Commit 33fb990e authored by Matija Obreza's avatar Matija Obreza

Merge branch '425-versioned-datasets-update' into 'master'

Resolve "Versioned Datasets: update"

Closes #425

See merge request genesys-pgr/genesys-server!376
parents 84694442 4a52ffab
/*
* Copyright 2018 Global Crop Diversity Trust
* Copyright 2019 Global Crop Diversity Trust
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
......@@ -17,6 +17,7 @@ package org.genesys.catalog.model.dataset;
import java.util.List;
import java.util.Set;
import java.util.UUID;
import javax.persistence.Cacheable;
import javax.persistence.CascadeType;
......@@ -35,12 +36,16 @@ import javax.persistence.ManyToMany;
import javax.persistence.ManyToOne;
import javax.persistence.OneToMany;
import javax.persistence.OrderColumn;
import javax.persistence.PostLoad;
import javax.persistence.PrePersist;
import javax.persistence.PreUpdate;
import javax.persistence.Table;
import javax.persistence.Transient;
import javax.persistence.UniqueConstraint;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Size;
import com.fasterxml.jackson.annotation.JsonGetter;
import org.genesys.blocks.auditlog.annotations.Audited;
import org.genesys.blocks.model.JsonViews;
import org.genesys.blocks.model.Publishable;
......@@ -66,10 +71,10 @@ import com.fasterxml.jackson.annotation.JsonView;
*
* @author Matija Obreza
* @author Andrey Lugovskoy
* @author Maxim Borodenko
* @author Maxym Borodenko
*/
@Entity
@Table(name = "dataset")
@Table(name = "dataset", uniqueConstraints = @UniqueConstraint(name = "UQ_current_dataset_version", columnNames={"versionsId", "current"}))
@Cacheable
@Audited
@Document(indexName = "dataset")
......@@ -79,11 +84,13 @@ public class Dataset extends UuidModel implements Publishable, SelfCleaning, Acl
private static final long serialVersionUID = -4601980446454791177L;
/** The versions. */
@ManyToOne(cascade = CascadeType.ALL, optional = false)
@ManyToOne(cascade = { CascadeType.MERGE, CascadeType.REFRESH }, optional = false)
@JoinColumn(name = "versionsId", updatable = false)
@JsonIgnore
private DatasetVersions versions;
private Boolean current;
/** The owner. */
@ManyToOne(cascade = {}, optional = false)
@JoinColumn(name = "partnerId", updatable = false)
......@@ -195,6 +202,16 @@ public class Dataset extends UuidModel implements Publishable, SelfCleaning, Acl
@Enumerated(EnumType.ORDINAL)
private PublishState state = PublishState.DRAFT;
@Transient
private UUID currentVersion;
@PostLoad
protected void postLoad() {
if (this.versions != null && versions.getCurrentVersion() != null && !this.uuid.equals(versions.getCurrentVersion().getUuid())) {
this.currentVersion = versions.getCurrentVersion().getUuid();
}
}
/**
* Preupdate.
*/
......@@ -215,6 +232,43 @@ public class Dataset extends UuidModel implements Publishable, SelfCleaning, Acl
trimStringsToNull();
}
/**
* Gets the current.
*
* @return the current
*/
public Boolean getCurrent() {
return current;
}
/**
* Sets current value
*
* @param current the new value of current
*/
public void setCurrent(final Boolean current) {
this.current = current;
}
/**
* Gets the UUID of current dataset
*
* @return the UUID of current dataset
*/
@JsonGetter
public UUID getCurrentVersion() {
return currentVersion;
}
/**
* Sets the UUID of current dataset
*
* @param currentVersion the UUID of current dataset
*/
public void setCurrentVersion(final UUID currentVersion) {
this.currentVersion = currentVersion;
}
/**
* Owner is the ACL parent object for the dataset
*/
......
......@@ -463,4 +463,12 @@ public interface DatasetService {
*/
void writeXlsxMCPD(Dataset dataset, OutputStream outputStream) throws IOException;
/**
* Method creating a new version of Dataset based on an existing published Dataset.
*
* @param source the source
* @return saved Dataset in db.
*/
Dataset createNewVersion(@Valid Dataset source);
}
......@@ -568,4 +568,16 @@ public class DatasetController extends ApiBaseController {
LOG.warn("Download was aborted: {}", e.getMessage());
}
}
/**
* Create a new version of Dataset based on an existing published Dataset.
*
* @param uuid Dataset UUID
* @return the new version of Dataset
*/
@PostMapping(value = "/create-new-version")
public Dataset createNewVersion(@RequestParam(value = "uuid", required = true) final UUID uuid) {
final Dataset dataset = datasetService.loadDataset(uuid);
return datasetService.createNewVersion(dataset);
}
}
......@@ -33,7 +33,6 @@ import org.genesys.blocks.model.JsonViews;
import org.genesys.blocks.model.SelfCleaning;
import org.genesys2.server.model.impl.AccessionIdentifier3;
import com.fasterxml.jackson.annotation.JsonIgnore;
import com.fasterxml.jackson.annotation.JsonView;
/**
......@@ -86,10 +85,6 @@ public class AccessionRef implements SelfCleaning, AccessionIdentifier3, Seriali
@JoinColumn(name = "accessionId", nullable = true)
@JsonView({ JsonViews.Public.class })
protected Accession accession;
@Transient
@JsonIgnore
private boolean stored;
public AccessionRef() {
}
......@@ -321,15 +316,6 @@ public class AccessionRef implements SelfCleaning, AccessionIdentifier3, Seriali
return true;
}
@Transient
public boolean isStored() {
return stored;
}
public void setStored(boolean stored) {
this.stored = stored;
}
@Override
public String toString() {
return "AccessionRef " + instCode + " " + acceNumb + " " + genus;
......
......@@ -471,19 +471,39 @@ public class Subset extends UuidModel implements AclAwareModel, SelfCleaning {
this.source = source;
}
/**
* Gets the owner.
*
* @return the owner
*/
public Partner getOwner() {
return owner;
}
/**
* Sets the owner.
*
* @param owner the owner
*/
public void setOwner(Partner owner) {
this.owner = owner;
}
/**
* Gets the UUID of current subset
*
* @return the UUID of current subset
*/
@JsonGetter
public UUID getCurrentVersion() {
return currentVersion;
}
/**
* Sets the UUID of current subset
*
* @param currentVersion the UUID of current subset
*/
public void setCurrentVersion(UUID currentVersion) {
this.currentVersion = currentVersion;
}
......
......@@ -726,24 +726,98 @@ public class SubsetServiceImpl implements SubsetService {
subset.setCurrent(null);
subset.setUuid(null);
subset.setVersions(source.getVersions());
Subset saved = lazyLoad(subsetRepository.save(subset));
Subset saved = subsetRepository.save(subset);
// Copy accessionRefs
copyAccessionRefs(saved, source.getAccessionRefs());
// Copy creators
source.getCreators().forEach(creator -> {
entityManager.detach(creator);
creator.setSubset(subset);
creator.setId(null);
creator.setVersion(null);
creator.setUuid(null);
subsetCreatorRepository.save(creator);
});
setAccessionRefs(saved, new HashSet<>(source.getAccessionRefs()));
copyCreators(saved, source.getCreators());
saved.setCurrentVersion(source.getUuid());
// Make Subset publicly not-readable
aclService.makePubliclyReadable(saved, false);
return lazyLoad(saved);
return saved;
}
/**
* Copy and save subset accessionRefs.
*
* @param target the target
* @param accessionRefs the subset accessionRefs
* @return
*/
private Subset copyAccessionRefs(final Subset target, final List<SubsetAccessionRef> accessionRefs) {
if (accessionRefs == null || accessionRefs.size() == 0) {
return target;
}
final Subset loadedSubset = getSubset(target);
List<SubsetAccessionRef> copiedAccessionRefs = Lists.newArrayList();
accessionRefs.forEach(sAccessionRef -> {
SubsetAccessionRef copy = new SubsetAccessionRef();
copyAccessionRef(copy, sAccessionRef);
copy.setSubset(loadedSubset);
copiedAccessionRefs.add(copy);
});
accessionRefRepository.save(copiedAccessionRefs);
loadedSubset.setAccessionCount((int) accessionRefRepository.countBySubset(loadedSubset));
LOG.info("Done saving {} accession refs, have {} in subset", accessionRefs.size(), loadedSubset.getAccessionCount());
return subsetRepository.save(loadedSubset);
}
/**
* Copy and save subset creators.
*
* @param target the target
* @param creators the subset creators
*/
private void copyCreators(final Subset target, final List<SubsetCreator> creators) {
if (creators == null || creators.size() == 0) {
return;
}
List<SubsetCreator> copiedCreators = Lists.newArrayList();
creators.forEach(creator -> {
SubsetCreator copy = new SubsetCreator();
copyCreator(copy, creator);
copy.setSubset(target);
copiedCreators.add(copy);
});
target.setCreators(subsetCreatorRepository.save(copiedCreators));
}
/**
* Copy creator values.
*
* @param target the target
* @param source the source
*/
private void copyCreator(final SubsetCreator target, final SubsetCreator source) {
target.setFullName(source.getFullName());
target.setEmail(source.getEmail());
target.setPhoneNumber(source.getPhoneNumber());
target.setFax(source.getFax());
target.setInstituteAddress(source.getInstituteAddress());
target.setInstitutionalAffiliation(source.getInstitutionalAffiliation());
target.setRole(source.getRole());
}
/**
* Copy subset accessionRef values.
*
* @param target the target
* @param source the source
*/
private void copyAccessionRef(final SubsetAccessionRef target, final SubsetAccessionRef source) {
target.setDoi(source.getDoi());
target.setInstCode(source.getInstCode());
target.setAcceNumb(source.getAcceNumb());
target.setGenus(source.getGenus());
target.setSpecies(source.getSpecies());
target.setAccession(source.getAccession());
}
}
......@@ -5783,3 +5783,28 @@ databaseChangeLog:
- sql:
comment: Organization renamed to PGRFANetwork
sql: update classpk set classname='org.genesys2.server.model.impl.PGRFANetwork', shortName='pgrfanetwork' where classname='org.genesys2.server.model.impl.Organization';
- changeSet:
id: 1552920444624-1
author: mborodenko
comment: Extend dataset table
changes:
- addColumn:
tableName: dataset
columns:
- column:
name: current
type: BIT(1)
defaultValue: null
- sql:
comment: dataset#current should be true if dataset is published
sql: update dataset set current = true where state = 1
- changeSet:
id: 1552920444624-2
author: mborodenko
changes:
- sql:
comment: dataset_version#currentVersion_id must be null if subset is not published
sql: update dataset_version dv inner join dataset d on dv.currentVersion_id = d.id
set dv.currentVersion_id = null where d.state != 1
......@@ -15,23 +15,35 @@
*/
package org.genesys.test.base;
import static org.hamcrest.Matchers.is;
import static org.junit.Assert.assertThat;
import static org.springframework.restdocs.mockmvc.MockMvcRestDocumentation.documentationConfiguration;
import java.util.ArrayList;
import java.util.HashSet;
import java.util.Set;
import java.util.UUID;
import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.databind.DeserializationFeature;
import org.genesys.catalog.model.Partner;
import org.genesys.catalog.model.dataset.Dataset;
import org.genesys.catalog.model.dataset.DatasetCreator;
import org.genesys.catalog.model.traits.Descriptor;
import org.genesys.catalog.persistence.PartnerRepository;
import org.genesys.catalog.persistence.dataset.DatasetAccessionRefRepository;
import org.genesys.catalog.persistence.dataset.DatasetCreatorRepository;
import org.genesys.catalog.persistence.dataset.DatasetRepository;
import org.genesys.catalog.persistence.dataset.DatasetVersionsRepository;
import org.genesys.catalog.persistence.traits.DescriptorRepository;
import org.genesys.catalog.service.DatasetService;
import org.genesys.catalog.service.ShortFilterService;
import org.genesys.filerepository.persistence.RepositoryFilePersistence;
import org.genesys.test.config.ApplicationConfig;
import org.genesys2.server.model.PublishState;
import org.genesys2.server.model.genesys.AccessionRef;
import org.genesys2.server.model.impl.Subset;
import org.genesys2.server.model.impl.SubsetCreator;
import org.genesys2.server.persistence.FaoInstituteRepository;
import org.junit.After;
import org.junit.Before;
......@@ -58,14 +70,25 @@ import com.fasterxml.jackson.databind.ObjectMapper;
public abstract class AbstractApiTest extends AbstractTest {
@Autowired
protected ObjectMapper objectMapper;
protected static final ObjectMapper objectMapper;
protected static final ObjectMapper verboseMapper = new ObjectMapper();
static {
objectMapper = new ObjectMapper();
objectMapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
objectMapper.configure(DeserializationFeature.ACCEPT_SINGLE_VALUE_AS_ARRAY, true);
objectMapper.setSerializationInclusion(JsonInclude.Include.NON_EMPTY);
}
@Autowired
private WebApplicationContext webApplicationContext;
@Autowired
protected DatasetRepository datasetRepository;
@Autowired
protected DatasetVersionsRepository datasetVersionsRepository;
@Autowired
protected DatasetCreatorRepository datasetCreatorRepository;
@Autowired
private PartnerRepository partnerRepository;
@Autowired
protected DescriptorRepository descriptorRepository;
......@@ -77,6 +100,8 @@ public abstract class AbstractApiTest extends AbstractTest {
private FaoInstituteRepository instituteRepository;
@Autowired
protected RepositoryFilePersistence repositoryFilePersistence;
@Autowired
protected DatasetAccessionRefRepository accessionRefRepository;
protected MockMvc mockMvc;
@Rule
......@@ -99,6 +124,9 @@ public abstract class AbstractApiTest extends AbstractTest {
@Override
@Transactional
public void cleanup() throws Exception {
accessionRefRepository.deleteAll();
datasetVersionsRepository.deleteAll();
datasetCreatorRepository.deleteAll();
datasetRepository.deleteAll();
repositoryFilePersistence.deleteAll();
partnerRepository.deleteAll();
......@@ -106,20 +134,64 @@ public abstract class AbstractApiTest extends AbstractTest {
super.cleanup();
}
protected Dataset setUpDataset(final PublishState state) {
return setupDataset("Test Dataset Title", "Test Dataset Description", setUpPartner("Partner", true, "PartnerShortName", UUID.randomUUID()), state);
protected Dataset setUpDataset() {
return setupDataset("Test Dataset Title", "Test Dataset Description", setUpPartner("Partner", true, "PartnerShortName", UUID.randomUUID()));
}
protected Dataset setupDataset(final String title, final String description, final Partner owner, final PublishState state) {
protected Dataset setupDataset(final String title, final String description, final Partner owner) {
final Dataset input = new Dataset();
input.setTitle(title);
input.setDescription(description);
input.setOwner(owner);
input.setVersionTag("1.0");
// input.setAccessions(accessions);
input.setState(state);
return input;
}
protected Dataset toPublished(Dataset dataset) {
if (datasetRepository.findByUuid(dataset.getUuid()) == null) {
dataset = datasetService.createDataset(dataset);
assertThat(dataset.getState(), is(PublishState.DRAFT));
}
if (dataset.getState() == PublishState.DRAFT) {
dataset = datasetService.reviewDataset(dataset);
assertThat(dataset.getState(), is(PublishState.REVIEWING));
}
if (dataset.getState() == PublishState.REVIEWING) {
dataset = datasetService.approveDataset(dataset);
assertThat(dataset.getState(), is(PublishState.PUBLISHED));
}
return dataset;
}
protected Set<AccessionRef> generateAccessionRefs(final int size) {
final Set<AccessionRef> accessionRefs = new HashSet<>(size);
for (int i=0; i<size; i++) {
accessionRefs.add(new AccessionRef("InstCode", "TestAccNum" + i, "TestGen", null));
}
return accessionRefs;
}
protected DatasetCreator buildDatasetCreator(final String fullName, final String email, final String phoneNumber, final Dataset dataset) {
final DatasetCreator datasetCreator = new DatasetCreator();
datasetCreator.setDataset(dataset);
datasetCreator.setFullName(fullName);
datasetCreator.setRole(DatasetCreator.DatasetCreatorRole.MANAGER);
datasetCreator.setEmail(email);
datasetCreator.setPhoneNumber(phoneNumber);
return datasetCreator;
}
protected SubsetCreator buildSubsetCreator(final String fullName, final String email, final String phoneNumber, final Subset subset) {
final SubsetCreator subsetCreator = new SubsetCreator();
subsetCreator.setSubset(subset);
subsetCreator.setFullName(fullName);
subsetCreator.setRole(SubsetCreator.SubsetCreatorRole.MANAGER);
subsetCreator.setEmail(email);
subsetCreator.setPhoneNumber(phoneNumber);
return subsetCreator;
}
protected Partner setUpPartner(final String name, final boolean isActive, final String shortName, final UUID uuid) {
final Partner partner = new Partner();
partner.setName(name);
......
......@@ -73,8 +73,8 @@ public abstract class AbstractDatasetServiceTest extends CatalogServiceTest {
@After
@Override
public void cleanup() throws Exception {
datasetRepository.deleteAll();
datasetVersionsRepository.deleteAll();
datasetRepository.deleteAll();
descriptorRepository.deleteAll();
repositoryFilePersistence.deleteAll();
super.cleanup();
......@@ -90,9 +90,23 @@ public abstract class AbstractDatasetServiceTest extends CatalogServiceTest {
input.setDescription(datasetDescription);
input.setOwner(partner);
input.setState(state);
input.setVersionTag("1.0");
return input;
}
protected Dataset toPublished(Dataset dataset) {
if (datasetRepository.findByUuid(dataset.getUuid()) == null) {
dataset = datasetService.createDataset(buildDataset(DATASET_TITLE_1, DATASET_DESCRIPTION_1, partner, PublishState.DRAFT));
}
if (dataset.getState() == PublishState.DRAFT) {
dataset = datasetService.reviewDataset(dataset);
}
if (dataset.getState() == PublishState.REVIEWING) {
dataset = datasetService.approveDataset(dataset);
}
return dataset;
}
protected DatasetCreator buildDatasetCreator(final String fullName, final String email, final String phoneNumber, final Dataset dataset) {
final DatasetCreator datasetCreator = new DatasetCreator();
datasetCreator.setDataset(dataset);
......
......@@ -36,8 +36,6 @@ public class DatasetPublishingTest extends AbstractDatasetServiceTest {
@Transactional
public void cleanup() throws Exception {
savedDataset = null;
descriptorRepository.deleteAll();
datasetRepository.deleteAll();
super.cleanup();
}
......
......@@ -71,7 +71,8 @@ public class DatasetServiceTest extends AbstractDatasetServiceTest {
assertThat(input, not(nullValue()));
assertThat(input.getId(), not(nullValue()));
assertThat(input.getVersions(), not(nullValue()));
assertThat(input.getVersions().getCurrentVersion(), is(input));
assertNull(input.getVersions().getCurrentVersion());
assertEquals(input.getState(), PublishState.DRAFT);
}
/**
......@@ -155,7 +156,7 @@ public class DatasetServiceTest extends AbstractDatasetServiceTest {
}
@Test
public void testLookupAccessionsForAccessionIdentifiersInDataset() {
public void testLookupAccessionsForAccessionIdentifiersInDataset() throws InterruptedException {
final Accession accession = upsertAccession(TEST_INSTCODE, "TestAccNum", "TestGen");
Dataset input = buildDataset(DATASET_TITLE_1, DATASET_DESCRIPTION_1, partner, PublishState.DRAFT);
......@@ -167,6 +168,8 @@ public class DatasetServiceTest extends AbstractDatasetServiceTest {
assertThat(input, not(nullValue()));
assertThat(input.getAccessionCount(), is(1));
datasetService.rematchDatasetAccessions(input);
Thread.sleep(2000);
final AccessionRef datasetAccessionRef = datasetService.listAccessions(input, new PageRequest(0, 10)).getContent().get(0);
assertThat(datasetAccessionRef, notNullValue());
......@@ -175,7 +178,7 @@ public class DatasetServiceTest extends AbstractDatasetServiceTest {
}
@Test
public void testCreateAndUpdateAccessionsInDataset() {
public void testCreateAndUpdateAccessionsInDataset() throws InterruptedException {
final Accession accession1 = upsertAccession(TEST_INSTCODE, TEST_ACCNUM, TEST_GEN);
final Accession accession2 = upsertAccession(TEST_INSTCODE2, TEST_ACCNUM2, TEST_GEN2);
final Accession accession3 = upsertAccession(TEST_INSTCODE3, TEST_ACCNUM3, TEST_GEN3);
......@@ -191,6 +194,8 @@ public class DatasetServiceTest extends AbstractDatasetServiceTest {
assertThat(input.getAccessionCount(), is(3));
assertThat(input.getAccessionCount(), is(datasetAccessionRefs.size()));
datasetService.rematchDatasetAccessions(input);
Thread.sleep(5500);
datasetService.listAccessions(input, new PageRequest(0, 10)).forEach(aid -> {
assertThat(aid.getAccession(), notNullValue());
......@@ -446,9 +451,9 @@ public class DatasetServiceTest extends AbstractDatasetServiceTest {
@Test
public void testListMarkdownSortDatasets() {
final Dataset dataset1 = buildAndSaveDataset("Dataset 1", DATASET_DESCRIPTION_1, partner, PublishState.PUBLISHED);
final Dataset dataset2 = buildAndSaveDataset("*Dataset* 2", DATASET_DESCRIPTION_1, partner, PublishState.PUBLISHED);
final Dataset dataset3 = buildAndSaveDataset("Dataset 3", DATASET_DESCRIPTION_1, partner, PublishState.PUBLISHED);
final Dataset dataset1 = toPublished(buildAndSaveDataset("Dataset 1", DATASET_DESCRIPTION_1, partner, PublishState.DRAFT));
final Dataset dataset2 = toPublished(buildAndSaveDataset("*Dataset* 2", DATASET_DESCRIPTION_1, partner, PublishState.DRAFT));
final Dataset dataset3 = toPublished(buildAndSaveDataset("Dataset 3", DATASET_DESCRIPTION_1, partner, PublishState.DRAFT));
final String[] strs = new String[] { "title" };
final Pageable pageable = new PageRequest(0, Integer.min(50, 100), Sort.Direction.ASC, strs);
......@@ -465,25 +470,30 @@ public class DatasetServiceTest extends AbstractDatasetServiceTest {
// not listed
buildAndSaveDataset("Not published " + DATASET_TITLE_1, DATASET_DESCRIPTION_1, partner, PublishState.DRAFT);
// listed
final Dataset input = buildAndSaveDataset(DATASET_TITLE_1, DATASET_DESCRIPTION_1, partner, PublishState.PUBLISHED);
final Dataset published = toPublished(new Dataset());
final String[] strs = new String[] { "title" };
final Pageable pageable = new PageRequest(0, Integer.min(50, 100), Sort.Direction.ASC, strs);
final Page<?> page = datasetService.listDatasets(new DatasetFilter(), pageable);
final String[] sortBy = new String[] { "title" };
final Pageable pageable = new PageRequest(0, Integer.min(50, 100), Sort.Direction.ASC, sortBy);
final Page<Dataset> page = datasetService.listDatasets(new DatasetFilter(), pageable);
assertThat(page.getTotalElements(), is(1L));
assertThat(((Dataset) page.getContent().get(0)).getUuid(), is(input.getUuid()));
assertThat((page.getContent().get(0)).getUuid(), is(published.getUuid()));
}
@Test
public void testLoadCurrentVersionList() {
final Dataset result = buildAndSaveDataset(DATASET_TITLE_1, DATASET_DESCRIPTION_1, partner, PublishState.DRAFT);
final Dataset dataset_1 = toPublished(buildAndSaveDataset(DATASET_TITLE_1, DATASET_DESCRIPTION_1, partner, PublishState.DRAFT));
assertTrue(dataset_1.getCurrent());
final String[] strs = new String[] { "title" };
final Pageable pageable = new PageRequest(0, Integer.min(50, 100), Sort.Direction.ASC, strs);
final Page<?> page = datasetService.loadCurrentVersionList(pageable);
final Dataset dataset_2 = datasetService.createNewVersion(dataset_1);
assertNull(dataset_2.getCurrent());
assertTrue(datasetRepository.findByUuid(dataset_1.getUuid()).getCurrent());
final String[] sortBy = new String[] { "title" };
final Pageable pageable = new PageRequest(0, Integer.min(50, 100), Sort.Direction.ASC, sortBy);
final Page<Dataset> page = datasetService.loadCurrentVersionList(pageable);
assertThat(page.getTotalElements(), is(1L));
assertThat(((Dataset) page.getContent().get(0)).getUuid(), is(result.getUuid()));
assertThat((page.getContent().get(0)).getUuid(), is(dataset_1.getUuid()));
}
@Test(expected = NotFoundElement.class)
......@@ -839,6 +849,8 @@ public class DatasetServiceTest extends AbstractDatasetServiceTest {
datasetService.rematchDatasetAccessions(dataset1);
datasetService.rematchDatasetAccessions(dataset2);
Thread.sleep(5500);
List<Dataset> datasets1 = datasetService.listByAccession(accession1);
assertThat(datasets1, not(nullValue()));
assertThat(datasetRepository.count(), is(2l));
......@@ -848,7 +860,7 @@ public class DatasetServiceTest extends AbstractDatasetServiceTest {
final Accession accession2 = upsertAccession(TEST_INSTCODE, "A8", "Musa");
datasetService.rematchDatasetAccessions(dataset1);
Thread.sleep(5000);
Thread.sleep(5500);
datasets1 = datasetService.listByAccession(accession2);
assertThat(datasets1.size(), is(1));
......
......@@ -50,7 +50,7 @@ public class DatasetCreatorControllerTest extends AbstractApiTest {
@Test
@WithMockOAuth2Authentication(roles = { "ADMINISTRATOR" }, scopes = { "write" })
public void listDatasetCreators() throws Exception {
final Dataset dataset = datasetService.createDataset(setUpDataset(PublishState.DRAFT));
final Dataset dataset = datasetService.