@Test public void testOrphanedEntity() { securityContextInjector.setStaffContext(); Entity principalEntity = Mockito.mock(Entity.class); Mockito.when(principalEntity.getEntityId()).thenReturn("doofus1_id"); SLIPrincipal principal = Mockito.mock(SLIPrincipal.class); Mockito.when(principal.getEntity()).thenReturn(principalEntity); securityContextInjector.setOauthSecurityContext(principal, false); Mockito.when(repo.findAll(Mockito.anyString(), Mockito.any(NeutralQuery.class))).thenReturn(new ArrayList<Entity>()); Map<String, Object> metaData = new HashMap<String, Object>(); metaData.put("createdBy", "doofus1_id"); metaData.put("isOrphaned", "true"); Entity student1 = new MongoEntity(EntityNames.STUDENT, "student1", new HashMap<String, Object>(), metaData); Set<String> edorgIds = arbiter.determineHierarchicalEdorgs(Arrays.asList(student1), EntityNames.STUDENT); Assert.assertTrue(edorgIds.isEmpty()); }
public Set<String> determineHierarchicalEdorgs(Iterable<Entity> entities, String entityType) { Set<String> hierarchicalEdorgs = new HashSet<String>(); List<Entity> edorgs = findOwner(entities, entityType, true); for (Entity edorg : edorgs) { hierarchicalEdorgs.add(edorg.getEntityId()); hierarchicalEdorgs.addAll(helper.getParentEdOrgs(edorg)); } return hierarchicalEdorgs; }
EdOrgOwnershipArbiter extends OwnershipArbiter { public Set<String> determineHierarchicalEdorgs(Iterable<Entity> entities, String entityType) { Set<String> hierarchicalEdorgs = new HashSet<String>(); List<Entity> edorgs = findOwner(entities, entityType, true); for (Entity edorg : edorgs) { hierarchicalEdorgs.add(edorg.getEntityId()); hierarchicalEdorgs.addAll(helper.getParentEdOrgs(edorg)); } return hierarchicalEdorgs; } }
EdOrgOwnershipArbiter extends OwnershipArbiter { public Set<String> determineHierarchicalEdorgs(Iterable<Entity> entities, String entityType) { Set<String> hierarchicalEdorgs = new HashSet<String>(); List<Entity> edorgs = findOwner(entities, entityType, true); for (Entity edorg : edorgs) { hierarchicalEdorgs.add(edorg.getEntityId()); hierarchicalEdorgs.addAll(helper.getParentEdOrgs(edorg)); } return hierarchicalEdorgs; }  }
EdOrgOwnershipArbiter extends OwnershipArbiter { public Set<String> determineHierarchicalEdorgs(Iterable<Entity> entities, String entityType) { Set<String> hierarchicalEdorgs = new HashSet<String>(); List<Entity> edorgs = findOwner(entities, entityType, true); for (Entity edorg : edorgs) { hierarchicalEdorgs.add(edorg.getEntityId()); hierarchicalEdorgs.addAll(helper.getParentEdOrgs(edorg)); } return hierarchicalEdorgs; }  @SuppressWarnings("unused") @PostConstruct void init(); Set<String> determineEdorgs(Iterable<Entity> entities, String entityType); Set<String> determineHierarchicalEdorgs(Iterable<Entity> entities, String entityType); boolean isEntityOwnedByEdOrg(String entityType); }
EdOrgOwnershipArbiter extends OwnershipArbiter { public Set<String> determineHierarchicalEdorgs(Iterable<Entity> entities, String entityType) { Set<String> hierarchicalEdorgs = new HashSet<String>(); List<Entity> edorgs = findOwner(entities, entityType, true); for (Entity edorg : edorgs) { hierarchicalEdorgs.add(edorg.getEntityId()); hierarchicalEdorgs.addAll(helper.getParentEdOrgs(edorg)); } return hierarchicalEdorgs; }  @SuppressWarnings("unused") @PostConstruct void init(); Set<String> determineEdorgs(Iterable<Entity> entities, String entityType); Set<String> determineHierarchicalEdorgs(Iterable<Entity> entities, String entityType); boolean isEntityOwnedByEdOrg(String entityType);  }