use of org.contextmapper.servicecutter.dsl.serviceCutterConfigurationDSL.SharedOwnerGroup in project context-mapper-dsl by ContextMapper.
the class UserRepresentationsBuilderTest method canGenerateSharedOwnerGroupsFromCML.
@Test
public void canGenerateSharedOwnerGroupsFromCML() throws IOException {
// given
ContextMappingModel inputModel = getOriginalResourceOfTestCML("user-representations-builder-test-3.cml").getContextMappingModel();
// when
UserRepresentationsBuilder builder = new UserRepresentationsBuilder(inputModel);
ServiceCutterUserRepresentationsModel scModel = builder.build();
// then
assertEquals(1, scModel.getSharedOwnerGroups().size());
SharedOwnerGroup ownerGroup = scModel.getSharedOwnerGroups().get(0);
assertEquals("TeamA", ownerGroup.getName());
assertEquals(1, ownerGroup.getNanoentities().size());
assertEquals("TestEntity.attribute1", ownerGroup.getNanoentities().get(0));
}
use of org.contextmapper.servicecutter.dsl.serviceCutterConfigurationDSL.SharedOwnerGroup in project context-mapper-dsl by ContextMapper.
the class UserRepresentationsBuilder method buildSharedOwnerGroups.
private void buildSharedOwnerGroups() {
model.getSharedOwnerGroups().clear();
List<Aggregate> allAggregatesWithOwner = resolvingHelper.resolveAllAggregates().stream().filter(agg -> agg.getOwner() != null).collect(Collectors.toList());
if (allAggregatesWithOwner.isEmpty())
return;
Map<String, Set<String>> nanoentitiesPerOwner = Maps.newHashMap();
for (Aggregate aggregate : allAggregatesWithOwner) {
if (!nanoentitiesPerOwner.containsKey(aggregate.getOwner().getName()))
nanoentitiesPerOwner.put(aggregate.getOwner().getName(), Sets.newHashSet());
nanoentitiesPerOwner.get(aggregate.getOwner().getName()).addAll(nanoentityResolver.getAllNanoentities(aggregate));
}
for (Entry<String, Set<String>> entry : nanoentitiesPerOwner.entrySet()) {
SharedOwnerGroup ownerGroup = factory.createSharedOwnerGroup();
ownerGroup.setName(entry.getKey());
ownerGroup.getNanoentities().addAll(entry.getValue());
model.getSharedOwnerGroups().add(ownerGroup);
}
if (!model.getSharedOwnerGroups().isEmpty())
model.getSharedOwnerGroups().get(0).setDoc("/* These shared owner groups are generated from the CML model. Note that they are overwritten each time you use the service cut generator! */");
}
use of org.contextmapper.servicecutter.dsl.serviceCutterConfigurationDSL.SharedOwnerGroup in project context-mapper-dsl by ContextMapper.
the class UserRepresentationsExampleFactory method createSampleSharedOwnerGroups.
private List<SharedOwnerGroup> createSampleSharedOwnerGroups() {
List<SharedOwnerGroup> sharedOwnerGroups = Lists.newArrayList();
if (allModelAttributes.size() > 0) {
SharedOwnerGroup exampleSharedOwnerGroup = factory.createSharedOwnerGroup();
exampleSharedOwnerGroup.setName("SharedOwnerGroupTemplate");
exampleSharedOwnerGroup.setDoc("/* Shared Owner Groups 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. */");
exampleSharedOwnerGroup.getNanoentities().add(randomlyPickAttribute(allModelAttributes));
exampleSharedOwnerGroup.getNanoentities().add(randomlyPickAttribute(allModelAttributes));
sharedOwnerGroups.add(exampleSharedOwnerGroup);
}
return sharedOwnerGroups;
}
Aggregations