@Test public void testConstrainResponse_ResourceEntity_Id() { AgEntity<Tr> entity = metadata.getAgEntity(Tr.class); Constraint<Tr> constraint1 = Constraint.excludeAll(Tr.class).excludeId(); Constraint<Tr> constraint2 = Constraint.excludeAll(Tr.class).includeId(); ResourceEntity<Tr> e1 = new RootResourceEntity<>(entity, null); e1.includeId(); constraintsHandler.constrainResponse(e1, null, constraint1); assertFalse(e1.isIdIncluded()); ResourceEntity<Tr> e2 = new RootResourceEntity<>(entity, null); e2.includeId(); constraintsHandler.constrainResponse(e2, null, constraint2); assertTrue(e2.isIdIncluded()); ResourceEntity<Tr> e3 = new RootResourceEntity<>(entity, null); e3.excludeId(); constraintsHandler.constrainResponse(e3, null, constraint2); assertFalse(e3.isIdIncluded()); }
@Override public <T> void constrainResponse(ResourceEntity<T> entity, SizeConstraints sizeConstraints, Constraint<T> c) { if (sizeConstraints != null) { applySizeConstraintsForRead(entity, sizeConstraints); } if (!treeConstraintsHandler.constrainResponse(entity, c)) { entityConstraintHandler.constrainResponse(entity); } }
ConstraintsHandler implements IConstraintsHandler { @Override public <T> void constrainResponse(ResourceEntity<T> entity, SizeConstraints sizeConstraints, Constraint<T> c) { if (sizeConstraints != null) { applySizeConstraintsForRead(entity, sizeConstraints); } if (!treeConstraintsHandler.constrainResponse(entity, c)) { entityConstraintHandler.constrainResponse(entity); } } }
ConstraintsHandler implements IConstraintsHandler { @Override public <T> void constrainResponse(ResourceEntity<T> entity, SizeConstraints sizeConstraints, Constraint<T> c) { if (sizeConstraints != null) { applySizeConstraintsForRead(entity, sizeConstraints); } if (!treeConstraintsHandler.constrainResponse(entity, c)) { entityConstraintHandler.constrainResponse(entity); } } ConstraintsHandler(
            @Inject(DEFAULT_READ_CONSTRAINTS_LIST) List<EntityConstraint> readConstraints,
            @Inject(DEFAULT_WRITE_CONSTRAINTS_LIST) List<EntityConstraint> writeConstraints
    ); }
ConstraintsHandler implements IConstraintsHandler { @Override public <T> void constrainResponse(ResourceEntity<T> entity, SizeConstraints sizeConstraints, Constraint<T> c) { if (sizeConstraints != null) { applySizeConstraintsForRead(entity, sizeConstraints); } if (!treeConstraintsHandler.constrainResponse(entity, c)) { entityConstraintHandler.constrainResponse(entity); } } ConstraintsHandler(
            @Inject(DEFAULT_READ_CONSTRAINTS_LIST) List<EntityConstraint> readConstraints,
            @Inject(DEFAULT_WRITE_CONSTRAINTS_LIST) List<EntityConstraint> writeConstraints
    ); @Override void constrainUpdate(UpdateContext<T> context, Constraint<T> c); @Override void constrainResponse(ResourceEntity<T> entity, SizeConstraints sizeConstraints, Constraint<T> c); }
ConstraintsHandler implements IConstraintsHandler { @Override public <T> void constrainResponse(ResourceEntity<T> entity, SizeConstraints sizeConstraints, Constraint<T> c) { if (sizeConstraints != null) { applySizeConstraintsForRead(entity, sizeConstraints); } if (!treeConstraintsHandler.constrainResponse(entity, c)) { entityConstraintHandler.constrainResponse(entity); } } ConstraintsHandler(
            @Inject(DEFAULT_READ_CONSTRAINTS_LIST) List<EntityConstraint> readConstraints,
            @Inject(DEFAULT_WRITE_CONSTRAINTS_LIST) List<EntityConstraint> writeConstraints
    ); @Override void constrainUpdate(UpdateContext<T> context, Constraint<T> c); @Override void constrainResponse(ResourceEntity<T> entity, SizeConstraints sizeConstraints, Constraint<T> c); static final String DEFAULT_READ_CONSTRAINTS_LIST; static final String DEFAULT_WRITE_CONSTRAINTS_LIST; }