@Test void testGetClasses() { resetMocks(); when(mutableAclClassService.getAclClassTypes()) .thenReturn(Arrays.asList("entity-test1", "entity-test2")); doReturn("label1").when(entityHelper).getLabel("entity-test1"); doReturn("entityType1").when(entityHelper).getEntityTypeIdFromType("entity-test1"); doReturn("label2").when(entityHelper).getLabel("entity-test2"); doReturn("entityType2").when(entityHelper).getEntityTypeIdFromType("entity-test2"); doReturn(true) .when(userPermissionEvaluator) .hasPermission(new EntityTypeIdentity("entityType1"), READ_METADATA); doReturn(true) .when(userPermissionEvaluator) .hasPermission(new EntityTypeIdentity("entityType2"), READ_METADATA); assertEquals( new HashSet<>( asList( create("entity-test1", "entityType1", "label1"), create("entity-test2", "entityType2", "label2"))), permissionsApiService.getLabelledTypes()); }
@Override public Set<LabelledType> getLabelledTypes() { Set<LabelledType> types = new HashSet<>(); for (String typeId : mutableAclClassService.getAclClassTypes()) { String entityTypeId = entityHelper.getEntityTypeIdFromType(typeId); String label = entityHelper.getLabel(typeId); types.add(LabelledType.create(typeId, entityTypeId, label)); } return types.stream() .filter( type -> userPermissionEvaluator.hasPermission( new EntityTypeIdentity(type.getEntityType()), READ_METADATA)) .collect(toSet()); }
PermissionServiceImpl implements PermissionService { @Override public Set<LabelledType> getLabelledTypes() { Set<LabelledType> types = new HashSet<>(); for (String typeId : mutableAclClassService.getAclClassTypes()) { String entityTypeId = entityHelper.getEntityTypeIdFromType(typeId); String label = entityHelper.getLabel(typeId); types.add(LabelledType.create(typeId, entityTypeId, label)); } return types.stream() .filter( type -> userPermissionEvaluator.hasPermission( new EntityTypeIdentity(type.getEntityType()), READ_METADATA)) .collect(toSet()); } }
PermissionServiceImpl implements PermissionService { @Override public Set<LabelledType> getLabelledTypes() { Set<LabelledType> types = new HashSet<>(); for (String typeId : mutableAclClassService.getAclClassTypes()) { String entityTypeId = entityHelper.getEntityTypeIdFromType(typeId); String label = entityHelper.getLabel(typeId); types.add(LabelledType.create(typeId, entityTypeId, label)); } return types.stream() .filter( type -> userPermissionEvaluator.hasPermission( new EntityTypeIdentity(type.getEntityType()), READ_METADATA)) .collect(toSet()); } PermissionServiceImpl(
      MutableAclService mutableAclService,
      PermissionInheritanceResolver inheritanceResolver,
      ObjectIdentityService objectIdentityService,
      DataService dataService,
      MutableAclClassService mutableAclClassService,
      UserRoleTools userRoleTools,
      EntityHelper entityHelper,
      UserPermissionEvaluator userPermissionEvaluator); }
PermissionServiceImpl implements PermissionService { @Override public Set<LabelledType> getLabelledTypes() { Set<LabelledType> types = new HashSet<>(); for (String typeId : mutableAclClassService.getAclClassTypes()) { String entityTypeId = entityHelper.getEntityTypeIdFromType(typeId); String label = entityHelper.getLabel(typeId); types.add(LabelledType.create(typeId, entityTypeId, label)); } return types.stream() .filter( type -> userPermissionEvaluator.hasPermission( new EntityTypeIdentity(type.getEntityType()), READ_METADATA)) .collect(toSet()); } PermissionServiceImpl(
      MutableAclService mutableAclService,
      PermissionInheritanceResolver inheritanceResolver,
      ObjectIdentityService objectIdentityService,
      DataService dataService,
      MutableAclClassService mutableAclClassService,
      UserRoleTools userRoleTools,
      EntityHelper entityHelper,
      UserPermissionEvaluator userPermissionEvaluator); @Override Set<LabelledType> getLabelledTypes(); @Override Set<LabelledObject> getObjects(String typeId, int page, int pageSize); @Override Set<PermissionSet> getSuitablePermissionsForType(String typeId); @Override Set<LabelledPermission> getPermissionsForObject(
      ObjectIdentity objectIdentity, Set<Sid> sids, boolean isReturnInheritedPermissions); @Override Set<LabelledPermission> getPermissions(Set<Sid> sids, boolean isReturnInherited); @Override Map<String, Set<LabelledPermission>> getPermissionsForType(
      String typeId, Set<Sid> sids, int page, int pageSize); @Override Map<String, Set<LabelledPermission>> getPermissionsForType(
      String typeId, Set<Sid> sids, boolean isReturnInherited); @Override @Transactional void createAcl(ObjectIdentity objectIdentity); @Override @Transactional void createPermission(Permission permission); @Override @Transactional void createPermissions(Set<Permission> permissions); @Override @Transactional void updatePermission(Permission permission); @Override @Transactional void updatePermissions(Set<Permission> permissions); @Override @Transactional void deletePermission(Sid sid, ObjectIdentity objectIdentity); @Override @Transactional void addType(String typeId); @Override @Transactional void deleteType(String typeId); @Override boolean exists(ObjectIdentity objectIdentity, Sid sid); }
PermissionServiceImpl implements PermissionService { @Override public Set<LabelledType> getLabelledTypes() { Set<LabelledType> types = new HashSet<>(); for (String typeId : mutableAclClassService.getAclClassTypes()) { String entityTypeId = entityHelper.getEntityTypeIdFromType(typeId); String label = entityHelper.getLabel(typeId); types.add(LabelledType.create(typeId, entityTypeId, label)); } return types.stream() .filter( type -> userPermissionEvaluator.hasPermission( new EntityTypeIdentity(type.getEntityType()), READ_METADATA)) .collect(toSet()); } PermissionServiceImpl(
      MutableAclService mutableAclService,
      PermissionInheritanceResolver inheritanceResolver,
      ObjectIdentityService objectIdentityService,
      DataService dataService,
      MutableAclClassService mutableAclClassService,
      UserRoleTools userRoleTools,
      EntityHelper entityHelper,
      UserPermissionEvaluator userPermissionEvaluator); @Override Set<LabelledType> getLabelledTypes(); @Override Set<LabelledObject> getObjects(String typeId, int page, int pageSize); @Override Set<PermissionSet> getSuitablePermissionsForType(String typeId); @Override Set<LabelledPermission> getPermissionsForObject(
      ObjectIdentity objectIdentity, Set<Sid> sids, boolean isReturnInheritedPermissions); @Override Set<LabelledPermission> getPermissions(Set<Sid> sids, boolean isReturnInherited); @Override Map<String, Set<LabelledPermission>> getPermissionsForType(
      String typeId, Set<Sid> sids, int page, int pageSize); @Override Map<String, Set<LabelledPermission>> getPermissionsForType(
      String typeId, Set<Sid> sids, boolean isReturnInherited); @Override @Transactional void createAcl(ObjectIdentity objectIdentity); @Override @Transactional void createPermission(Permission permission); @Override @Transactional void createPermissions(Set<Permission> permissions); @Override @Transactional void updatePermission(Permission permission); @Override @Transactional void updatePermissions(Set<Permission> permissions); @Override @Transactional void deletePermission(Sid sid, ObjectIdentity objectIdentity); @Override @Transactional void addType(String typeId); @Override @Transactional void deleteType(String typeId); @Override boolean exists(ObjectIdentity objectIdentity, Sid sid);  }