Skip to content

Commit

Permalink
update the unit tests for mapper
Browse files Browse the repository at this point in the history
  • Loading branch information
mdsage1 committed Dec 5, 2023
1 parent ee9ca10 commit 7e0e0a3
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 47 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
@SpringBootTest
class OrganizationServiceApplicationTests {

//integration test
// integration test
@Test
void contextLoads() {}
}
Original file line number Diff line number Diff line change
Expand Up @@ -38,28 +38,6 @@ public void ConvertToEntity_ShouldReturnDtoProperties_WhenDtoPropertiesPassed()
assertThat(OrganizationEntity.getAcronym()).isEqualTo(user.getAcronym());
}

@Test
public void convertToEntity_ShouldReturnNullProperties_WhenDtoPropertiesNotPassed() {

OrganizationDto user = new OrganizationDto(null);
// don't set dto properties to avoid BeanUtils.copyProperties from passing them to the new
// entity

OrganizationMapper mapper = new OrganizationMapper();

OrganizationEntity organizationEntity = mapper.convertToEntity(user);

assertThat(organizationEntity.getName()).isEqualTo(null);
assertThat(organizationEntity.getDescription()).isEqualTo(null);
assertThat(organizationEntity.getId()).isEqualTo(null);
assertThat(organizationEntity.getEmail()).isEqualTo(null);
assertThat(organizationEntity.getLogin()).isEqualTo(null);
assertThat(organizationEntity.getAvatarKey()).isEqualTo(null);
assertThat(organizationEntity.getWebsiteUrl()).isEqualTo(null);
assertThat(organizationEntity.getChallengeCount()).isEqualTo(null);
assertThat(organizationEntity.getAcronym()).isEqualTo(null);
}

@Test
public void
ConvertToDto_ShouldReturndDtoWithMatchingEntityProperties_WhenEntityPropertiesPassed() {
Expand Down Expand Up @@ -91,28 +69,4 @@ public void convertToEntity_ShouldReturnNullProperties_WhenDtoPropertiesNotPasse
assertThat(user.getChallengeCount()).isEqualTo(organizationEntity.getChallengeCount());
assertThat(user.getAcronym()).isEqualTo(organizationEntity.getAcronym());
}

@Test
public void convertToDto_ShouldReturnNullProperties_WhenEntityPropertiesNotPassed() {

OrganizationEntity organizationEntity = new OrganizationEntity(null);
// don't set entity properties to avoid BeanUtils.copyProperties from passing them to the new
// entity

OrganizationMapper mapper = new OrganizationMapper();

OrganizationDto user = mapper.convertTouser(organizationEntity);
// don't set dto properties to avoid BeanUtils.copyProperties from passing them to the new
// entity

assertThat(user.getName()).isEqualTo(null);
assertThat(user.getDescription()).isEqualTo(null);
assertThat(user.getId()).isEqualTo(null);
assertThat(user.getEmail()).isEqualTo(null);
assertThat(user.getLogin()).isEqualTo(null);
assertThat(user.getAvatarKey()).isEqualTo(null);
assertThat(user.getWebsiteUrl()).isEqualTo(null);
assertThat(user.getChallengeCount()).isEqualTo(null);
assertThat(user.getAcronym()).isEqualTo(null);
}
}

0 comments on commit 7e0e0a3

Please sign in to comment.