use of org.contextmapper.servicecutter.dsl.serviceCutterConfigurationDSL.UseCase in project context-mapper-dsl by ContextMapper.
the class UserRepresentationsBuilderTest method canGenerateUseCasesFromCML.
@Test
public void canGenerateUseCasesFromCML() throws IOException {
// given
ContextMappingModel inputModel = getOriginalResourceOfTestCML("user-representations-builder-test-1.cml").getContextMappingModel();
// when
UserRepresentationsBuilder builder = new UserRepresentationsBuilder(inputModel);
ServiceCutterUserRepresentationsModel scModel = builder.build();
// then
assertEquals(1, scModel.getUseCases().size());
UseCase useCase = scModel.getUseCases().get(0);
assertEquals(10, useCase.getNanoentitiesRead().size());
assertEquals(10, useCase.getNanoentitiesWritten().size());
}
use of org.contextmapper.servicecutter.dsl.serviceCutterConfigurationDSL.UseCase in project context-mapper-dsl by ContextMapper.
the class UserRepresentationsExampleFactory method createSampleUseCases.
private List<UseCase> createSampleUseCases() {
List<UseCase> useCases = Lists.newArrayList();
List<DomainObject> domainObjects = collectDomainObjects();
for (DomainObject domainObject : domainObjects) {
if (useCases.size() >= MAX_ENTITY_USECASE_EXAMPLES)
break;
useCases.addAll(createEntityUseCases(domainObject));
}
return useCases;
}
use of org.contextmapper.servicecutter.dsl.serviceCutterConfigurationDSL.UseCase in project context-mapper-dsl by ContextMapper.
the class UserRepresentationsExampleFactory method createEntityUseCases.
private List<UseCase> createEntityUseCases(DomainObject domainObject) {
List<UseCase> useCases = Lists.newArrayList();
// READ use case example
UseCase viewUseCase = factory.createUseCase();
viewUseCase.setName("View" + domainObject.getName());
viewUseCase.getNanoentitiesRead().addAll(collectNanoEntities(domainObject));
useCases.add(viewUseCase);
// WRITE use case example
UseCase updateUseCase = factory.createUseCase();
updateUseCase.setName("Update" + domainObject.getName());
updateUseCase.getNanoentitiesWritten().addAll(collectNanoEntities(domainObject));
useCases.add(updateUseCase);
return useCases;
}
use of org.contextmapper.servicecutter.dsl.serviceCutterConfigurationDSL.UseCase in project context-mapper-dsl by ContextMapper.
the class UserRepresentationsBuilder method buildUseCases.
private void buildUseCases() {
model.getUseCases().clear();
for (UserRequirement ur : contextMappingModel.getUserRequirements()) {
Set<String> nanoEntitiesRead = new NanoentityCollector().getNanoentitiesRead(ur);
Set<String> nanoEntitiesWritten = new NanoentityCollector().getNanoentitiesWritten(ur);
if (nanoEntitiesRead.isEmpty() && nanoEntitiesWritten.isEmpty())
continue;
// create one use case for each user requirement in CML (use case or user story
// in CML)
UseCase uc = factory.createUseCase();
uc.setName(ur.getName());
uc.getNanoentitiesRead().addAll(nanoEntitiesRead);
uc.getNanoentitiesWritten().addAll(nanoEntitiesWritten);
model.getUseCases().add(uc);
}
}
use of org.contextmapper.servicecutter.dsl.serviceCutterConfigurationDSL.UseCase in project context-mapper-dsl by ContextMapper.
the class UserRepresentationsExampleFactory method createExampleModel.
public ServiceCutterUserRepresentationsModel createExampleModel(ContextMappingModel contextMappingModel) {
ServiceCutterUserRepresentationsModel model = factory.createServiceCutterUserRepresentationsModel();
this.contextMappingModel = contextMappingModel;
this.allModelAttributes = collectAttributes(contextMappingModel);
// give the user a hint, if no data available to generate something useful
if (allModelAttributes.size() <= 0) {
UseCase dummyUseCase = factory.createUseCase();
dummyUseCase.setName("NoDataFound");
dummyUseCase.setDoc("/* Your context map should at least contain one bounded context with aggregates, entities and some attributes. \n" + " * Otherwise it is not possible to generate user representation examples. */");
model.getUseCases().add(dummyUseCase);
return model;
}
List<UseCase> useCases = createSampleUseCases();
if (useCases.size() > 0)
useCases.get(0).setDoc("/* The following usecases are just examples to give you a hint how to specify them! You may want to change or remove them. */");
model.getUseCases().addAll(useCases);
model.setCompatibilities(createSampleCompatibilities());
model.getAggregates().addAll(createSampleAggregates());
model.getEntities().addAll(createSampleEntities());
model.getPredefinedServices().addAll(createSamplePredefinedServices());
model.getSecurityAccessGroups().addAll(createSampleSecurityAccessGroups());
model.getSeparatedSecurityZones().addAll(createSampleSeparatedSecurityZones());
model.getSharedOwnerGroups().addAll(createSampleSharedOwnerGroups());
return model;
}
Aggregations