Commit 4a52ffab authored by Matija Obreza's avatar Matija Obreza

Dataset: Updates for new version

parent 507811fc
...@@ -104,6 +104,7 @@ import com.querydsl.core.types.dsl.PathBuilder; ...@@ -104,6 +104,7 @@ import com.querydsl.core.types.dsl.PathBuilder;
import com.querydsl.core.types.dsl.PathBuilderFactory; import com.querydsl.core.types.dsl.PathBuilderFactory;
import com.querydsl.jpa.JPAExpressions; import com.querydsl.jpa.JPAExpressions;
import com.querydsl.jpa.JPQLQuery; import com.querydsl.jpa.JPQLQuery;
import com.vdurmont.semver4j.SemverException;
/** /**
* The Class DatasetServiceImpl. * The Class DatasetServiceImpl.
...@@ -242,7 +243,7 @@ public class DatasetServiceImpl implements DatasetService { ...@@ -242,7 +243,7 @@ public class DatasetServiceImpl implements DatasetService {
@PreAuthorize("hasRole('ADMINISTRATOR') or hasPermission(#dataset, 'write')") @PreAuthorize("hasRole('ADMINISTRATOR') or hasPermission(#dataset, 'write')")
public Dataset setAccessionRefs(Dataset dataset, @Valid final Set<AccessionRef> accessionRefs) { public Dataset setAccessionRefs(Dataset dataset, @Valid final Set<AccessionRef> accessionRefs) {
LOG.info("Update AccessionIdentifiers. Input dataset: {}, input accessionRefs {}", dataset, accessionRefs); LOG.info("Update AccessionIdentifiers. Input dataset: {}, input accessionRefs {}", dataset, accessionRefs);
dataset = reloadFromDatabase(dataset); dataset = getDataset(dataset);
if (dataset.isPublished()) { if (dataset.isPublished()) {
throw new InvalidApiUsageException("Cannot modify a published Dataset."); throw new InvalidApiUsageException("Cannot modify a published Dataset.");
} }
...@@ -260,7 +261,7 @@ public class DatasetServiceImpl implements DatasetService { ...@@ -260,7 +261,7 @@ public class DatasetServiceImpl implements DatasetService {
@PreAuthorize("hasRole('ADMINISTRATOR') or hasPermission(#dataset, 'write')") @PreAuthorize("hasRole('ADMINISTRATOR') or hasPermission(#dataset, 'write')")
public Dataset addDescriptors(Dataset dataset, final Descriptor... descriptors) { public Dataset addDescriptors(Dataset dataset, final Descriptor... descriptors) {
LOG.info("Add descriptor to Dataset {}. Input descriptors {}", dataset, descriptors); LOG.info("Add descriptor to Dataset {}. Input descriptors {}", dataset, descriptors);
dataset = reloadFromDatabase(dataset); dataset = getDataset(dataset);
if (dataset.isPublished()) { if (dataset.isPublished()) {
throw new InvalidApiUsageException("Cannot modify a published Dataset."); throw new InvalidApiUsageException("Cannot modify a published Dataset.");
} }
...@@ -291,7 +292,7 @@ public class DatasetServiceImpl implements DatasetService { ...@@ -291,7 +292,7 @@ public class DatasetServiceImpl implements DatasetService {
@PreAuthorize("hasRole('ADMINISTRATOR') or hasPermission(#dataset, 'write')") @PreAuthorize("hasRole('ADMINISTRATOR') or hasPermission(#dataset, 'write')")
public Dataset removeDescriptors(Dataset dataset, final Descriptor... descriptors) { public Dataset removeDescriptors(Dataset dataset, final Descriptor... descriptors) {
LOG.info("Remove descriptors {} of dataset {}.", descriptors, dataset); LOG.info("Remove descriptors {} of dataset {}.", descriptors, dataset);
dataset = reloadFromDatabase(dataset); dataset = getDataset(dataset);
if (dataset.isPublished()) { if (dataset.isPublished()) {
throw new InvalidApiUsageException("Cannot modify a published Dataset."); throw new InvalidApiUsageException("Cannot modify a published Dataset.");
} }
...@@ -313,7 +314,7 @@ public class DatasetServiceImpl implements DatasetService { ...@@ -313,7 +314,7 @@ public class DatasetServiceImpl implements DatasetService {
@PreAuthorize("hasRole('ADMINISTRATOR') or hasPermission(#dataset, 'write')") @PreAuthorize("hasRole('ADMINISTRATOR') or hasPermission(#dataset, 'write')")
public Dataset updateDescriptors(Dataset dataset, final List<Descriptor> descriptors) { public Dataset updateDescriptors(Dataset dataset, final List<Descriptor> descriptors) {
LOG.info("Update descriptors for Dataset {}. Input descriptors {}", dataset, descriptors); LOG.info("Update descriptors for Dataset {}. Input descriptors {}", dataset, descriptors);
dataset = reloadFromDatabase(dataset); dataset = getDataset(dataset);
if (dataset.isPublished()) { if (dataset.isPublished()) {
throw new InvalidApiUsageException("Cannot modify a published Dataset."); throw new InvalidApiUsageException("Cannot modify a published Dataset.");
} }
...@@ -366,11 +367,15 @@ public class DatasetServiceImpl implements DatasetService { ...@@ -366,11 +367,15 @@ public class DatasetServiceImpl implements DatasetService {
@Transactional @Transactional
@PreAuthorize("(hasRole('ADMINISTRATOR') || hasPermission(#source, 'write')) && #source.published") @PreAuthorize("(hasRole('ADMINISTRATOR') || hasPermission(#source, 'write')) && #source.published")
public Dataset createNewVersion(@Valid Dataset source) { public Dataset createNewVersion(@Valid Dataset source) {
source = reloadFromDatabase(source); source = getDataset(source);
final Dataset dataset = new Dataset(); final Dataset dataset = new Dataset();
copyValues(dataset, source); copyValues(dataset, source);
dataset.setVersionTag(versionManager.nextMajor(source.getVersionTag())); try {
dataset.setVersionTag(versionManager.nextMajor(source.getVersionTag()));
} catch (SemverException e) {
dataset.setVersionTag(source.getVersionTag() + ".1");
}
dataset.setState(PublishState.DRAFT); dataset.setState(PublishState.DRAFT);
dataset.setCurrent(null); dataset.setCurrent(null);
dataset.setUuid(null); dataset.setUuid(null);
...@@ -380,10 +385,10 @@ public class DatasetServiceImpl implements DatasetService { ...@@ -380,10 +385,10 @@ public class DatasetServiceImpl implements DatasetService {
dataset.setDescriptors(new ArrayList<>()); dataset.setDescriptors(new ArrayList<>());
copyDescriptors(dataset, source.getDescriptors()); copyDescriptors(dataset, source.getDescriptors());
final Dataset saved = datasetRepository.save(dataset); Dataset saved = datasetRepository.save(dataset);
// copy accessionRefs // copy accessionRefs
copyAccessionRefs(saved, source.getAccessionRefs()); saved = copyAccessionRefs(saved, source.getAccessionRefs());
// Copy creators // Copy creators
copyCreators(saved, source.getCreators()); copyCreators(saved, source.getCreators());
...@@ -407,13 +412,14 @@ public class DatasetServiceImpl implements DatasetService { ...@@ -407,13 +412,14 @@ public class DatasetServiceImpl implements DatasetService {
* *
* @param target the target * @param target the target
* @param accessionRefs the dataset accessionRefs * @param accessionRefs the dataset accessionRefs
* @return
*/ */
private void copyAccessionRefs(final Dataset target, final List<DatasetAccessionRef> accessionRefs) { private Dataset copyAccessionRefs(final Dataset target, final List<DatasetAccessionRef> accessionRefs) {
if (accessionRefs == null || accessionRefs.size() == 0) { if (accessionRefs == null || accessionRefs.size() == 0) {
return; return target;
} }
Dataset loadedDataset = reloadFromDatabase(target); Dataset loadedDataset = getDataset(target);
List<DatasetAccessionRef> copiedAccessionRefs = Lists.newArrayList(); List<DatasetAccessionRef> copiedAccessionRefs = Lists.newArrayList();
accessionRefs.forEach(dAccessionRef -> { accessionRefs.forEach(dAccessionRef -> {
DatasetAccessionRef copy = new DatasetAccessionRef(); DatasetAccessionRef copy = new DatasetAccessionRef();
...@@ -425,7 +431,7 @@ public class DatasetServiceImpl implements DatasetService { ...@@ -425,7 +431,7 @@ public class DatasetServiceImpl implements DatasetService {
loadedDataset.setAccessionCount((int) accessionRefRepository.countByDataset(loadedDataset)); loadedDataset.setAccessionCount((int) accessionRefRepository.countByDataset(loadedDataset));
LOG.info("Done saving {} accession refs, have {} in dataset", accessionRefs.size(), loadedDataset.getAccessionCount()); LOG.info("Done saving {} accession refs, have {} in dataset", accessionRefs.size(), loadedDataset.getAccessionCount());
datasetRepository.save(loadedDataset); return datasetRepository.save(loadedDataset);
} }
/** /**
...@@ -498,11 +504,11 @@ public class DatasetServiceImpl implements DatasetService { ...@@ -498,11 +504,11 @@ public class DatasetServiceImpl implements DatasetService {
@Override @Override
@PostAuthorize("hasRole('ADMINISTRATOR') || returnObject==null || returnObject.isPublished() || hasPermission(returnObject, 'read')") @PostAuthorize("hasRole('ADMINISTRATOR') || returnObject==null || returnObject.isPublished() || hasPermission(returnObject, 'read')")
public Dataset loadDataset(final Dataset input) { public Dataset loadDataset(final Dataset input) {
final Dataset dataset = reloadFromDatabase(input); final Dataset dataset = getDataset(input);
return lazyLoad(dataset); return lazyLoad(dataset);
} }
private Dataset reloadFromDatabase(final Dataset input) { private Dataset getDataset(final Dataset input) {
LOG.debug("Load Dataset. Input data {}", input); LOG.debug("Load Dataset. Input data {}", input);
final Dataset dataset = datasetRepository.findOne(input.getId()); final Dataset dataset = datasetRepository.findOne(input.getId());
...@@ -589,7 +595,7 @@ public class DatasetServiceImpl implements DatasetService { ...@@ -589,7 +595,7 @@ public class DatasetServiceImpl implements DatasetService {
@Override @Override
@PreAuthorize("hasRole('ADMINISTRATOR') || #dataset.published || hasPermission(#dataset, 'read')") @PreAuthorize("hasRole('ADMINISTRATOR') || #dataset.published || hasPermission(#dataset, 'read')")
public Page<? extends AccessionRef> listAccessions(Dataset dataset, final Pageable page) { public Page<? extends AccessionRef> listAccessions(Dataset dataset, final Pageable page) {
dataset = reloadFromDatabase(dataset); dataset = getDataset(dataset);
return accessionRefRepository.findAll(dataset, page); return accessionRefRepository.findAll(dataset, page);
} }
...@@ -719,7 +725,7 @@ public class DatasetServiceImpl implements DatasetService { ...@@ -719,7 +725,7 @@ public class DatasetServiceImpl implements DatasetService {
@Override @Override
@PreAuthorize("hasRole('ADMINISTRATOR') or hasPermission(#dataset, 'delete')") @PreAuthorize("hasRole('ADMINISTRATOR') or hasPermission(#dataset, 'delete')")
public Dataset removeDataset(final Dataset dataset) { public Dataset removeDataset(final Dataset dataset) {
final Dataset loadedDataset = reloadFromDatabase(dataset); final Dataset loadedDataset = getDataset(dataset);
for (RepositoryFile repositoryFile : loadedDataset.getRepositoryFiles()) { for (RepositoryFile repositoryFile : loadedDataset.getRepositoryFiles()) {
try { try {
...@@ -747,7 +753,7 @@ public class DatasetServiceImpl implements DatasetService { ...@@ -747,7 +753,7 @@ public class DatasetServiceImpl implements DatasetService {
@Override @Override
@PreAuthorize("hasRole('ADMINISTRATOR') or hasPermission(#dataset, 'write')") @PreAuthorize("hasRole('ADMINISTRATOR') or hasPermission(#dataset, 'write')")
public Dataset addAccessionRefs(final Dataset dataset, @Valid final Set<AccessionRef> accessionRefs) throws NotFoundElement { public Dataset addAccessionRefs(final Dataset dataset, @Valid final Set<AccessionRef> accessionRefs) throws NotFoundElement {
final Dataset loadedDataset = reloadFromDatabase(dataset); final Dataset loadedDataset = getDataset(dataset);
if (loadedDataset == null) { if (loadedDataset == null) {
throw new NotFoundElement("Dataset doesn't exist"); throw new NotFoundElement("Dataset doesn't exist");
} }
...@@ -779,7 +785,7 @@ public class DatasetServiceImpl implements DatasetService { ...@@ -779,7 +785,7 @@ public class DatasetServiceImpl implements DatasetService {
@Transactional @Transactional
@PreAuthorize("hasRole('ADMINISTRATOR')") @PreAuthorize("hasRole('ADMINISTRATOR')")
public Dataset approveDataset(final Dataset dataset) { public Dataset approveDataset(final Dataset dataset) {
Dataset loaded = reloadFromDatabase(dataset); Dataset loaded = getDataset(dataset);
if (loaded == null) { if (loaded == null) {
throw new NotFoundElement("No dataset with specified uuid and version"); throw new NotFoundElement("No dataset with specified uuid and version");
} }
...@@ -858,7 +864,7 @@ public class DatasetServiceImpl implements DatasetService { ...@@ -858,7 +864,7 @@ public class DatasetServiceImpl implements DatasetService {
@Transactional @Transactional
@PreAuthorize("hasRole('ADMINISTRATOR') or hasPermission(#dataset, 'write')") @PreAuthorize("hasRole('ADMINISTRATOR') or hasPermission(#dataset, 'write')")
public Dataset reviewDataset(final Dataset dataset) { public Dataset reviewDataset(final Dataset dataset) {
final Dataset loaded = reloadFromDatabase(dataset); final Dataset loaded = getDataset(dataset);
if (loaded == null) { if (loaded == null) {
throw new NotFoundElement("No dataset with specified uuid and version"); throw new NotFoundElement("No dataset with specified uuid and version");
} }
...@@ -892,7 +898,7 @@ public class DatasetServiceImpl implements DatasetService { ...@@ -892,7 +898,7 @@ public class DatasetServiceImpl implements DatasetService {
@Transactional @Transactional
@PreAuthorize("hasRole('ADMINISTRATOR') or hasPermission(#dataset, 'administration')") @PreAuthorize("hasRole('ADMINISTRATOR') or hasPermission(#dataset, 'administration')")
public Dataset rejectDataset(final Dataset dataset) { public Dataset rejectDataset(final Dataset dataset) {
Dataset loaded = reloadFromDatabase(dataset); Dataset loaded = getDataset(dataset);
if (loaded == null) { if (loaded == null) {
throw new NotFoundElement("No dataset with specified uuid and version"); throw new NotFoundElement("No dataset with specified uuid and version");
} }
...@@ -957,7 +963,7 @@ public class DatasetServiceImpl implements DatasetService { ...@@ -957,7 +963,7 @@ public class DatasetServiceImpl implements DatasetService {
@Override @Override
@PreAuthorize("hasRole('ADMINISTRATOR') or hasPermission(#dataset, 'write')") @PreAuthorize("hasRole('ADMINISTRATOR') or hasPermission(#dataset, 'write')")
public DatasetCreator createDatasetCreator(Dataset dataset, @Valid final DatasetCreator input) throws NotFoundElement { public DatasetCreator createDatasetCreator(Dataset dataset, @Valid final DatasetCreator input) throws NotFoundElement {
dataset = reloadFromDatabase(dataset); dataset = getDataset(dataset);
input.setDataset(dataset); input.setDataset(dataset);
return datasetCreatorRepository.save(input); return datasetCreatorRepository.save(input);
} }
...@@ -1021,7 +1027,7 @@ public class DatasetServiceImpl implements DatasetService { ...@@ -1021,7 +1027,7 @@ public class DatasetServiceImpl implements DatasetService {
*/ */
@Override @Override
public List<DatasetCreator> loadDatasetCreators(Dataset dataset) throws NotFoundElement { public List<DatasetCreator> loadDatasetCreators(Dataset dataset) throws NotFoundElement {
dataset = reloadFromDatabase(dataset); dataset = getDataset(dataset);
return dataset.getCreators(); return dataset.getCreators();
} }
...@@ -1254,7 +1260,7 @@ public class DatasetServiceImpl implements DatasetService { ...@@ -1254,7 +1260,7 @@ public class DatasetServiceImpl implements DatasetService {
@Override @Override
public List<DatasetLocation> listLocation(Dataset dataset) throws NotFoundElement { public List<DatasetLocation> listLocation(Dataset dataset) throws NotFoundElement {
LOG.info("Load list DatasetLocation for dataset {}", dataset.getUuid()); LOG.info("Load list DatasetLocation for dataset {}", dataset.getUuid());
dataset = reloadFromDatabase(dataset); dataset = getDataset(dataset);
dataset.getLocations().size(); dataset.getLocations().size();
return dataset.getLocations(); return dataset.getLocations();
} }
...@@ -1308,7 +1314,7 @@ public class DatasetServiceImpl implements DatasetService { ...@@ -1308,7 +1314,7 @@ public class DatasetServiceImpl implements DatasetService {
@Transactional @Transactional
@PreAuthorize("hasRole('ADMINISTRATOR') or hasPermission(#dataset, 'write')") @PreAuthorize("hasRole('ADMINISTRATOR') or hasPermission(#dataset, 'write')")
public DatasetLocation updateLocation(Dataset dataset, @Valid final DatasetLocation input) throws NotFoundElement { public DatasetLocation updateLocation(Dataset dataset, @Valid final DatasetLocation input) throws NotFoundElement {
dataset = reloadFromDatabase(dataset); dataset = getDataset(dataset);
final DatasetLocation datasetLocation = loadLocation(input); final DatasetLocation datasetLocation = loadLocation(input);
if (!datasetLocation.getDataset().getUuid().equals(dataset.getUuid())) { if (!datasetLocation.getDataset().getUuid().equals(dataset.getUuid())) {
throw new InvalidApiUsageException("Location does not belong to dataset"); throw new InvalidApiUsageException("Location does not belong to dataset");
......
...@@ -33,7 +33,6 @@ import org.genesys.blocks.model.JsonViews; ...@@ -33,7 +33,6 @@ import org.genesys.blocks.model.JsonViews;
import org.genesys.blocks.model.SelfCleaning; import org.genesys.blocks.model.SelfCleaning;
import org.genesys2.server.model.impl.AccessionIdentifier3; import org.genesys2.server.model.impl.AccessionIdentifier3;
import com.fasterxml.jackson.annotation.JsonIgnore;
import com.fasterxml.jackson.annotation.JsonView; import com.fasterxml.jackson.annotation.JsonView;
/** /**
...@@ -86,10 +85,6 @@ public class AccessionRef implements SelfCleaning, AccessionIdentifier3, Seriali ...@@ -86,10 +85,6 @@ public class AccessionRef implements SelfCleaning, AccessionIdentifier3, Seriali
@JoinColumn(name = "accessionId", nullable = true) @JoinColumn(name = "accessionId", nullable = true)
@JsonView({ JsonViews.Public.class }) @JsonView({ JsonViews.Public.class })
protected Accession accession; protected Accession accession;
@Transient
@JsonIgnore
private boolean stored;
public AccessionRef() { public AccessionRef() {
} }
...@@ -321,15 +316,6 @@ public class AccessionRef implements SelfCleaning, AccessionIdentifier3, Seriali ...@@ -321,15 +316,6 @@ public class AccessionRef implements SelfCleaning, AccessionIdentifier3, Seriali
return true; return true;
} }
@Transient
public boolean isStored() {
return stored;
}
public void setStored(boolean stored) {
this.stored = stored;
}
@Override @Override
public String toString() { public String toString() {
return "AccessionRef " + instCode + " " + acceNumb + " " + genus; return "AccessionRef " + instCode + " " + acceNumb + " " + genus;
......
...@@ -747,10 +747,11 @@ public class SubsetServiceImpl implements SubsetService { ...@@ -747,10 +747,11 @@ public class SubsetServiceImpl implements SubsetService {
* *
* @param target the target * @param target the target
* @param accessionRefs the subset accessionRefs * @param accessionRefs the subset accessionRefs
* @return
*/ */
private void copyAccessionRefs(final Subset target, final List<SubsetAccessionRef> accessionRefs) { private Subset copyAccessionRefs(final Subset target, final List<SubsetAccessionRef> accessionRefs) {
if (accessionRefs == null || accessionRefs.size() == 0) { if (accessionRefs == null || accessionRefs.size() == 0) {
return; return target;
} }
final Subset loadedSubset = getSubset(target); final Subset loadedSubset = getSubset(target);
...@@ -765,7 +766,7 @@ public class SubsetServiceImpl implements SubsetService { ...@@ -765,7 +766,7 @@ public class SubsetServiceImpl implements SubsetService {
loadedSubset.setAccessionCount((int) accessionRefRepository.countBySubset(loadedSubset)); loadedSubset.setAccessionCount((int) accessionRefRepository.countBySubset(loadedSubset));
LOG.info("Done saving {} accession refs, have {} in subset", accessionRefs.size(), loadedSubset.getAccessionCount()); LOG.info("Done saving {} accession refs, have {} in subset", accessionRefs.size(), loadedSubset.getAccessionCount());
subsetRepository.save(loadedSubset); return subsetRepository.save(loadedSubset);
} }
/** /**
......
...@@ -156,7 +156,7 @@ public class DatasetServiceTest extends AbstractDatasetServiceTest { ...@@ -156,7 +156,7 @@ public class DatasetServiceTest extends AbstractDatasetServiceTest {
} }
@Test @Test
public void testLookupAccessionsForAccessionIdentifiersInDataset() { public void testLookupAccessionsForAccessionIdentifiersInDataset() throws InterruptedException {
final Accession accession = upsertAccession(TEST_INSTCODE, "TestAccNum", "TestGen"); final Accession accession = upsertAccession(TEST_INSTCODE, "TestAccNum", "TestGen");
Dataset input = buildDataset(DATASET_TITLE_1, DATASET_DESCRIPTION_1, partner, PublishState.DRAFT); Dataset input = buildDataset(DATASET_TITLE_1, DATASET_DESCRIPTION_1, partner, PublishState.DRAFT);
...@@ -168,6 +168,8 @@ public class DatasetServiceTest extends AbstractDatasetServiceTest { ...@@ -168,6 +168,8 @@ public class DatasetServiceTest extends AbstractDatasetServiceTest {
assertThat(input, not(nullValue())); assertThat(input, not(nullValue()));
assertThat(input.getAccessionCount(), is(1)); assertThat(input.getAccessionCount(), is(1));
datasetService.rematchDatasetAccessions(input); datasetService.rematchDatasetAccessions(input);
Thread.sleep(2000);
final AccessionRef datasetAccessionRef = datasetService.listAccessions(input, new PageRequest(0, 10)).getContent().get(0); final AccessionRef datasetAccessionRef = datasetService.listAccessions(input, new PageRequest(0, 10)).getContent().get(0);
assertThat(datasetAccessionRef, notNullValue()); assertThat(datasetAccessionRef, notNullValue());
...@@ -176,7 +178,7 @@ public class DatasetServiceTest extends AbstractDatasetServiceTest { ...@@ -176,7 +178,7 @@ public class DatasetServiceTest extends AbstractDatasetServiceTest {
} }
@Test @Test
public void testCreateAndUpdateAccessionsInDataset() { public void testCreateAndUpdateAccessionsInDataset() throws InterruptedException {
final Accession accession1 = upsertAccession(TEST_INSTCODE, TEST_ACCNUM, TEST_GEN); final Accession accession1 = upsertAccession(TEST_INSTCODE, TEST_ACCNUM, TEST_GEN);
final Accession accession2 = upsertAccession(TEST_INSTCODE2, TEST_ACCNUM2, TEST_GEN2); final Accession accession2 = upsertAccession(TEST_INSTCODE2, TEST_ACCNUM2, TEST_GEN2);
final Accession accession3 = upsertAccession(TEST_INSTCODE3, TEST_ACCNUM3, TEST_GEN3); final Accession accession3 = upsertAccession(TEST_INSTCODE3, TEST_ACCNUM3, TEST_GEN3);
...@@ -192,6 +194,8 @@ public class DatasetServiceTest extends AbstractDatasetServiceTest { ...@@ -192,6 +194,8 @@ public class DatasetServiceTest extends AbstractDatasetServiceTest {
assertThat(input.getAccessionCount(), is(3)); assertThat(input.getAccessionCount(), is(3));
assertThat(input.getAccessionCount(), is(datasetAccessionRefs.size())); assertThat(input.getAccessionCount(), is(datasetAccessionRefs.size()));
datasetService.rematchDatasetAccessions(input); datasetService.rematchDatasetAccessions(input);
Thread.sleep(5500);
datasetService.listAccessions(input, new PageRequest(0, 10)).forEach(aid -> { datasetService.listAccessions(input, new PageRequest(0, 10)).forEach(aid -> {
assertThat(aid.getAccession(), notNullValue()); assertThat(aid.getAccession(), notNullValue());
...@@ -845,6 +849,8 @@ public class DatasetServiceTest extends AbstractDatasetServiceTest { ...@@ -845,6 +849,8 @@ public class DatasetServiceTest extends AbstractDatasetServiceTest {
datasetService.rematchDatasetAccessions(dataset1); datasetService.rematchDatasetAccessions(dataset1);
datasetService.rematchDatasetAccessions(dataset2); datasetService.rematchDatasetAccessions(dataset2);
Thread.sleep(5500);
List<Dataset> datasets1 = datasetService.listByAccession(accession1); List<Dataset> datasets1 = datasetService.listByAccession(accession1);
assertThat(datasets1, not(nullValue())); assertThat(datasets1, not(nullValue()));
assertThat(datasetRepository.count(), is(2l)); assertThat(datasetRepository.count(), is(2l));
...@@ -854,7 +860,7 @@ public class DatasetServiceTest extends AbstractDatasetServiceTest { ...@@ -854,7 +860,7 @@ public class DatasetServiceTest extends AbstractDatasetServiceTest {
final Accession accession2 = upsertAccession(TEST_INSTCODE, "A8", "Musa"); final Accession accession2 = upsertAccession(TEST_INSTCODE, "A8", "Musa");
datasetService.rematchDatasetAccessions(dataset1); datasetService.rematchDatasetAccessions(dataset1);
Thread.sleep(5000); Thread.sleep(5500);
datasets1 = datasetService.listByAccession(accession2); datasets1 = datasetService.listByAccession(accession2);
assertThat(datasets1.size(), is(1)); assertThat(datasets1.size(), is(1));
......
...@@ -16,10 +16,7 @@ ...@@ -16,10 +16,7 @@
package org.genesys.test.server.api.v1; package org.genesys.test.server.api.v1;
import static org.hamcrest.Matchers.*; import static org.hamcrest.Matchers.*;
import static org.junit.Assert.assertEquals; import static org.junit.Assert.*;
import static org.junit.Assert.assertNull;
import static org.junit.Assert.assertThat;
import static org.junit.Assert.assertTrue;
import static org.springframework.restdocs.mockmvc.MockMvcRestDocumentation.document; import static org.springframework.restdocs.mockmvc.MockMvcRestDocumentation.document;
import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.*; import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.*;
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.*; import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.*;
...@@ -46,13 +43,14 @@ import org.springframework.data.domain.PageRequest; ...@@ -46,13 +43,14 @@ import org.springframework.data.domain.PageRequest;
import org.springframework.http.MediaType; import org.springframework.http.MediaType;
import org.springframework.restdocs.mockmvc.RestDocumentationRequestBuilders; import org.springframework.restdocs.mockmvc.RestDocumentationRequestBuilders;
import org.springframework.security.test.context.support.WithMockUser; import org.springframework.security.test.context.support.WithMockUser;
import org.springframework.test.web.servlet.ResultActions;
import com.google.common.collect.Sets; import com.google.common.collect.Sets;
import org.springframework.test.web.servlet.ResultActions;
import org.springframework.test.web.servlet.result.MockMvcResultHandlers;
/** /**
* @author Andrey Lugovskoy. * @author Andrey Lugovskoy
* @author Maxym Borodenko
* @author Matija Obreza
*/ */
public class DatasetControllerTest extends AbstractApiTest { public class DatasetControllerTest extends AbstractApiTest {
...@@ -353,7 +351,7 @@ public class DatasetControllerTest extends AbstractApiTest { ...@@ -353,7 +351,7 @@ public class DatasetControllerTest extends AbstractApiTest {
return mockMvc.perform(post(DatasetController.CONTROLLER_URL.concat("/create-new-version")) return mockMvc.perform(post(DatasetController.CONTROLLER_URL.concat("/create-new-version"))
.param("uuid", dataset.getUuid().toString()) .param("uuid", dataset.getUuid().toString())
.contentType(MediaType.APPLICATION_JSON)) .contentType(MediaType.APPLICATION_JSON))
.andDo(MockMvcResultHandlers.print()) // .andDo(MockMvcResultHandlers.print())
.andExpect(status().isOk()) .andExpect(status().isOk())
.andExpect(content().contentType(MediaType.APPLICATION_JSON_UTF8)); .andExpect(content().contentType(MediaType.APPLICATION_JSON_UTF8));
/*@formatter:on*/ /*@formatter:on*/
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment