tests
This commit is contained in:
parent
b78eab271d
commit
216d9cf53c
|
@ -6,7 +6,7 @@ import static org.junit.jupiter.api.Assertions.assertNotEquals;
|
|||
|
||||
import java.util.Date;
|
||||
|
||||
import org.junit.Ignore;
|
||||
import org.junit.jupiter.api.Disabled;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.boot.test.context.SpringBootTest;
|
||||
|
@ -15,7 +15,7 @@ import eu.dnetlib.data.mdstore.manager.common.model.MDStoreVersion;
|
|||
import eu.dnetlib.data.mdstore.manager.common.model.MDStoreWithInfo;
|
||||
import eu.dnetlib.data.mdstore.manager.exceptions.MDStoreManagerException;
|
||||
|
||||
@Ignore
|
||||
@Disabled
|
||||
@SpringBootTest
|
||||
class MDStoreControllerTest {
|
||||
|
||||
|
@ -30,12 +30,12 @@ class MDStoreControllerTest {
|
|||
final MDStoreWithInfo store = controller.createMDStore("oai_dc", "store", "native", "TEST REPO", "openaire____::1234", "openaire____::1234::oai");
|
||||
|
||||
final String mdId = store.getId();
|
||||
final String currentVersion = store.getCurrentVersion();
|
||||
final String firstVersion = store.getCurrentVersion();
|
||||
|
||||
final long lastUpdate = store.getLastUpdate().getTime();
|
||||
|
||||
assertTrue(mdId.length() > 0);
|
||||
assertTrue(currentVersion.length() > 0);
|
||||
assertTrue(firstVersion.length() > 0);
|
||||
assertTrue(lastUpdate > now);
|
||||
assertEquals("oai_dc", store.getFormat());
|
||||
assertEquals("store", store.getLayout());
|
||||
|
@ -49,7 +49,7 @@ class MDStoreControllerTest {
|
|||
final MDStoreWithInfo store2 = controller.getMdStore(mdId);
|
||||
|
||||
assertEquals(store2.getId(), mdId);
|
||||
assertEquals(store2.getCurrentVersion(), currentVersion);
|
||||
assertEquals(store2.getCurrentVersion(), firstVersion);
|
||||
assertEquals(store2.getLastUpdate().getTime(), lastUpdate);
|
||||
assertEquals(store2.getFormat(), store.getFormat());
|
||||
assertEquals(store2.getLayout(), store.getLayout());
|
||||
|
@ -77,35 +77,35 @@ class MDStoreControllerTest {
|
|||
final MDStoreWithInfo store = controller.createMDStore("oai_dc", "store", "native", "TEST REPO", "openaire____::1234", "openaire____::1234::oai");
|
||||
|
||||
final String mdId = store.getId();
|
||||
final String currentVersion = store.getCurrentVersion();
|
||||
final String firstVersion = store.getCurrentVersion();
|
||||
|
||||
final MDStoreVersion v1 = controller.startReading(mdId);
|
||||
assertEquals(currentVersion, v1.getId());
|
||||
assertEquals(firstVersion, v1.getId());
|
||||
assertEquals(0l, v1.getSize());
|
||||
assertEquals(1, v1.getReadCount());
|
||||
|
||||
final MDStoreVersion v2 = controller.startReading(mdId);
|
||||
assertEquals(currentVersion, v2.getId());
|
||||
assertEquals(firstVersion, v2.getId());
|
||||
assertEquals(0l, v2.getSize());
|
||||
assertEquals(2, v2.getReadCount());
|
||||
|
||||
final MDStoreVersion v3 = controller.startReading(mdId);
|
||||
assertEquals(currentVersion, v3.getId());
|
||||
assertEquals(firstVersion, v3.getId());
|
||||
assertEquals(0l, v3.getSize());
|
||||
assertEquals(3, v3.getReadCount());
|
||||
|
||||
final MDStoreVersion v4 = controller.endReading(v1.getId());
|
||||
assertEquals(currentVersion, v4.getId());
|
||||
assertEquals(firstVersion, v4.getId());
|
||||
assertEquals(0l, v4.getSize());
|
||||
assertEquals(2, v4.getReadCount());
|
||||
|
||||
final MDStoreVersion v5 = controller.endReading(v2.getId());
|
||||
assertEquals(currentVersion, v5.getId());
|
||||
assertEquals(firstVersion, v5.getId());
|
||||
assertEquals(0l, v5.getSize());
|
||||
assertEquals(1, v5.getReadCount());
|
||||
|
||||
final MDStoreVersion v6 = controller.endReading(v3.getId());
|
||||
assertEquals(currentVersion, v6.getId());
|
||||
assertEquals(firstVersion, v6.getId());
|
||||
assertEquals(0l, v6.getSize());
|
||||
assertEquals(0, v6.getReadCount());
|
||||
|
||||
|
@ -118,12 +118,12 @@ class MDStoreControllerTest {
|
|||
final MDStoreWithInfo store = controller.createMDStore("oai_dc", "store", "native", "TEST REPO", "openaire____::1234", "openaire____::1234::oai");
|
||||
|
||||
final String mdId = store.getId();
|
||||
final String currentVersion = store.getCurrentVersion();
|
||||
final String firstVersion = store.getCurrentVersion();
|
||||
|
||||
final MDStoreVersion v1 = controller.prepareNewVersion(mdId);
|
||||
final MDStoreWithInfo md1 = controller.getMdStore(mdId);
|
||||
assertNotEquals(v1.getId(), md1.getCurrentVersion());
|
||||
assertEquals(currentVersion, md1.getCurrentVersion());
|
||||
assertEquals(firstVersion, md1.getCurrentVersion());
|
||||
assertEquals(0l, md1.getSize());
|
||||
|
||||
final MDStoreVersion v2 = controller.commitVersion(v1.getId(), 1234l);
|
||||
|
@ -147,12 +147,52 @@ class MDStoreControllerTest {
|
|||
final String v2 = controller.prepareNewVersion(mdId).getId();
|
||||
final String v3 = controller.prepareNewVersion(mdId).getId();
|
||||
|
||||
assertEquals(0, controller.listExpiredVersions().size());
|
||||
|
||||
controller.commitVersion(v3, 1111l).getId();
|
||||
assertEquals(v3, controller.getMdStore(mdId).getCurrentVersion());
|
||||
assertEquals(1, controller.listExpiredVersions().size());
|
||||
|
||||
controller.commitVersion(v1, 2222l).getId();
|
||||
assertEquals(v1, controller.getMdStore(mdId).getCurrentVersion());
|
||||
assertEquals(2, controller.listExpiredVersions().size());
|
||||
|
||||
controller.commitVersion(v2, 3333l).getId();
|
||||
assertEquals(v2, controller.getMdStore(mdId).getCurrentVersion());
|
||||
assertEquals(3, controller.listExpiredVersions().size());
|
||||
|
||||
controller.delete(mdId);
|
||||
}
|
||||
|
||||
@Test
|
||||
void testNewVersionsAndReading() throws MDStoreManagerException {
|
||||
|
||||
final MDStoreWithInfo store = controller.createMDStore("oai_dc", "store", "native", "TEST REPO", "openaire____::1234", "openaire____::1234::oai");
|
||||
|
||||
final String mdId = store.getId();
|
||||
final String firstVersion = store.getCurrentVersion();
|
||||
|
||||
final String vr1 = controller.startReading(mdId).getId();
|
||||
assertEquals(firstVersion, vr1);
|
||||
|
||||
final String v1 = controller.prepareNewVersion(mdId).getId();
|
||||
|
||||
final String vr2 = controller.startReading(mdId).getId();
|
||||
assertEquals(firstVersion, vr2);
|
||||
|
||||
controller.commitVersion(v1, 1111l);
|
||||
|
||||
final String vr3 = controller.startReading(mdId).getId();
|
||||
assertEquals(v1, vr3);
|
||||
|
||||
assertEquals(0, controller.listExpiredVersions().size());
|
||||
controller.endReading(vr1);
|
||||
assertEquals(0, controller.listExpiredVersions().size());
|
||||
controller.endReading(vr3);
|
||||
assertEquals(0, controller.listExpiredVersions().size());
|
||||
controller.endReading(vr2);
|
||||
assertEquals(1, controller.listExpiredVersions().size());
|
||||
assertEquals(firstVersion, controller.listExpiredVersions().get(0));
|
||||
|
||||
controller.delete(mdId);
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue