-
Notifications
You must be signed in to change notification settings - Fork 12
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'Sage-Bionetworks:main' into org_srv_model_entity_unittest
- Loading branch information
Showing
9 changed files
with
192 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
19 changes: 15 additions & 4 deletions
19
apps/openchallenges/challenge-service/src/main/resources/db/challenges.csv
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
21 changes: 19 additions & 2 deletions
21
apps/openchallenges/organization-service/src/main/resources/db/organizations.csv
Large diffs are not rendered by default.
Oops, something went wrong.
71 changes: 71 additions & 0 deletions
71
...ebionetworks/openchallenges/organization/service/model/mapper/OrganizationMapperTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
package org.sagebionetworks.openchallenges.organization.service.model.mapper; | ||
|
||
import org.junit.jupiter.api.Assertions; | ||
import org.junit.jupiter.api.Test; | ||
import org.sagebionetworks.openchallenges.organization.service.model.dto.OrganizationDto; | ||
import org.sagebionetworks.openchallenges.organization.service.model.entity.OrganizationEntity; | ||
|
||
public class OrganizationMapperTest { | ||
@Test | ||
public void ConvertToEntity_ShouldReturnDtoProperties_WhenDtoPropertiesPassed() { | ||
|
||
// create new Dto with properties to be copied to organization entity | ||
OrganizationDto dto = new OrganizationDto(); | ||
dto.setName("Test Organization"); | ||
dto.setDescription("This is a test organization"); | ||
dto.setId(4599L); | ||
dto.setEmail("[email protected]"); | ||
dto.setLogin("login"); | ||
dto.setAvatarKey("avatar Key"); | ||
dto.setWebsiteUrl("url"); | ||
dto.setChallengeCount(7); | ||
dto.setAcronym(null); | ||
|
||
OrganizationMapper mapper = new OrganizationMapper(); | ||
|
||
OrganizationEntity entity = mapper.convertToEntity(dto); | ||
|
||
// verify the entity properties were copied | ||
Assertions.assertEquals(entity.getId(), dto.getId()); | ||
Assertions.assertEquals(entity.getName(), dto.getName()); | ||
Assertions.assertEquals(entity.getEmail(), dto.getEmail()); | ||
Assertions.assertEquals(entity.getLogin(), dto.getLogin()); | ||
Assertions.assertEquals(entity.getAvatarKey(), dto.getAvatarKey()); | ||
Assertions.assertEquals(entity.getWebsiteUrl(), dto.getWebsiteUrl()); | ||
Assertions.assertEquals(entity.getChallengeCount(), dto.getChallengeCount()); | ||
Assertions.assertEquals(entity.getDescription(), dto.getDescription()); | ||
Assertions.assertEquals(entity.getAcronym(), dto.getAcronym()); | ||
} | ||
|
||
@Test | ||
public void | ||
ConvertToDto_ShouldReturndDtoWithMatchingEntityProperties_WhenEntityPropertiesPassed() { | ||
|
||
OrganizationEntity entity = new OrganizationEntity(); | ||
|
||
entity.setName("Test Organization"); | ||
entity.setDescription("This is a test organization"); | ||
entity.setId(4599L); | ||
entity.setEmail("[email protected]"); | ||
entity.setLogin("login"); | ||
entity.setAvatarKey("avatar Key"); | ||
entity.setWebsiteUrl("url"); | ||
entity.setChallengeCount(7); | ||
entity.setAcronym(null); | ||
|
||
OrganizationMapper mapper = new OrganizationMapper(); | ||
|
||
OrganizationDto dto = mapper.convertToDto(entity); | ||
|
||
// verify the entity properties were copied | ||
Assertions.assertEquals(entity.getId(), dto.getId()); | ||
Assertions.assertEquals(entity.getName(), dto.getName()); | ||
Assertions.assertEquals(entity.getEmail(), dto.getEmail()); | ||
Assertions.assertEquals(entity.getLogin(), dto.getLogin()); | ||
Assertions.assertEquals(entity.getAvatarKey(), dto.getAvatarKey()); | ||
Assertions.assertEquals(entity.getWebsiteUrl(), dto.getWebsiteUrl()); | ||
Assertions.assertEquals(entity.getChallengeCount(), dto.getChallengeCount()); | ||
Assertions.assertEquals(entity.getDescription(), dto.getDescription()); | ||
Assertions.assertEquals(entity.getAcronym(), dto.getAcronym()); | ||
} | ||
} |
21 changes: 21 additions & 0 deletions
21
...ionetworks/openchallenges/organization/service/model/rest/response/ImageResponseTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
package org.sagebionetworks.openchallenges.organization.service.model.rest.response; | ||
|
||
import org.junit.jupiter.api.Assertions; | ||
import org.junit.jupiter.api.Test; | ||
|
||
public class ImageResponseTest { | ||
|
||
@Test | ||
public void ImageUrlGetterAndSetter_ShouldSetAndGetUrl_WhenCalledAfterImageUrlKeyPassed() { | ||
|
||
String imageUrl = "https://example.com/image.jpg"; | ||
ImageResponse imageResponse = new ImageResponse(); | ||
|
||
// Set the url | ||
imageResponse.setUrl(imageUrl); | ||
String actualUrl = imageResponse.getUrl(); | ||
|
||
// Confirm that the same image url was actual that was set | ||
Assertions.assertEquals(imageUrl, actualUrl); | ||
} | ||
} |