@Test public void testCreateDataSetWithNoSample() { IExternalDataDAO externalDataDAO = daoFactory.getExternalDataDAO(); String dataSetCode = daoFactory.getPermIdDAO().createPermId(); ExternalDataPE externalData = createExternalData(dataSetCode, null); externalDataDAO.createDataSet(externalData); ExternalDataPE dataSet = (ExternalDataPE) externalDataDAO.tryToFindDataSetByCode(dataSetCode); assertDataEqual(externalData, dataSet); }
@Test public void testCreateDataSetFailWithBothSampleAndParent() { final IExternalDataDAO externalDataDAO = daoFactory.getExternalDataDAO(); // try to create a dataset connected with a sample and a parent at the same time final String dataSetCode = daoFactory.getPermIdDAO().createPermId(); final SamplePE sample = pickASample(); ExternalDataPE parentData = findExternalData(PARENT_CODE); ExternalDataPE externalData = createExternalData(dataSetCode, sample); externalData.addParent(parentData); externalDataDAO.createDataSet(externalData); assertCommitFailsWithBothSampleAndParentConnectionForDataSet(dataSetCode); }
@Test public void testUpdateDataSetAquiredFromSample() { IExternalDataDAO externalDataDAO = daoFactory.getExternalDataDAO(); DataPE data = new DataPE(); String dataSetCode = daoFactory.getPermIdDAO().createPermId(); data.setCode(dataSetCode); data.setDataSetType(getDataSetType(DataSetTypeCode.UNKNOWN)); data.setExperiment(pickAnExperiment()); data.setSampleAcquiredFrom(pickASample()); data.setPlaceholder(true); data.setDataStore(pickADataStore()); data.setModificationDate(new Date()); externalDataDAO.createDataSet(data); ExternalDataPE externalData = new ExternalDataPE(); externalData.setId(externalDataDAO.tryToFindDataSetByCode(dataSetCode).getId()); externalData.setCode(dataSetCode); externalData.setDataSetType(getDataSetType(DataSetTypeCode.UNKNOWN)); externalData.setDataStore(pickADataStore()); externalData.setExperiment(pickAnExperiment()); externalData.setSampleAcquiredFrom(pickASample()); externalData.setFileFormatType(pickAFileFormatType()); externalData.setLocatorType(pickALocatorType()); externalData.setLocation("abcd"); externalData.setComplete(BooleanOrUnknown.U); externalData.setStorageFormatVocabularyTerm(pickAStorageFormatVocabularyTerm()); externalData.setPlaceholder(true); final Date modificationTimestamp = data.getModificationDate(); externalData.setModificationDate(modificationTimestamp); externalDataDAO.updateDataSet(externalData); ExternalDataPE dataSet = (ExternalDataPE) externalDataDAO.tryToFindDataSetByCode(dataSetCode); assertEquals(externalData.getCode(), dataSet.getCode()); assertEquals(externalData.getDataSetType(), dataSet.getDataSetType()); assertEquals(externalData.getExperiment(), dataSet.getExperiment()); assertEquals(externalData.getFileFormatType(), dataSet.getFileFormatType()); assertEquals(externalData.getLocatorType(), dataSet.getLocatorType()); assertEquals(externalData.getLocation(), dataSet.getLocation()); assertEquals(externalData.getComplete(), dataSet.getComplete()); assertEquals(externalData.getStorageFormat(), dataSet.getStorageFormat()); assertEquals(externalData.isPlaceholder(), dataSet.isPlaceholder()); assertEquals(externalData.isMeasured(), dataSet.isMeasured()); assertFalse(externalData.getModificationDate().equals(modificationTimestamp)); }