Skip to content

Commit

Permalink
Merge branch 'Sage-Bionetworks:main' into org_srv_model_entity_unittest
Browse files Browse the repository at this point in the history
  • Loading branch information
mdsage1 authored Dec 8, 2023
2 parents f72a9e7 + ca0f467 commit dcea741
Show file tree
Hide file tree
Showing 9 changed files with 192 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ public ChallengesPerYearDto getChallengesPerYear() {
"2018", "2019", "2020", "2021", "2022", "2023");
List<Integer> challengeCounts =
Arrays.asList(6, 9, 13, 17, 23, 29, 34, 41, 49, 59, 86, 97, 116, 135, 183, 242, 302);
Integer undatedChallengeCount = 160;
Integer undatedChallengeCount = 171;

// int currentYear = Year.now().getValue();
// years.removeIf(year -> Integer.parseInt(year) > currentYear);
Expand Down

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -1095,3 +1095,25 @@
"1094","463","408","sponsor"
"1095","464","407","sponsor"
"1096","465","407","sponsor"
"1097","466","414","sponsor"
"1098","466","416","data_contributor"
"1099","467","417","challenge_organizer"
"1100","467","418","challenge_organizer"
"1101","467","419","sponsor"
"1102","468","420","challenge_organizer"
"1103","468","418","challenge_organizer"
"1104","468","421","sponsor"
"1105","469","120","sponsor"
"1106","470","422","data_contributor"
"1107","471","423","data_contributor"
"1108","472","415","data_contributor"
"1109","472","424","data_contributor"
"1110","472","425","data_contributor"
"1111","473","426","sponsor"
"1112","474","415","data_contributor"
"1113","474","427","challenge_organizer"
"1114","474","428","data_contributor"
"1115","475","423","data_contributor"
"1116","476","429","sponsor"
"1117","476","339","sponsor"
"1118","476","430","sponsor"
Original file line number Diff line number Diff line change
Expand Up @@ -598,3 +598,12 @@
"597","publication","462","2023-11-13 22:51:53"
"598","speaking_engagement","462","2023-11-13 22:51:53"
"599","monetary","463","2023-11-16 21:57:03"
"600","monetary","466","2023-12-06 06:56:06"
"601","monetary","467","2023-12-06 07:35:00"
"602","speaking_engagement","467","2023-12-06 07:35:00"
"603","monetary","468","2023-12-06 07:52:34"
"604","monetary","469","2023-12-06 08:04:52"
"605","monetary","473","2023-12-06 08:35:31"
"606","publication","473","2023-12-06 08:35:31"
"607","monetary","474","2023-12-06 08:45:12"
"608","monetary","476","2023-12-06 08:54:24"
Original file line number Diff line number Diff line change
Expand Up @@ -455,3 +455,15 @@
"454","notebook","459","2023-11-11 01:29:20"
"455","prediction_file","463","2023-11-16 21:57:03"
"456","other","463","2023-11-16 21:57:03"
"457","notebook","466","2023-12-06 06:56:06"
"458","other","466","2023-12-06 06:56:06"
"459","prediction_file","467","2023-12-06 07:35:00"
"460","prediction_file","468","2023-12-06 07:52:34"
"461","prediction_file","469","2023-12-06 08:04:52"
"462","prediction_file","470","2023-12-06 08:10:49"
"463","prediction_file","471","2023-12-06 08:19:47"
"464","prediction_file","472","2023-12-06 08:28:42"
"465","prediction_file","473","2023-12-06 08:35:31"
"466","prediction_file","474","2023-12-06 08:45:12"
"467","prediction_file","475","2023-12-06 08:52:21"
"468","prediction_file","476","2023-12-06 08:54:24"
Original file line number Diff line number Diff line change
Expand Up @@ -1095,3 +1095,25 @@
"1094","463","408","sponsor"
"1095","464","407","sponsor"
"1096","465","407","sponsor"
"1097","466","414","sponsor"
"1098","466","416","data_contributor"
"1099","467","417","challenge_organizer"
"1100","467","418","challenge_organizer"
"1101","467","419","sponsor"
"1102","468","420","challenge_organizer"
"1103","468","418","challenge_organizer"
"1104","468","421","sponsor"
"1105","469","120","sponsor"
"1106","470","422","data_contributor"
"1107","471","423","data_contributor"
"1108","472","415","data_contributor"
"1109","472","424","data_contributor"
"1110","472","425","data_contributor"
"1111","473","426","sponsor"
"1112","474","415","data_contributor"
"1113","474","427","challenge_organizer"
"1114","474","428","data_contributor"
"1115","475","423","data_contributor"
"1116","476","429","sponsor"
"1117","476","339","sponsor"
"1118","476","430","sponsor"

Large diffs are not rendered by default.

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());
}
}
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);
}
}

0 comments on commit dcea741

Please sign in to comment.