Skip to content

Commit

Permalink
Fixed typo in the SignupJsonInput class and in the classes that depen…
Browse files Browse the repository at this point in the history
…ds on it. mercedes-benz#1139
  • Loading branch information
zigfridus committed Dec 22, 2023
1 parent fcd4d5f commit c4ca1ad
Show file tree
Hide file tree
Showing 10 changed files with 49 additions and 49 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ public class AnonymousSignupCreateService {
@UseCaseUserSignup(@Step(number = 2, name = "Persistence", description = "Valid self registration input will be persisted to database."))
public void register(@Valid SignupJsonInput userSelfRegistrationInput) {
String userId = userSelfRegistrationInput.getUserId();
String emailAddress = userSelfRegistrationInput.getEmailAdress();
String emailAddress = userSelfRegistrationInput.getEmailAddress();

LOG.debug("user tries to register himself:{},mail:{}", userId, emailAddress);

Expand All @@ -63,7 +63,7 @@ public void register(@Valid SignupJsonInput userSelfRegistrationInput) {

assertNotAlreadySignedIn(userId, emailAddress);
assertUsernameNotUsedAlready(userId, emailAddress);
assertEmailAdressNotUsedAlready(userId, emailAddress);
assertEmailAddressNotUsedAlready(userId, emailAddress);

Signup entity = new Signup();

Expand All @@ -89,29 +89,29 @@ private void informAboutSignupRequest(Signup signup) {
eventBusService.sendAsynchron(infoRequest);
}

private void assertEmailAdressNotUsedAlready(String userId, String emailAdress) {
Optional<User> foundUserByMail = userRepository.findByEmailAddress(emailAdress);
private void assertEmailAddressNotUsedAlready(String userId, String emailAddress) {
Optional<User> foundUserByMail = userRepository.findByEmailAddress(emailAddress);

if (foundUserByMail.isPresent()) {
LOG.warn("Self registration coming in for emailadress:{} and user:{} but an existing user does already have this email adress. So not accepted",
emailAdress, userId);
LOG.warn("Self registration coming in for email address:{} and user:{} but an existing user does already have this email address. So not accepted",
emailAddress, userId);
handleRegistrationNotPossible();
}
}

private void assertUsernameNotUsedAlready(String userId, String emailAdress) {
private void assertUsernameNotUsedAlready(String userId, String emailAddress) {
Optional<User> foundUser = userRepository.findById(userId);

if (foundUser.isPresent()) {
LOG.warn("Self registration coming in for emailadress:{} and user:{} but existing user found by name. So not accepted", emailAdress, userId);
LOG.warn("Self registration coming in for email address:{} and user:{} but existing user found by name. So not accepted", emailAddress, userId);
handleRegistrationNotPossible();
}
}

private void assertNotAlreadySignedIn(String userId, String emailAdress) {
private void assertNotAlreadySignedIn(String userId, String emailAddress) {
Optional<Signup> found = userSelfRegistrationRepository.findById(userId);
if (found.isPresent()) {
LOG.warn("Self registration coming in for emailadress:{} and user:{} but signup already exists. So not accepted", emailAdress, userId);
LOG.warn("Self registration coming in for email address:{} and user:{} but signup already exists. So not accepted", emailAddress, userId);
handleRegistrationNotPossible();
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,11 @@ public class SignupJsonInput implements JSONable<SignupJsonInput> {

public static final String PROPERTY_API_VERSION = "apiVersion";
public static final String PROPERTY_USER_ID = "userId";
public static final String PROPERTY_EMAIL_ADRESS = "emailAdress";
public static final String PROPERTY_EMAIL_ADDRESS = "emailAddress";

private String apiVersion;
private String userId;
private String emailAdress;
private String emailAddress;

@Override
public Class<SignupJsonInput> getJSONTargetClass() {
Expand All @@ -38,12 +38,12 @@ public void setUserId(String userId) {
this.userId = userId;
}

public String getEmailAdress() {
return emailAdress;
public String getEmailAddress() {
return emailAddress;
}

public void setEmailAdress(String emailAdress) {
this.emailAdress = emailAdress;
public void setEmailAddress(String emailAddress) {
this.emailAddress = emailAddress;
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -62,9 +62,9 @@ public void validate(Object target, Errors errors) {
return;
}

ValidationResult emailValidationResult = emailValidation.validate(selfRegistration.getEmailAdress());
ValidationResult emailValidationResult = emailValidation.validate(selfRegistration.getEmailAddress());
if (!emailValidationResult.isValid()) {
errors.rejectValue(PROPERTY_EMAIL_ADRESS, "api.error.email.invalid", "Invalid email adress");
errors.rejectValue(PROPERTY_EMAIL_ADDRESS, "api.error.email.invalid", "Invalid email address");
return;
}
LOG.debug("Selfregistration of {} was accepted", selfRegistration.getUserId());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ public void calling_with_api_1_0_and_valid_userid_and_email_calls_signup_create_
this.mockMvc.perform(
post(https(PORT_USED).buildUserSignUpUrl()).
contentType(MediaType.APPLICATION_JSON_VALUE).
content("{\"apiVersion\":\"1.0\",\"userId\":\"valid_userid\",\"emailAdress\":\"valid_mailadress@test.com\"}")
content("{\"apiVersion\":\"1.0\",\"userId\":\"valid_userid\",\"emailAddress\":\"valid_mailaddress@test.com\"}")
).
andExpect(status().isOk()
);
Expand Down Expand Up @@ -163,7 +163,7 @@ private SignupJsonInput createUserSelfRegistration(String api, String email, Str

SignupJsonInput created = new SignupJsonInput();
created.setApiVersion(api);
created.setEmailAdress(email);
created.setEmailAddress(email);
created.setUserId(name);
return created;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ public void a_created_signup_sends_event_containing_userid_and_email() {
/* prepare */
SignupJsonInput userSelfRegistrationInput = mock(SignupJsonInput.class);
when(userSelfRegistrationInput.getUserId()).thenReturn("schlaubi");
when(userSelfRegistrationInput.getEmailAdress()).thenReturn("schlaubi@schlumpfhausen.de");
when(userSelfRegistrationInput.getEmailAddress()).thenReturn("schlaubi@schlumpfhausen.de");

/* execute */
serviceToTest.register(userSelfRegistrationInput);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ public String getApiVersion() {
}

public String getEmailAdress() {
return internalAccess.getEmailAdress();
return internalAccess.getEmailAddress();
}

public String getUserId() {
Expand All @@ -66,8 +66,8 @@ public void setApiVersion(String apiVersion) {
internalAccess.setApiVersion(apiVersion);
}

public void setEmailAdress(String emailAdress) {
internalAccess.setEmailAdress(emailAdress);
public void setEmailAdress(String emailAddress) {
internalAccess.setEmailAddress(emailAddress);
}

public void setUserId(String userId) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,8 @@ public String getApiVersion() {
return delegate.getApiVersion();
}

public String getEmailAdress() {
return delegate.getEmailAdress();
public String getEmailAddress() {
return delegate.getEmailAddress();
}

public String getUserId() {
Expand All @@ -47,8 +47,8 @@ public void setApiVersion(String apiVersion) {
delegate.setApiVersion(apiVersion);
}

public void setEmailAdress(String emailAdress) {
delegate.setEmailAdress(emailAdress);
public void setEmailAddress(String emailAddress) {
delegate.setEmailAddress(emailAddress);
}

public void setUserId(String userId) {
Expand Down
36 changes: 18 additions & 18 deletions sechub-api-java/src/main/resources/reduced-openapi3.json
Original file line number Diff line number Diff line change
Expand Up @@ -2524,24 +2524,6 @@
"description": "List of user signups"
}
},
"UserSignup": {
"title": "UserSignup",
"type": "object",
"properties": {
"apiVersion": {
"type": "string",
"description": "The api version, currently only 1.0 is supported"
},
"emailAdress": {
"type": "string",
"description": "Email adress"
},
"userId": {
"type": "string",
"description": "Wanted userid, the userid must be lowercase only!"
}
}
},
"Project": {
"title": "Project",
"type": "object",
Expand Down Expand Up @@ -2590,6 +2572,24 @@
"title": "ExecutorConfigurationId",
"type": "object"
},
"UserSignup": {
"title": "UserSignup",
"type": "object",
"properties": {
"emailAddress": {
"type": "string",
"description": "Email address"
},
"apiVersion": {
"type": "string",
"description": "The api version, currently only 1.0 is supported"
},
"userId": {
"type": "string",
"description": "Wanted userid, the userid must be lowercase only!"
}
}
},
"ProjectJobList": {
"title": "ProjectJobList",
"type": "object",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ public void calling_with_api_1_0_and_valid_userid_and_email_returns_HTTP_200() t
this.mockMvc.perform(
post(apiEndpoint).
contentType(MediaType.APPLICATION_JSON_VALUE).
content("{\"apiVersion\":\"1.0\",\"userId\":\"valid_userid\",\"emailAdress\":\"valid_mailadress@test.com\"}")
content("{\"apiVersion\":\"1.0\",\"userId\":\"valid_userid\",\"emailAddress\":\"valid_mailaddress@test.com\"}")
)./*andDo(print()).*/
andExpect(status().isOk()).
andDo(defineRestService().
Expand All @@ -84,7 +84,7 @@ public void calling_with_api_1_0_and_valid_userid_and_email_returns_HTTP_200() t
requestFields(
fieldWithPath("apiVersion").description("The api version, currently only 1.0 is supported"),
fieldWithPath("userId").description("Wanted userid, the userid must be lowercase only!"),
fieldWithPath("emailAdress").description("Email adress")
fieldWithPath("emailAddress").description("Email address")
)
)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,7 @@ private TestRestHelper getRestHelper() {
*/
public AsUser signUpAs(TestUser user) {

String json = "{\"apiVersion\":\"1.0\",\r\n" + " \"userId\":\"" + user.getUserId() + "\",\r\n" + " \"emailAdress\":\"" + user.getEmail()
String json = "{\"apiVersion\":\"1.0\",\r\n" + " \"userId\":\"" + user.getUserId() + "\",\r\n" + " \"emailAddress\":\"" + user.getEmail()
+ "\"}";
getRestHelper().postJson(getUrlBuilder().buildUserSignUpUrl(), json);
return this;
Expand Down

0 comments on commit c4ca1ad

Please sign in to comment.