use of org.contextmapper.servicecutter.dsl.serviceCutterConfigurationDSL.SeparatedSecurityZone in project context-mapper-dsl by ContextMapper.
the class UserRepresentationsBuilder method buildSeparatedSecurityZones.
private void buildSeparatedSecurityZones() {
model.getSeparatedSecurityZones().clear();
List<Aggregate> allAggregatesWithSecurityZone = resolvingHelper.resolveAllAggregates().stream().filter(agg -> agg.getSecurityZone() != null && !"".equals(agg.getSecurityZone())).collect(Collectors.toList());
Map<String, List<Aggregate>> aggregatesPerSecurityZone = allAggregatesWithSecurityZone.stream().collect(Collectors.groupingBy(Aggregate::getSecurityZone));
for (Entry<String, List<Aggregate>> entry : aggregatesPerSecurityZone.entrySet()) {
SeparatedSecurityZone separatedSecurityZone = factory.createSeparatedSecurityZone();
separatedSecurityZone.setName(entry.getKey());
for (Aggregate aggregate : entry.getValue()) separatedSecurityZone.getNanoentities().addAll(nanoentityResolver.getAllNanoentities(aggregate));
model.getSeparatedSecurityZones().add(separatedSecurityZone);
}
}
use of org.contextmapper.servicecutter.dsl.serviceCutterConfigurationDSL.SeparatedSecurityZone in project context-mapper-dsl by ContextMapper.
the class UserRepresentationsBuilderTest method canGenerateSeparatedSecurityZonesFromCML.
@Test
public void canGenerateSeparatedSecurityZonesFromCML() throws IOException {
// given
ContextMappingModel inputModel = getOriginalResourceOfTestCML("user-representations-builder-test-10.cml").getContextMappingModel();
// when
UserRepresentationsBuilder builder = new UserRepresentationsBuilder(inputModel);
ServiceCutterUserRepresentationsModel scModel = builder.build();
// then
assertEquals(2, scModel.getSeparatedSecurityZones().size());
SeparatedSecurityZone zoneA = scModel.getSeparatedSecurityZones().stream().filter(s -> s.getName().equals("ZoneA")).findFirst().get();
SeparatedSecurityZone zoneB = scModel.getSeparatedSecurityZones().stream().filter(s -> s.getName().equals("ZoneB")).findFirst().get();
assertNotNull(zoneA);
assertNotNull(zoneB);
assertEquals(2, zoneA.getNanoentities().size());
assertEquals(1, zoneB.getNanoentities().size());
assertTrue(zoneA.getNanoentities().contains("Customer.firstName"));
assertTrue(zoneA.getNanoentities().contains("Contract.contractId"));
assertTrue(zoneB.getNanoentities().contains("TestEntity.attribute1"));
}
use of org.contextmapper.servicecutter.dsl.serviceCutterConfigurationDSL.SeparatedSecurityZone in project context-mapper-dsl by ContextMapper.
the class UserRepresentationsExampleFactory method createSampleSeparatedSecurityZones.
private List<SeparatedSecurityZone> createSampleSeparatedSecurityZones() {
List<SeparatedSecurityZone> separatedSecurityZones = Lists.newArrayList();
if (allModelAttributes.size() > 0) {
SeparatedSecurityZone exampleSeparatedSecurityZone = factory.createSeparatedSecurityZone();
exampleSeparatedSecurityZone.setName("SeparatedSecurityZoneTemplate");
exampleSeparatedSecurityZone.setDoc("/* Separated Security Zones cannot be derived from ContextMap. \n " + "* This is a template/example how you can define them. If you do not want to specify any, remove this block. */");
exampleSeparatedSecurityZone.getNanoentities().add(randomlyPickAttribute(allModelAttributes));
exampleSeparatedSecurityZone.getNanoentities().add(randomlyPickAttribute(allModelAttributes));
separatedSecurityZones.add(exampleSeparatedSecurityZone);
}
return separatedSecurityZones;
}
Aggregations