use of io.atlasmap.v2.Document in project mycore by MyCoRe-Org.
the class MCRMetadataStoreTest method exists.
@Test
public void exists() throws Exception {
int id = getMetaDataStore().getNextFreeID();
assertFalse(getMetaDataStore().exists(id));
Document xml1 = new Document(new Element("root"));
getMetaDataStore().create(new MCRJDOMContent(xml1), id);
assertTrue(getMetaDataStore().exists(id));
getMetaDataStore().delete(id);
assertFalse(getMetaDataStore().exists(id));
}
use of io.atlasmap.v2.Document in project mycore by MyCoRe-Org.
the class MCRMetadataStoreTest method lastModified.
@Test
public void lastModified() throws Exception {
Document xml1 = new Document(new Element("root"));
Date date1 = new Date();
synchronized (this) {
wait(1000);
}
MCRStoredMetadata sm = getMetaDataStore().create(new MCRJDOMContent(xml1));
Date date2 = sm.getLastModified();
assertTrue(date2.after(date1));
synchronized (this) {
wait(1000);
}
Document xml2 = new Document(new Element("root"));
sm.update(new MCRJDOMContent(xml2));
assertTrue(sm.getLastModified().after(date2));
@SuppressWarnings("deprecation") Date date = new Date(109, 1, 1);
sm.setLastModified(date);
sm = getMetaDataStore().retrieve(sm.getID());
assertEquals(date, sm.getLastModified());
}
use of io.atlasmap.v2.Document in project mycore by MyCoRe-Org.
the class MCRVersioningMetadataStoreTest method delete.
@Test
public void delete() throws Exception {
System.out.println("TEST DELETE");
Document xml1 = new Document(new Element("root"));
int id = getVersStore().create(new MCRJDOMContent(xml1)).getID();
assertTrue(getVersStore().exists(id));
getVersStore().delete(id);
assertFalse(getVersStore().exists(id));
}
use of io.atlasmap.v2.Document in project mycore by MyCoRe-Org.
the class MCRVersioningMetadataStoreTest method createUpdateDeleteCreate.
@Test
public void createUpdateDeleteCreate() throws Exception {
Element root = new Element("bingo");
Document xml1 = new Document(root);
MCRVersionedMetadata vm = getVersStore().create(new MCRJDOMContent(xml1));
root.setName("bango");
vm.update(new MCRJDOMContent(xml1));
vm.delete();
root.setName("bongo");
vm = getVersStore().create(new MCRJDOMContent(xml1), vm.getID());
List<MCRMetadataVersion> versions = vm.listVersions();
assertEquals(4, versions.size());
assertEquals(MCRMetadataVersion.CREATED, versions.get(0).getType());
assertEquals(MCRMetadataVersion.UPDATED, versions.get(1).getType());
assertEquals(MCRMetadataVersion.DELETED, versions.get(2).getType());
assertEquals(MCRMetadataVersion.CREATED, versions.get(3).getType());
versions.get(1).restore();
assertEquals("bango", vm.getMetadata().asXML().getRootElement().getName());
}
use of io.atlasmap.v2.Document in project mycore by MyCoRe-Org.
the class MCRVersioningMetadataStoreTest method createDocument.
@Test
public void createDocument() throws Exception {
Document testXmlDoc = new Document(new Element("root"));
MCRContent testContent = new MCRJDOMContent(testXmlDoc);
MCRVersionedMetadata versionedMetadata = getVersStore().create(testContent);
MCRContent contentFromStore = getVersStore().retrieve(versionedMetadata.getID()).getMetadata();
String contentStrFromStore = contentFromStore.asString();
MCRContent mcrContent = new MCRJDOMContent(testXmlDoc);
String expectedContentStr = mcrContent.asString();
assertNotNull(versionedMetadata);
assertEquals(expectedContentStr, contentStrFromStore);
assertTrue(versionedMetadata.getID() > 0);
assertTrue(versionedMetadata.getRevision() > 0);
MCRVersionedMetadata vm3 = getVersStore().create(new MCRJDOMContent(testXmlDoc));
assertTrue(vm3.getID() > versionedMetadata.getID());
assertTrue(vm3.getRevision() > versionedMetadata.getRevision());
}
Aggregations