@Test public void testEdOrgReferenceEntities() { securityContextInjector.setEducatorContext(); Entity edorg = createEntity(EntityNames.SCHOOL, "edorg1", new HashMap<String, Object>()); Mockito.when(repo.findAll(Mockito.eq(EntityNames.EDUCATION_ORGANIZATION), argThat(new BaseMatcher<NeutralQuery>() { @Override public boolean matches(Object item) { NeutralQuery matching = new NeutralQuery(new NeutralCriteria(ParameterConstants.ID, NeutralCriteria.OPERATOR_EQUAL, "edorg1")); NeutralQuery other = (NeutralQuery) item; return matching.getCriteria().equals(other.getCriteria()); } @Override public void describeTo(Description description) { } }))).thenReturn(Arrays.asList(edorg)); Map<String, Object> attendanceBody = new HashMap<String, Object>(); attendanceBody.put(ParameterConstants.SCHOOL_ID, "edorg1"); Entity attendance = createEntity(EntityNames.ATTENDANCE, "attendance1", attendanceBody); Set<String> edorgIds = arbiter.determineEdorgs(Arrays.asList(attendance), EntityNames.ATTENDANCE); Assert.assertEquals(1, edorgIds.size()); Assert.assertTrue(edorgIds.contains("edorg1")); }
public Set<String> determineEdorgs(Iterable<Entity> entities, String entityType) { Set<String> edorgs = new HashSet<String>(); for (Entity entity : findOwner(entities, entityType, false)) { edorgs.add(entity.getEntityId()); } return edorgs; }
EdOrgOwnershipArbiter extends OwnershipArbiter { public Set<String> determineEdorgs(Iterable<Entity> entities, String entityType) { Set<String> edorgs = new HashSet<String>(); for (Entity entity : findOwner(entities, entityType, false)) { edorgs.add(entity.getEntityId()); } return edorgs; } }
EdOrgOwnershipArbiter extends OwnershipArbiter { public Set<String> determineEdorgs(Iterable<Entity> entities, String entityType) { Set<String> edorgs = new HashSet<String>(); for (Entity entity : findOwner(entities, entityType, false)) { edorgs.add(entity.getEntityId()); } return edorgs; }  }
EdOrgOwnershipArbiter extends OwnershipArbiter { public Set<String> determineEdorgs(Iterable<Entity> entities, String entityType) { Set<String> edorgs = new HashSet<String>(); for (Entity entity : findOwner(entities, entityType, false)) { edorgs.add(entity.getEntityId()); } return edorgs; }  @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> determineEdorgs(Iterable<Entity> entities, String entityType) { Set<String> edorgs = new HashSet<String>(); for (Entity entity : findOwner(entities, entityType, false)) { edorgs.add(entity.getEntityId()); } return edorgs; }  @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);  }