@Test public void testConstrainResponse_ResourceEntity_NoTargetRel() { AgEntity<Tr> entityTr = metadata.getAgEntity(Tr.class); AgEntity<Ts> entityTs = metadata.getAgEntity(Ts.class); Constraint<Tr> tc1 = Constraint.excludeAll(Tr.class).attributes("a", "b"); ResourceEntity<Tr> te1 = new RootResourceEntity<>(entityTr, null); ResourceEntityUtils.appendAttribute(te1, "c"); ResourceEntityUtils.appendAttribute(te1, "b"); NestedResourceEntity<Ts> te11 = new NestedResourceEntity<>(entityTs, null, te1, entityTr.getRelationship("rts")); ResourceEntityUtils.appendAttribute(te11, "a1"); ResourceEntityUtils.appendAttribute(te11, "b1"); te1.getChildren().put("d", te11); constraintsHandler.constrainResponse(te1, null, tc1); assertEquals(1, te1.getAttributes().size()); assertTrue(te1.getAttributes().containsKey("b")); assertTrue(te1.getChildren().isEmpty()); }
@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; }