Search in sources :

Example 21 with PID

use of edu.unc.lib.boxc.model.api.ids.PID in project box-c by UNC-Libraries.

the class RepositoryObjectLoaderTest method invalidateTest.

@Test
public void invalidateTest() throws Exception {
    PID pid = pidMinter.mintContentPid();
    when(objectCacheLoader.load(eq(pid))).thenReturn(mock(FolderObject.class));
    // Trigger population of cache
    repoObjLoader.getRepositoryObject(pid);
    LoadingCache<PID, RepositoryObject> repoObjCache = repoObjLoader.getRepositoryObjectCache();
    assertNotNull(repoObjCache.getIfPresent(pid));
    repoObjLoader.invalidate(pid);
    assertNull(repoObjCache.getIfPresent(pid));
}
Also used : RepositoryObject(edu.unc.lib.boxc.model.api.objects.RepositoryObject) PID(edu.unc.lib.boxc.model.api.ids.PID) FolderObject(edu.unc.lib.boxc.model.api.objects.FolderObject) Test(org.junit.Test)

Example 22 with PID

use of edu.unc.lib.boxc.model.api.ids.PID in project box-c by UNC-Libraries.

the class OperationsMessageSender method sendSetAsPrimaryObjectOperation.

/**
 * Sends set-as-primary-object operation message.
 *
 * @param userid id of user who triggered the operation
 * @param pids objects whose primary object has changed
 * @return id of operation message
 */
public String sendSetAsPrimaryObjectOperation(String userid, Collection<PID> pids) {
    Element contentEl = createAtomEntry(userid, pids.iterator().next(), CDRActions.SET_AS_PRIMARY_OBJECT);
    Element updateEl = new Element(CDRActions.SET_AS_PRIMARY_OBJECT.getName(), CDR_MESSAGE_NS);
    contentEl.addContent(updateEl);
    Element subjects = new Element("subjects", CDR_MESSAGE_NS);
    updateEl.addContent(subjects);
    for (PID sub : pids) {
        subjects.addContent(new Element("pid", CDR_MESSAGE_NS).setText(sub.getRepositoryPath()));
    }
    Document msg = contentEl.getDocument();
    sendMessage(msg);
    LOG.debug("sent set-as-primary-object operation JMS message using JMS template: {}", this.getJmsTemplate());
    return getMessageId(msg);
}
Also used : Element(org.jdom2.Element) PID(edu.unc.lib.boxc.model.api.ids.PID) Document(org.jdom2.Document)

Example 23 with PID

use of edu.unc.lib.boxc.model.api.ids.PID in project box-c by UNC-Libraries.

the class PIDsTest method getRootFromIdTest.

@Test
public void getRootFromIdTest() {
    PID pid = PIDs.get(REPOSITORY_ROOT_ID);
    assertEquals(FEDORA_BASE, pid.getRepositoryPath());
    assertEquals(REPOSITORY_ROOT_ID, pid.getId());
    assertEquals(REPOSITORY_ROOT_ID, pid.getQualifier());
    assertEquals(REPOSITORY_ROOT_ID + "/" + REPOSITORY_ROOT_ID, pid.getQualifiedId());
}
Also used : PID(edu.unc.lib.boxc.model.api.ids.PID) Test(org.junit.Test)

Example 24 with PID

use of edu.unc.lib.boxc.model.api.ids.PID in project box-c by UNC-Libraries.

the class PIDsTest method getContentBaseFromIdTest.

@Test
public void getContentBaseFromIdTest() {
    PID pid = PIDs.get(CONTENT_BASE);
    assertEquals(FEDORA_BASE + CONTENT_BASE, pid.getRepositoryPath());
    assertEquals(CONTENT_BASE, pid.getId());
    assertEquals(REPOSITORY_ROOT_ID, pid.getQualifier());
}
Also used : PID(edu.unc.lib.boxc.model.api.ids.PID) Test(org.junit.Test)

Example 25 with PID

use of edu.unc.lib.boxc.model.api.ids.PID in project box-c by UNC-Libraries.

the class PIDsTest method getPidFromRepositoryPath.

@Test
public void getPidFromRepositoryPath() {
    String path = fakeRepositoryPath(CONTENT_BASE, null);
    PID pid = PIDs.get(path);
    assertNotNull(pid);
    assertEquals("Identifier did not match provided value", TEST_UUID, pid.getId());
    assertEquals("Repository path was incorrect", path, pid.getRepositoryUri().toString());
    assertEquals("Incorrect qualifier", CONTENT_BASE, pid.getQualifier());
    assertNull("Component path should not be set", pid.getComponentPath());
}
Also used : PID(edu.unc.lib.boxc.model.api.ids.PID) Test(org.junit.Test)

Aggregations

PID (edu.unc.lib.boxc.model.api.ids.PID)735 Test (org.junit.Test)509 Model (org.apache.jena.rdf.model.Model)130 Resource (org.apache.jena.rdf.model.Resource)122 Bag (org.apache.jena.rdf.model.Bag)100 Matchers.anyString (org.mockito.Matchers.anyString)89 RoleAssignment (edu.unc.lib.boxc.auth.api.models.RoleAssignment)85 MvcResult (org.springframework.test.web.servlet.MvcResult)78 CollectionObject (edu.unc.lib.boxc.model.api.objects.CollectionObject)65 RepositoryObject (edu.unc.lib.boxc.model.api.objects.RepositoryObject)63 AdminUnit (edu.unc.lib.boxc.model.api.objects.AdminUnit)62 WorkObject (edu.unc.lib.boxc.model.api.objects.WorkObject)62 URI (java.net.URI)62 FileObject (edu.unc.lib.boxc.model.api.objects.FileObject)61 AbstractDepositJobTest (edu.unc.lib.boxc.deposit.fcrepo4.AbstractDepositJobTest)55 BinaryObject (edu.unc.lib.boxc.model.api.objects.BinaryObject)50 Document (org.jdom2.Document)50 FolderObject (edu.unc.lib.boxc.model.api.objects.FolderObject)48 File (java.io.File)48 Path (java.nio.file.Path)48