Skip to content

Commit

Permalink
Merge pull request #53 from KPMP/KPMP-5713_Fix_tests
Browse files Browse the repository at this point in the history
KPMP-5713: Fix tests
  • Loading branch information
rlreamy authored Dec 16, 2024
2 parents fe7678e + 8f56f6d commit c5541c3
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import com.fasterxml.jackson.annotation.JsonIgnore;
import com.fasterxml.jackson.annotation.JsonProperty;

import com.fasterxml.jackson.annotation.JsonPropertyOrder;
import org.apache.commons.text.WordUtils;
import org.kpmp.file.File;

Expand All @@ -20,6 +21,9 @@

@Entity
@Table(name = "sv_file_v")
@JsonPropertyOrder(
{"externallink","configtype","imagetype","datatype","spectracksampleid","redcapid","participantid","age","protocol","sampletype","sex","tissuesource","enrollmentcategory","primaryadjudicatedcategory","kdigostage","baselineegfr","proteinuria","a1c","albuminuria","diabeteshistory","diabetesduration","hypertensionduration","hypertensionhistory","onraasblockade","race","releaseversion","participant_id_sort","image_type_sort","dlfileid","relatedfiles"}
)
public class SpatialViewerFileDataset implements SpatialViewerDataset {
private static final int UUID_LENGTH = 37;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
package org.kpmp.spatialViewerDataset;

import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.mockito.ArgumentMatchers.any;
import static org.mockito.ArgumentMatchers.anyString;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;

Expand Down Expand Up @@ -107,11 +109,11 @@ public void testLoadEnterpriseSearch() throws JSONException, Exception {
when(fileRepo.findAll()).thenReturn(expectedResult2);
results.addAll(expectedResult1);
results.addAll(expectedResult2);

HttpEntity<Object> entity = new HttpEntity<>(results, headers);
String expectedJson = "[{\"externallink\":\"11\",\"configtype\":null,\"imagetype\":\"\",\"datatype\":null,\"spectracksampleid\":null,\"redcapid\":\"123-456\",\"participantid\":123,\"age\":null,\"protocol\":null,\"sampletype\":null,\"sex\":null,\"tissuesource\":null,\"enrollmentcategory\":null,\"primaryadjudicatedcategory\":null,\"kdigostage\":null,\"baselineegfr\":null,\"proteinuria\":null,\"a1c\":null,\"albuminuria\":null,\"diabeteshistory\":null,\"diabetesduration\":null,\"hypertensionduration\":null,\"hypertensionhistory\":null,\"onraasblockade\":null,\"race\":null,\"releaseversion\":null,\"participant_id_sort\":123456,\"image_type_sort\":\"\",\"dlfileid\":null,\"relatedfiles\":[]},{\"externallink\":\"55\",\"configtype\":null,\"imagetype\":\"\",\"datatype\":null,\"spectracksampleid\":null,\"redcapid\":\"345-456\",\"participantid\":345,\"age\":null,\"protocol\":null,\"sampletype\":null,\"sex\":null,\"tissuesource\":null,\"enrollmentcategory\":null,\"primaryadjudicatedcategory\":null,\"kdigostage\":null,\"baselineegfr\":null,\"proteinuria\":null,\"a1c\":null,\"albuminuria\":null,\"diabeteshistory\":null,\"diabetesduration\":null,\"hypertensionduration\":null,\"hypertensionhistory\":null,\"onraasblockade\":null,\"race\":null,\"releaseversion\":null,\"participant_id_sort\":345456,\"image_type_sort\":\"\",\"dlfileid\":null,\"relatedfiles\":[]},{\"externallink\":null,\"configtype\":null,\"imagetype\":\"\",\"datatype\":null,\"spectracksampleid\":null,\"redcapid\":\"456-456\",\"participantid\":456,\"age\":null,\"protocol\":null,\"sampletype\":null,\"sex\":null,\"tissuesource\":null,\"enrollmentcategory\":null,\"primaryadjudicatedcategory\":null,\"kdigostage\":null,\"baselineegfr\":null,\"proteinuria\":null,\"a1c\":null,\"albuminuria\":null,\"diabeteshistory\":null,\"diabetesduration\":null,\"hypertensionduration\":null,\"hypertensionhistory\":null,\"onraasblockade\":null,\"race\":null,\"releaseversion\":null,\"participant_id_sort\":456456,\"image_type_sort\":\"\",\"dlfileid\":\"DlFileId\",\"relatedfiles\":null,\"fileid\":444,\"filename\":null,\"packageid\":null,\"filesize\":null,\"level\":null,\"file_name_sort\":null,\"spatialviewerdataset\":null},{\"externallink\":null,\"configtype\":null,\"imagetype\":\"\",\"datatype\":null,\"spectracksampleid\":null,\"redcapid\":\"566-456\",\"participantid\":566,\"age\":null,\"protocol\":null,\"sampletype\":null,\"sex\":null,\"tissuesource\":null,\"enrollmentcategory\":null,\"primaryadjudicatedcategory\":null,\"kdigostage\":null,\"baselineegfr\":null,\"proteinuria\":null,\"a1c\":null,\"albuminuria\":null,\"diabeteshistory\":null,\"diabetesduration\":null,\"hypertensionduration\":null,\"hypertensionhistory\":null,\"onraasblockade\":null,\"race\":null,\"releaseversion\":\"Recently Released - release-date\",\"participant_id_sort\":566456,\"image_type_sort\":\"\",\"dlfileid\":\"DlFileId2\",\"relatedfiles\":null,\"fileid\":888,\"filename\":null,\"packageid\":null,\"filesize\":null,\"level\":null,\"file_name_sort\":null,\"spatialviewerdataset\":null}]";
HttpEntity<Object> entity = new HttpEntity<>(expectedJson, headers);
SpatialViewerDatasetService.ESResponse[] esResponses = {new SpatialViewerDatasetService.ESResponse()};
// when(restTemplate.postForObject("host/api/as/v1/engines/search-engine/documents", entity, SpatialViewerDatasetService.ESResponse[].class)).thenReturn(esResponses);
// service.loadEnterpriseSearch();
// verify(restTemplate).postForObject("host/api/as/v1/engines/search-engine/documents", entity, SpatialViewerDatasetService.ESResponse[].class);
when(restTemplate.postForObject(anyString(), any(), any(Class.class))).thenReturn(esResponses);
service.loadEnterpriseSearch();
verify(restTemplate).postForObject("host/api/as/v1/engines/search-engine/documents", entity, SpatialViewerDatasetService.ESResponse[].class);
}
}

0 comments on commit c5541c3

Please sign in to comment.