Search in sources :

Example 1 with UseCase

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());
}
Also used : ContextMappingModel(org.contextmapper.dsl.contextMappingDSL.ContextMappingModel) UserRepresentationsBuilder(org.contextmapper.dsl.generator.servicecutter.input.userrepresentations.UserRepresentationsBuilder) ServiceCutterUserRepresentationsModel(org.contextmapper.servicecutter.dsl.serviceCutterConfigurationDSL.ServiceCutterUserRepresentationsModel) UseCase(org.contextmapper.servicecutter.dsl.serviceCutterConfigurationDSL.UseCase) AbstractCMLInputFileTest(org.contextmapper.dsl.AbstractCMLInputFileTest) Test(org.junit.jupiter.api.Test)

Example 2 with UseCase

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;
}
Also used : DomainObject(org.contextmapper.tactic.dsl.tacticdsl.DomainObject) UseCase(org.contextmapper.servicecutter.dsl.serviceCutterConfigurationDSL.UseCase)

Example 3 with UseCase

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;
}
Also used : UseCase(org.contextmapper.servicecutter.dsl.serviceCutterConfigurationDSL.UseCase)

Example 4 with UseCase

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);
    }
}
Also used : UserRequirement(org.contextmapper.dsl.contextMappingDSL.UserRequirement) UseCase(org.contextmapper.servicecutter.dsl.serviceCutterConfigurationDSL.UseCase)

Example 5 with UseCase

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;
}
Also used : ServiceCutterUserRepresentationsModel(org.contextmapper.servicecutter.dsl.serviceCutterConfigurationDSL.ServiceCutterUserRepresentationsModel) UseCase(org.contextmapper.servicecutter.dsl.serviceCutterConfigurationDSL.UseCase)

Aggregations

UseCase (org.contextmapper.servicecutter.dsl.serviceCutterConfigurationDSL.UseCase)5 ServiceCutterUserRepresentationsModel (org.contextmapper.servicecutter.dsl.serviceCutterConfigurationDSL.ServiceCutterUserRepresentationsModel)2 AbstractCMLInputFileTest (org.contextmapper.dsl.AbstractCMLInputFileTest)1 ContextMappingModel (org.contextmapper.dsl.contextMappingDSL.ContextMappingModel)1 UserRequirement (org.contextmapper.dsl.contextMappingDSL.UserRequirement)1 UserRepresentationsBuilder (org.contextmapper.dsl.generator.servicecutter.input.userrepresentations.UserRepresentationsBuilder)1 DomainObject (org.contextmapper.tactic.dsl.tacticdsl.DomainObject)1 Test (org.junit.jupiter.api.Test)1