FedoraUserDao extends FedoraDao { public String add(UserProfile user, String owner, String logMessage) { String pid = user.getUserNameAsPid(); boolean isRemote = user.getRemoteName() != null; LocalObject newObject = newObject(pid, user, isRemote, owner, logMessage); user.setUserName(getUserName(newObject.getPid())); return newObject.getPid(); } FedoraUserDao(); String add(UserProfile user, String owner, String logMessage); void addMembership(UserProfile user, Collection<Group> groups, String logMessage); void setMembership(UserProfile user, Collection<Group> groups, String logMessage); static final String METAMODEL_ID; static final String PID_PREFIX; }
@Test public void testRollback() throws Exception { FedoraUserDao dao = new FedoraUserDao(); dao.setTransaction(tx); UserProfile user = new UserProfile(); user.setUserName(testName.getMethodName() + "_1"); dao.add(user, support.getTestUser(), testName.getMethodName()); String userPid1 = user.getUserNameAsPid(); user = new UserProfile(); user.setUserName(testName.getMethodName() + "_2"); dao.add(user, support.getTestUser(), testName.getMethodName()); String userPid2 = user.getUserNameAsPid(); assertTrue(tx.getRemoteStorage().exist(userPid1)); assertTrue(tx.getRemoteStorage().exist(userPid2)); tx.rollback(); assertFalse(tx.getRemoteStorage().exist(userPid1)); assertFalse(tx.getRemoteStorage().exist(userPid2)); }