### Question:
InheritedAclFactory implements AclFactory { @Override public Date getEmbargoUntil(PID target) { return getPidPath(target).stream() .map(p -> objectAclFactory.getEmbargoUntil(p)) .filter(Objects::nonNull) .max(Comparator.naturalOrder()) .orElse(null); }  @Override Map<String, Set<String>> getPrincipalRoles(PID target); @Override List<RoleAssignment> getStaffRoleAssignments(PID pid); @Override List<RoleAssignment> getPatronRoleAssignments(PID pid); @Override List<RoleAssignment> getPatronAccess(PID pid); @Override Date getEmbargoUntil(PID target); @Override boolean isMarkedForDeletion(PID target); void setObjectAclFactory(ObjectAclFactory objectAclFactory); void setPathFactory(ContentPathFactory pathFactory);  }### Answer:
@Test public void noEmbargo() { addPidToAncestors(); when(objectAclFactory.getEmbargoUntil(any(PID.class))).thenReturn(null); assertNull("No embargo should return null", aclFactory.getEmbargoUntil(pid)); }
@Test public void hasEmbargo() { addPidToAncestors(); Date embargoDate = new Date(); when(objectAclFactory.getEmbargoUntil(eq(pid))).thenReturn(embargoDate); assertEquals(embargoDate, aclFactory.getEmbargoUntil(pid)); }
@Test public void inheritEmbargo() { addPidToAncestors(); PID collPid = addPidToAncestors(); Date embargoDate = new Date(); when(objectAclFactory.getEmbargoUntil(eq(collPid))).thenReturn(embargoDate); assertEquals(embargoDate, aclFactory.getEmbargoUntil(pid)); }
@Test public void overrideInheritedEmbargo() { addPidToAncestors(); PID collPid = addPidToAncestors(); Date collEmbargoDate = new Date(); when(objectAclFactory.getEmbargoUntil(eq(collPid))).thenReturn(collEmbargoDate); Date tomorrowEmbargo = Date.from(ZonedDateTime.now().plusDays(1).toInstant()); when(objectAclFactory.getEmbargoUntil(eq(pid))).thenReturn(tomorrowEmbargo); assertEquals(tomorrowEmbargo, aclFactory.getEmbargoUntil(pid)); }
@Test public void overrideLocalEmbargo() { addPidToAncestors(); PID collPid = addPidToAncestors(); Date collEmbargoDate = Date.from(ZonedDateTime.now().plusDays(1).toInstant()); when(objectAclFactory.getEmbargoUntil(eq(collPid))).thenReturn(collEmbargoDate); Date objEmbargoDate = new Date(); when(objectAclFactory.getEmbargoUntil(eq(pid))).thenReturn(objEmbargoDate); assertEquals(collEmbargoDate, aclFactory.getEmbargoUntil(pid)); }