diff --git a/apps/openchallenges/organization-service/src/test/java/org/sagebionetworks/openchallenges/organization/service/model/mapper/OrganizationMapperTest.java b/apps/openchallenges/organization-service/src/test/java/org/sagebionetworks/openchallenges/organization/service/model/mapper/OrganizationMapperTest.java new file mode 100644 index 0000000000..66dc66825a --- /dev/null +++ b/apps/openchallenges/organization-service/src/test/java/org/sagebionetworks/openchallenges/organization/service/model/mapper/OrganizationMapperTest.java @@ -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("testemail@test.edu"); + 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("testemail@test.edu"); + 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()); + } +} diff --git a/apps/openchallenges/organization-service/src/test/java/org/sagebionetworks/openchallenges/organization/service/model/rest/response/ImageResponseTest.java b/apps/openchallenges/organization-service/src/test/java/org/sagebionetworks/openchallenges/organization/service/model/rest/response/ImageResponseTest.java new file mode 100644 index 0000000000..ec046ea334 --- /dev/null +++ b/apps/openchallenges/organization-service/src/test/java/org/sagebionetworks/openchallenges/organization/service/model/rest/response/ImageResponseTest.java @@ -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); + } +}