Skip to content

Commit

Permalink
Merge pull request #40 from KPMP/KPMP-217_Add_Protocol_To_Metadata
Browse files Browse the repository at this point in the history
KPMP-217: add the protocol to metadata
  • Loading branch information
rlreamy authored Aug 8, 2018
2 parents 581a44a + 2689cb6 commit 028ea28
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 1 deletion.
9 changes: 9 additions & 0 deletions src/main/java/org/kpmp/dao/UploadPackageMetadata.java
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ public class UploadPackageMetadata {
private String experimentDate;
private String createdAt;
private String packageType;
private String protocol;
private String submitterFirstName;
private String submitterLastName;
private String institution;
Expand Down Expand Up @@ -81,6 +82,7 @@ public UploadPackageMetadata(UploadPackage uploadPackage) {
demographics = fileSubmission.getInstitution();
}

this.protocol = uploadPackage.getProtocol().getProtocol();
this.submitterFirstName = submitter.getFirstName();
this.submitterLastName = submitter.getLastName();
this.institution = demographics.getInstitutionName();
Expand Down Expand Up @@ -163,4 +165,11 @@ public void setFiles(List<FileSubmissionJSON> files) {
this.files = files;
}

public String getProtocol() {
return protocol;
}

public void setProtocol(String protocol) {
this.protocol = protocol;
}
}
8 changes: 7 additions & 1 deletion src/test/java/org/kpmp/dao/UploadPackageMetadataTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -32,11 +32,14 @@ public void setUp() throws Exception {
now = new Date();

uploadPackage = mock(UploadPackage.class);
Protocol protocol = mock(Protocol.class);
when(protocol.getProtocol()).thenReturn("The Protocol");
when(uploadPackage.getCreatedAt()).thenReturn(now);
when(uploadPackage.getExperimentDate()).thenReturn(now);
when(uploadPackage.getId()).thenReturn(1);
when(uploadPackage.getSubjectId()).thenReturn("42");
when(uploadPackage.getUniversalId()).thenReturn("uuid-package");
when(uploadPackage.getProtocol()).thenReturn(protocol);

PackageType packageType = mock(PackageType.class);
when(packageType.getPackageType()).thenReturn("Big Data");
Expand Down Expand Up @@ -82,6 +85,7 @@ public void testConstructor() throws Exception {
assertEquals("42", uploadPackageMetadata.getSubjectId());
assertEquals("Mattie", uploadPackageMetadata.getSubmitterFirstName());
assertEquals("Dayta", uploadPackageMetadata.getSubmitterLastName());
assertEquals("The Protocol", uploadPackageMetadata.getProtocol());
}

@Test
Expand All @@ -99,7 +103,7 @@ public void testGenerateJSON() throws JsonProcessingException {
String date = dateFormat.format(now);
String expected = "{\"id\":\"uuid-package\",\"subjectId\":\"42\",\"experimentDate\":\""
+ date + "\",\"createdAt\":\"" + date
+ "\",\"packageType\":\"Big Data\",\"submitterFirstName\":\"Mattie\",\"submitterLastName\":\"Dayta\","
+ "\",\"packageType\":\"Big Data\",\"protocol\":\"The Protocol\",\"submitterFirstName\":\"Mattie\",\"submitterLastName\":\"Dayta\","
+ "\"institution\":\"Mars University\",\"files\":[{\"path\":\"/package1/filename\",\"size\":12345,\"fileName\":\"filename\",\"description\":\"file description\",\"universalId\":\"uuid-file\"}]}";
assertEquals(expected, actual);
}
Expand All @@ -114,6 +118,7 @@ public void testSetters() throws Exception {
uploadPackageMetadata.setSubjectId("242");
uploadPackageMetadata.setSubmitterFirstName("Zap");
uploadPackageMetadata.setSubmitterLastName("Branigan");
uploadPackageMetadata.setProtocol("The Protocol");

assertEquals("2014-04-16", uploadPackageMetadata.getCreatedAt());
assertEquals("2017-07-08", uploadPackageMetadata.getExperimentDate());
Expand All @@ -123,6 +128,7 @@ public void testSetters() throws Exception {
assertEquals("242", uploadPackageMetadata.getSubjectId());
assertEquals("Zap", uploadPackageMetadata.getSubmitterFirstName());
assertEquals("Branigan", uploadPackageMetadata.getSubmitterLastName());
assertEquals("The Protocol", uploadPackageMetadata.getProtocol());

}

Expand Down

0 comments on commit 028ea28

Please sign in to comment.