@WithMockUser(username = USERNAME) @Test void findOneByIdFetchUserPermissionAllowed() { String entityType0Name = "entity0"; EntityType entityType0 = when(mock(EntityType.class).getId()).thenReturn(entityType0Name).getMock(); String attr0Name = "entity0attr0"; Attribute attr0 = when(mock(Attribute.class).getName()).thenReturn(attr0Name).getMock(); when(attr0.getEntity()).thenReturn(entityType0); Object id = mock(Object.class); Fetch fetch = mock(Fetch.class); when(delegateRepository.findOneById(id, fetch)).thenReturn(attr0); when(permissionService.hasPermission( new EntityTypeIdentity(entityType0Name), EntityTypePermission.READ_METADATA)) .thenReturn(true); assertEquals(attr0, repo.findOneById(id, fetch)); }
@Override public Attribute findOneById(Object id) { if (currentUserIsSuOrSystem()) { return delegate().findOneById(id); } else { return filterReadPermission(delegate().findOneById(id)); } }
AttributeRepositorySecurityDecorator extends AbstractRepositoryDecorator<Attribute> { @Override public Attribute findOneById(Object id) { if (currentUserIsSuOrSystem()) { return delegate().findOneById(id); } else { return filterReadPermission(delegate().findOneById(id)); } } }
AttributeRepositorySecurityDecorator extends AbstractRepositoryDecorator<Attribute> { @Override public Attribute findOneById(Object id) { if (currentUserIsSuOrSystem()) { return delegate().findOneById(id); } else { return filterReadPermission(delegate().findOneById(id)); } } AttributeRepositorySecurityDecorator(
      Repository<Attribute> delegateRepository,
      SystemEntityTypeRegistry systemEntityTypeRegistry,
      UserPermissionEvaluator permissionService); }
AttributeRepositorySecurityDecorator extends AbstractRepositoryDecorator<Attribute> { @Override public Attribute findOneById(Object id) { if (currentUserIsSuOrSystem()) { return delegate().findOneById(id); } else { return filterReadPermission(delegate().findOneById(id)); } } AttributeRepositorySecurityDecorator(
      Repository<Attribute> delegateRepository,
      SystemEntityTypeRegistry systemEntityTypeRegistry,
      UserPermissionEvaluator permissionService); @Override long count(); @Override long count(Query<Attribute> q); @Override Stream<Attribute> findAll(Query<Attribute> q); @Override Iterator<Attribute> iterator(); @Override void forEachBatched(Fetch fetch, Consumer<List<Attribute>> consumer, int batchSize); @Override Attribute findOne(Query<Attribute> q); @Override Attribute findOneById(Object id); @Override Attribute findOneById(Object id, Fetch fetch); @Override Stream<Attribute> findAll(Stream<Object> ids); @Override Stream<Attribute> findAll(Stream<Object> ids, Fetch fetch); @Override AggregateResult aggregate(AggregateQuery aggregateQuery); @Override void update(Attribute attr); @Override void update(Stream<Attribute> attrs); @Override void delete(Attribute attr); @Override void delete(Stream<Attribute> attrs); @Override void deleteById(Object id); @Override void deleteAll(Stream<Object> ids); @Override void deleteAll(); @Override void add(Attribute attr); @Override Integer add(Stream<Attribute> attrs); }
AttributeRepositorySecurityDecorator extends AbstractRepositoryDecorator<Attribute> { @Override public Attribute findOneById(Object id) { if (currentUserIsSuOrSystem()) { return delegate().findOneById(id); } else { return filterReadPermission(delegate().findOneById(id)); } } AttributeRepositorySecurityDecorator(
      Repository<Attribute> delegateRepository,
      SystemEntityTypeRegistry systemEntityTypeRegistry,
      UserPermissionEvaluator permissionService); @Override long count(); @Override long count(Query<Attribute> q); @Override Stream<Attribute> findAll(Query<Attribute> q); @Override Iterator<Attribute> iterator(); @Override void forEachBatched(Fetch fetch, Consumer<List<Attribute>> consumer, int batchSize); @Override Attribute findOne(Query<Attribute> q); @Override Attribute findOneById(Object id); @Override Attribute findOneById(Object id, Fetch fetch); @Override Stream<Attribute> findAll(Stream<Object> ids); @Override Stream<Attribute> findAll(Stream<Object> ids, Fetch fetch); @Override AggregateResult aggregate(AggregateQuery aggregateQuery); @Override void update(Attribute attr); @Override void update(Stream<Attribute> attrs); @Override void delete(Attribute attr); @Override void delete(Stream<Attribute> attrs); @Override void deleteById(Object id); @Override void deleteAll(Stream<Object> ids); @Override void deleteAll(); @Override void add(Attribute attr); @Override Integer add(Stream<Attribute> attrs);  }