Skip to content

Commit

Permalink
[Hexlet#159] fix redirect, handling of existing user, add test
Browse files Browse the repository at this point in the history
  • Loading branch information
d1z3d committed Sep 2, 2024
1 parent 8caa628 commit e4c87af
Show file tree
Hide file tree
Showing 20 changed files with 690 additions and 61 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
package io.hexlet.typoreporter.service.account.signup;

import io.hexlet.typoreporter.web.model.SignupAccountModel;
import javax.annotation.processing.Generated;
import org.springframework.stereotype.Component;

@Generated(
value = "org.mapstruct.ap.MappingProcessor",
date = "2024-09-01T23:33:48+0300",
comments = "version: 1.5.3.Final, compiler: javac, environment: Java 19.0.2 (Amazon.com Inc.)"
)
@Component
public class SignupAccountMapperImpl implements SignupAccountMapper {

@Override
public SignupAccount toSignupAccount(SignupAccountModel signupAccountModel) {
if ( signupAccountModel == null ) {
return null;
}

String username = null;
String email = null;
String password = null;
String firstName = null;
String lastName = null;

username = signupAccountModel.getUsername();
email = signupAccountModel.getEmail();
password = signupAccountModel.getPassword();
firstName = signupAccountModel.getFirstName();
lastName = signupAccountModel.getLastName();

SignupAccount signupAccount = new SignupAccount( username, email, password, firstName, lastName );

return signupAccount;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,87 @@
package io.hexlet.typoreporter.service.mapper;

import io.hexlet.typoreporter.domain.account.Account;
import io.hexlet.typoreporter.service.account.signup.SignupAccount;
import io.hexlet.typoreporter.service.dto.account.InfoAccount;
import io.hexlet.typoreporter.service.dto.account.UpdateProfile;
import javax.annotation.processing.Generated;
import org.springframework.stereotype.Component;

@Generated(
value = "org.mapstruct.ap.MappingProcessor",
date = "2024-09-01T23:33:48+0300",
comments = "version: 1.5.3.Final, compiler: javac, environment: Java 19.0.2 (Amazon.com Inc.)"
)
@Component
public class AccountMapperImpl implements AccountMapper {

@Override
public InfoAccount toInfoAccount(Account source) {
if ( source == null ) {
return null;
}

Long id = null;
String email = null;
String username = null;
String firstName = null;
String lastName = null;

id = source.getId();
email = source.getEmail();
username = source.getUsername();
firstName = source.getFirstName();
lastName = source.getLastName();

InfoAccount infoAccount = new InfoAccount( id, email, username, firstName, lastName );

return infoAccount;
}

@Override
public UpdateProfile toUpdateProfile(Account source) {
if ( source == null ) {
return null;
}

UpdateProfile updateProfile = new UpdateProfile();

updateProfile.setUsername( source.getUsername() );
updateProfile.setEmail( source.getEmail() );
updateProfile.setFirstName( source.getFirstName() );
updateProfile.setLastName( source.getLastName() );

return updateProfile;
}

@Override
public Account toAccount(UpdateProfile source, Account account) {
if ( source == null ) {
return account;
}

account.setEmail( source.getEmail() );
account.setUsername( source.getUsername() );
account.setFirstName( source.getFirstName() );
account.setLastName( source.getLastName() );

return account;
}

@Override
public Account toAccount(SignupAccount source) {
if ( source == null ) {
return null;
}

Account account = new Account();

account.setEmail( source.email() );
account.setUsername( source.username() );
account.setPassword( source.password() );
account.setFirstName( source.firstName() );
account.setLastName( source.lastName() );

return account;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,113 @@
package io.hexlet.typoreporter.service.mapper;

import io.hexlet.typoreporter.domain.typo.Typo;
import io.hexlet.typoreporter.domain.typo.TypoStatus;
import io.hexlet.typoreporter.service.dto.typo.ReportedTypo;
import io.hexlet.typoreporter.service.dto.typo.TypoInfo;
import io.hexlet.typoreporter.service.dto.typo.TypoReport;
import java.time.Instant;
import javax.annotation.processing.Generated;
import org.springframework.stereotype.Component;

@Generated(
value = "org.mapstruct.ap.MappingProcessor",
date = "2024-09-01T23:33:48+0300",
comments = "version: 1.5.3.Final, compiler: javac, environment: Java 19.0.2 (Amazon.com Inc.)"
)
@Component
public class TypoMapperImpl implements TypoMapper {

@Override
public Typo toTypo(TypoReport source) {
if ( source == null ) {
return null;
}

Typo typo = new Typo();

typo.setPageUrl( source.pageUrl() );
typo.setReporterName( source.reporterName() );
typo.setReporterComment( source.reporterComment() );
typo.setTextBeforeTypo( source.textBeforeTypo() );
typo.setTextTypo( source.textTypo() );
typo.setTextAfterTypo( source.textAfterTypo() );

return typo;
}

@Override
public TypoInfo toTypoInfo(Typo source) {
if ( source == null ) {
return null;
}

String modifiedDateAgo = null;
String createdDateAgo = null;
String typoStatusStr = null;
Long id = null;
String pageUrl = null;
String reporterName = null;
String reporterComment = null;
String textBeforeTypo = null;
String textTypo = null;
String textAfterTypo = null;
TypoStatus typoStatus = null;
String createdBy = null;
Instant createdDate = null;
String modifiedBy = null;
Instant modifiedDate = null;

modifiedDateAgo = getDateAgoAsString( source.getModifiedDate() );
createdDateAgo = getDateAgoAsString( source.getCreatedDate() );
if ( source.getTypoStatus() != null ) {
typoStatusStr = source.getTypoStatus().name();
}
id = source.getId();
pageUrl = source.getPageUrl();
reporterName = source.getReporterName();
reporterComment = source.getReporterComment();
textBeforeTypo = source.getTextBeforeTypo();
textTypo = source.getTextTypo();
textAfterTypo = source.getTextAfterTypo();
typoStatus = source.getTypoStatus();
createdBy = source.getCreatedBy();
createdDate = source.getCreatedDate();
modifiedBy = source.getModifiedBy();
modifiedDate = source.getModifiedDate();

TypoInfo typoInfo = new TypoInfo( id, pageUrl, reporterName, reporterComment, textBeforeTypo, textTypo, textAfterTypo, typoStatusStr, typoStatus, createdBy, createdDateAgo, createdDate, modifiedBy, modifiedDateAgo, modifiedDate );

return typoInfo;
}

@Override
public ReportedTypo toReportedTypo(Typo source) {
if ( source == null ) {
return null;
}

Long id = null;
String pageUrl = null;
String reporterName = null;
String reporterComment = null;
String textBeforeTypo = null;
String textTypo = null;
String textAfterTypo = null;
String createdBy = null;
Instant createdDate = null;

id = source.getId();
pageUrl = source.getPageUrl();
reporterName = source.getReporterName();
reporterComment = source.getReporterComment();
textBeforeTypo = source.getTextBeforeTypo();
textTypo = source.getTextTypo();
textAfterTypo = source.getTextAfterTypo();
createdBy = source.getCreatedBy();
createdDate = source.getCreatedDate();

ReportedTypo reportedTypo = new ReportedTypo( id, pageUrl, reporterName, reporterComment, textBeforeTypo, textTypo, textAfterTypo, createdBy, createdDate );

return reportedTypo;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
package io.hexlet.typoreporter.service.mapper;

import io.hexlet.typoreporter.domain.workspace.Workspace;
import io.hexlet.typoreporter.service.dto.workspace.CreateWorkspace;
import io.hexlet.typoreporter.service.dto.workspace.WorkspaceInfo;
import java.time.Instant;
import javax.annotation.processing.Generated;
import org.springframework.stereotype.Component;

@Generated(
value = "org.mapstruct.ap.MappingProcessor",
date = "2024-09-01T23:33:48+0300",
comments = "version: 1.5.3.Final, compiler: javac, environment: Java 19.0.2 (Amazon.com Inc.)"
)
@Component
public class WorkspaceMapperImpl implements WorkspaceMapper {

@Override
public Workspace toWorkspace(CreateWorkspace source) {
if ( source == null ) {
return null;
}

Workspace workspace = new Workspace();

workspace.setName( source.name() );
workspace.setUrl( source.url() );
workspace.setDescription( source.description() );

return workspace;
}

@Override
public WorkspaceInfo toWorkspaceInfo(Workspace source) {
if ( source == null ) {
return null;
}

String createdDateAgo = null;
String modifiedDateAgo = null;
Long id = null;
String name = null;
String url = null;
String description = null;
String createdBy = null;
Instant createdDate = null;
String modifiedBy = null;
Instant modifiedDate = null;

createdDateAgo = getDateAgoAsString( source.getCreatedDate() );
modifiedDateAgo = getDateAgoAsString( source.getModifiedDate() );
id = source.getId();
name = source.getName();
url = source.getUrl();
description = source.getDescription();
createdBy = source.getCreatedBy();
createdDate = source.getCreatedDate();
modifiedBy = source.getModifiedBy();
modifiedDate = source.getModifiedDate();

WorkspaceInfo workspaceInfo = new WorkspaceInfo( id, name, url, description, createdBy, createdDate, createdDateAgo, modifiedBy, modifiedDate, modifiedDateAgo );

return workspaceInfo;
}
}
Loading

0 comments on commit e4c87af

Please sign in to comment.