diff --git a/CHANGELOG.md b/CHANGELOG.md index af62392169f..c80bd7c1db7 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,13 +1,14 @@ # Changelog +## [23.01.3] +* [Developer]: Fixed issue with metadata uploader removing exiting data. See [PR 1489](https://github.com/phac-nml/irida/pull/1489) -## [23.01.2] +## [23.01.2] - 2023/04/17 * [UI]: Fixed bug that caused all metadata fields to be removed when single field was removed from a template. See [PR 1482](https://github.com/phac-nml/irida/pull/1482) * [Developer]: Fixed bug which allowed duplicated entries in the user_group_project table which prevented the user group from being removed. Fixed bug which was preventing analyses with `html` file outputs from completing. See [PR 1483](https://github.com/phac-nml/irida/pull/1483) * [Developer]: Fixed flaky PipelinesPhylogenomicsPageIT test. See [PR 1482](https://github.com/phac-nml/irida/pull/1482) * [REST]: Fixed issues with syncing between newer IRIDA (>22.09) and older IRIDA (<=20.09) by disabling requests for `application/xml` for some of the REST requests and only requesting data as `application/json`. See [PR 1484](https://github.com/phac-nml/irida/pull/1484). - ## [23.01.1] - 2023/03/21 * [UI]: Fixed issue where template order was not applied when applying a linelist template. See [PR 1479](https://github.com/phac-nml/irida/pull/1479) * [UI]: Added select all to associated projects filter on project > samples page. See [PR 1479](https://github.com/phac-nml/irida/pull/1479) @@ -187,8 +188,9 @@ ## [...previous](https://github.com/phac-nml/irida/blob/21.09.2/CHANGELOG.md) -[Unreleased]: https://github.com/phac-nml/irida/compare/23.01.2...HEAD +[Unreleased]: https://github.com/phac-nml/irida/compare/23.01.3...HEAD +[23.01.3]: https://github.com/phac-nml/irida/compare/23.01.2...23.01.3 [23.01.2]: https://github.com/phac-nml/irida/compare/23.01.1...23.01.2 [23.01.1]: https://github.com/phac-nml/irida/compare/23.01...23.01.1 [23.01]: https://github.com/phac-nml/irida/compare/22.09.7...23.01 diff --git a/build.gradle.kts b/build.gradle.kts index f5a0f202ccd..4ecf26d56dc 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -14,7 +14,7 @@ plugins { } group = "ca.corefacility.bioinformatics" -version = "23.01.2" +version = "23.01.3" description = "irida" java { diff --git a/src/main/java/ca/corefacility/bioinformatics/irida/ria/web/services/UIProjectSampleService.java b/src/main/java/ca/corefacility/bioinformatics/irida/ria/web/services/UIProjectSampleService.java index 5f803ce9302..c98b8ec4d28 100644 --- a/src/main/java/ca/corefacility/bioinformatics/irida/ria/web/services/UIProjectSampleService.java +++ b/src/main/java/ca/corefacility/bioinformatics/irida/ria/web/services/UIProjectSampleService.java @@ -208,7 +208,7 @@ public Sample updateSample(UpdateSampleRequest request) } if (request.getMetadata() != null) { Set metadataEntrySet = createMetadata(request.getMetadata()); - sampleService.updateSampleMetadata(sample, metadataEntrySet); + sampleService.mergeSampleMetadata(sample, metadataEntrySet); } return sampleService.update(sample); diff --git a/src/test/java/ca/corefacility/bioinformatics/irida/ria/integration/projects/ProjectSampleMetadataImportPageIT.java b/src/test/java/ca/corefacility/bioinformatics/irida/ria/integration/projects/ProjectSampleMetadataImportPageIT.java index 78bcfbc3663..30cce8e255f 100644 --- a/src/test/java/ca/corefacility/bioinformatics/irida/ria/integration/projects/ProjectSampleMetadataImportPageIT.java +++ b/src/test/java/ca/corefacility/bioinformatics/irida/ria/integration/projects/ProjectSampleMetadataImportPageIT.java @@ -9,6 +9,7 @@ import org.junit.jupiter.api.Test; import ca.corefacility.bioinformatics.irida.ria.integration.AbstractIridaUIITChromeDriver; +import ca.corefacility.bioinformatics.irida.ria.integration.components.SampleDetailsViewer; import ca.corefacility.bioinformatics.irida.ria.integration.pages.LoginPage; import ca.corefacility.bioinformatics.irida.ria.integration.pages.ProjectMembersPage; import ca.corefacility.bioinformatics.irida.ria.integration.pages.projects.ProjectDeletePage; @@ -30,6 +31,8 @@ public class ProjectSampleMetadataImportPageIT extends AbstractIridaUIITChromeDr private static final String EMPTY_AND_DUPLICATE_HEADERS_FILE_PATH = "src/test/resources/files/metadata-upload/empty_and_duplicate_headers.xlsx"; private static final String DUPLICATE_HEADERS_FILE_PATH = "src/test/resources/files/metadata-upload/duplicate_headers.xlsx"; private static final String SAMPLE_NAME_COLUMN = "NLEP #"; + + private static final String SAMPLE_NAME = "sample1"; private static final Long PROJECT_ID = 1L; @BeforeEach @@ -189,4 +192,25 @@ public void testFailedUploadByRemovingPrivileges() { page.clickUploadButton(); assertTrue(page.isErrorNotificationDisplayed(), "Error notification did not display"); } + + @Test + public void testUploadDoesNotOverwriteExistingSampleMetadata() { + ProjectSampleMetadataImportPage page = ProjectSampleMetadataImportPage.goToPage(driver()); + page.uploadMetadataFile(GOOD_FILE_PATH); + page.selectSampleNameColumn(SAMPLE_NAME_COLUMN); + page.goToReviewPage(); + page.goToCompletePage(); + assertTrue(page.isSuccessDisplayed(), "Successful upload did not happen"); + ProjectSamplesPage samplePage = ProjectSamplesPage.goToPage(driver(), PROJECT_ID); + samplePage.clickSampleName(SAMPLE_NAME); + SampleDetailsViewer sampleDetailsViewer = SampleDetailsViewer.getSampleDetails(driver()); + sampleDetailsViewer.clickMetadataTabLink(); + assertTrue(sampleDetailsViewer.addNewMetadataButtonVisible()); + sampleDetailsViewer.getNumberOfMetadataEntries(); + assertEquals(10, sampleDetailsViewer.getNumberOfMetadataEntries(), + "Should have the proper number of metadata entries"); + assertEquals("Sneezing", sampleDetailsViewer.getValueForMetadataField("symptom"), + "Should have existing metadata"); + assertEquals("AB", sampleDetailsViewer.getValueForMetadataField("Province"), "Should have uploaded metadata"); + } } diff --git a/src/test/java/ca/corefacility/bioinformatics/irida/ria/unit/web/services/UIProjectSampleServiceTest.java b/src/test/java/ca/corefacility/bioinformatics/irida/ria/unit/web/services/UIProjectSampleServiceTest.java index 5bd55551bfa..59ecbf34bc3 100644 --- a/src/test/java/ca/corefacility/bioinformatics/irida/ria/unit/web/services/UIProjectSampleServiceTest.java +++ b/src/test/java/ca/corefacility/bioinformatics/irida/ria/unit/web/services/UIProjectSampleServiceTest.java @@ -25,11 +25,17 @@ import static org.junit.jupiter.api.Assertions.assertEquals; import static org.mockito.ArgumentMatchers.any; -import static org.mockito.Mockito.mock; -import static org.mockito.Mockito.when; +import static org.mockito.Mockito.*; public class UIProjectSampleServiceTest { private UIProjectSampleService service; + private ProjectService projectService; + private SampleService sampleService; + private MetadataTemplateService metadataTemplateService; + private MessageSource messageSource; + + private Sample sample; + private Join join; // DATA private final Long PROJECT_1_ID = 1L; @@ -44,10 +50,10 @@ public class UIProjectSampleServiceTest { @BeforeEach public void setUp() { - ProjectService projectService = mock(ProjectService.class); - SampleService sampleService = mock(SampleService.class); - MetadataTemplateService metadataTemplateService = mock(MetadataTemplateService.class); - MessageSource messageSource = mock(MessageSource.class); + projectService = mock(ProjectService.class); + sampleService = mock(SampleService.class); + metadataTemplateService = mock(MetadataTemplateService.class); + messageSource = mock(MessageSource.class); service = new UIProjectSampleService(projectService, sampleService, metadataTemplateService, messageSource); @@ -55,9 +61,9 @@ public void setUp() { when(sampleService.read(SAMPLE_1_ID)).thenReturn(SAMPLE_1); when(sampleService.getSampleBySampleName(PROJECT_1, GOOD_NAME)).thenThrow( new EntityNotFoundException("Sample not found")); - Sample sample = new Sample(GOOD_NAME); + sample = new Sample(GOOD_NAME); sample.setId(SAMPLE_1_ID); - Join join = new ProjectSampleJoin(PROJECT_1, sample, true); + join = new ProjectSampleJoin(PROJECT_1, sample, true); when(projectService.addSampleToProject(any(Project.class), any(Sample.class), any(Boolean.class))).thenReturn( join); when(projectService.addSampleToProjectWithoutEvent(any(Project.class), any(Sample.class), @@ -135,6 +141,7 @@ public void testCreateSampleWithMetadata() { .stream() .filter(response -> ((SampleResponse) response.getValue()).isError()) .count(); + verify(sampleService, times(1)).mergeSampleMetadata(any(), any()); assertEquals(0, errorCount, "Sample should be created"); } @@ -149,6 +156,8 @@ public void testUpdateSampleWithMetadata() { .stream() .filter(response -> ((SampleErrorResponse) response.getValue()).isError()) .count(); + verify(sampleService, times(1)).mergeSampleMetadata(any(), any()); assertEquals(0, errorCount, "Sample should be updated"); } + } diff --git a/src/test/resources/ca/corefacility/bioinformatics/irida/ria/web/projects/ProjectSampleMetadataView.xml b/src/test/resources/ca/corefacility/bioinformatics/irida/ria/web/projects/ProjectSampleMetadataView.xml index 5d0b1793e12..354db607fce 100644 --- a/src/test/resources/ca/corefacility/bioinformatics/irida/ria/web/projects/ProjectSampleMetadataView.xml +++ b/src/test/resources/ca/corefacility/bioinformatics/irida/ria/web/projects/ProjectSampleMetadataView.xml @@ -33,45 +33,16 @@ - - - - - - - - - - - - - - - - + + + + - - - - - - - - - - - - - - - - -