Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
152 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
23 changes: 23 additions & 0 deletions
23
fcrepo-kernel/src/test/java/org/fcrepo/identifiers/UUIDPidMinterTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
package org.fcrepo.identifiers; | ||
|
||
import org.junit.Test; | ||
|
||
import java.util.UUID; | ||
|
||
import static java.util.regex.Pattern.compile; | ||
import static org.junit.Assert.assertTrue; | ||
|
||
public class UUIDPidMinterTest { | ||
@Test | ||
public void testMintPid() throws Exception { | ||
|
||
PidMinter pidMinter = new UUIDPidMinter(); | ||
|
||
String pid = pidMinter.mintPid(); | ||
|
||
assertTrue("PID wasn't a UUID", compile( | ||
"[a-f0-9]{8}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{12}").matcher( | ||
pid).find()); | ||
|
||
} | ||
} |
128 changes: 128 additions & 0 deletions
128
fcrepo-kernel/src/test/java/org/fcrepo/observer/FedoraEventTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,128 @@ | ||
package org.fcrepo.observer; | ||
|
||
import com.google.common.collect.ImmutableMap; | ||
import org.junit.Test; | ||
|
||
import javax.jcr.RepositoryException; | ||
import javax.jcr.observation.Event; | ||
import java.util.Map; | ||
|
||
import static org.junit.Assert.assertEquals; | ||
|
||
public class FedoraEventTest { | ||
|
||
Event e = new FedoraEvent(new TestEvent(1, | ||
"Path", | ||
"UserId", | ||
"Identifier", | ||
ImmutableMap.of("1", "2"), | ||
"data", | ||
0L | ||
)); | ||
@Test | ||
public void testGetType() throws Exception { | ||
assertEquals(1, e.getType()); | ||
} | ||
|
||
@Test | ||
public void testGetPath() throws Exception { | ||
assertEquals("Path", e.getPath()); | ||
|
||
} | ||
|
||
@Test | ||
public void testGetUserID() throws Exception { | ||
|
||
assertEquals("UserId", e.getUserID()); | ||
|
||
} | ||
|
||
@Test | ||
public void testGetIdentifier() throws Exception { | ||
|
||
assertEquals("Identifier", e.getIdentifier()); | ||
|
||
} | ||
|
||
@Test | ||
public void testGetInfo() throws Exception { | ||
Map<String, String> m = e.getInfo(); | ||
|
||
assertEquals("2", m.get("1")); | ||
} | ||
|
||
@Test | ||
public void testGetUserData() throws Exception { | ||
|
||
assertEquals("data", e.getUserData()); | ||
|
||
} | ||
|
||
@Test | ||
public void testGetDate() throws Exception { | ||
assertEquals(0L, e.getDate()); | ||
|
||
} | ||
|
||
class TestEvent implements Event { | ||
|
||
private final int type; | ||
private final String path; | ||
private final String user_id; | ||
private final String identifier; | ||
private final Map<String, String> info; | ||
private final String userData; | ||
private final long date; | ||
|
||
public TestEvent(int type, | ||
String path, | ||
String user_id, | ||
String identifier, | ||
Map<String, String> info, | ||
String userData, | ||
long date ) { | ||
this.type = type; | ||
this.path = path; | ||
this.user_id = user_id; | ||
this.identifier = identifier; | ||
this.info = info; | ||
this.userData = userData; | ||
this.date = date; | ||
} | ||
|
||
@Override | ||
public int getType() { | ||
return this.type; | ||
} | ||
|
||
@Override | ||
public String getPath() throws RepositoryException { | ||
return this.path; | ||
} | ||
|
||
@Override | ||
public String getUserID() { | ||
return user_id; | ||
} | ||
|
||
@Override | ||
public String getIdentifier() throws RepositoryException { | ||
return identifier; | ||
} | ||
|
||
@Override | ||
public Map getInfo() throws RepositoryException { | ||
return info; | ||
} | ||
|
||
@Override | ||
public String getUserData() throws RepositoryException { | ||
return userData; | ||
} | ||
|
||
@Override | ||
public long getDate() throws RepositoryException { | ||
return date; | ||
} | ||
} | ||
} |