@Test public void testConstrainResponse_MapById_Included() { AgEntity<Tr> entityTr = metadata.getAgEntity(Tr.class); AgEntity<Ts> entityTs = metadata.getAgEntity(Ts.class); Constraint<Tr> constraint = Constraint .excludeAll(Tr.class) .path("rts", Constraint.excludeAll(Ts.class).includeId()); ResourceEntity<Tr> te1MapBy = new RootResourceEntity<>(entityTr, null); NestedResourceEntity<Ts> te1MapByTarget = new NestedResourceEntity<>(entityTs, null, te1MapBy, entityTr.getRelationship("rts")); te1MapByTarget.includeId(); te1MapBy.getChildren().put("rts", te1MapByTarget); ResourceEntity<Tr> te1 = new RootResourceEntity<>(entityTr, null); te1.mapBy(te1MapBy, "rts"); constraintsHandler.constrainResponse(te1, null, constraint); assertSame(te1MapBy, te1.getMapBy()); assertEquals("rts", te1.getMapByPath()); }
@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; }