Search in sources :

Example 1 with UserRepresentationsBuilder

use of org.contextmapper.dsl.generator.servicecutter.input.userrepresentations.UserRepresentationsBuilder in project context-mapper-dsl by ContextMapper.

the class UserRepresentationsBuilderTest method canGenerateConsistencyCriticalityCompatibilitiesFromCML.

@Test
public void canGenerateConsistencyCriticalityCompatibilitiesFromCML() throws IOException {
    // given
    ContextMappingModel inputModel = getOriginalResourceOfTestCML("user-representations-builder-test-7.cml").getContextMappingModel();
    // when
    ServiceCutterUserRepresentationsModel scModel = new UserRepresentationsBuilder(inputModel).build();
    // then
    assertNotNull(scModel.getCompatibilities());
    Compatibilities compatibilities = scModel.getCompatibilities();
    assertFalse(compatibilities.getConsistencyCriticality().isEmpty());
    assertEquals(3, compatibilities.getConsistencyCriticality().size());
    ConsistencyCriticality normal = compatibilities.getConsistencyCriticality().stream().filter(sv -> sv.getCharacteristic().equals("Eventually")).findFirst().get();
    ConsistencyCriticality high = compatibilities.getConsistencyCriticality().stream().filter(sv -> sv.getCharacteristic().equals("High")).findFirst().get();
    ConsistencyCriticality low = compatibilities.getConsistencyCriticality().stream().filter(sv -> sv.getCharacteristic().equals("Weak")).findFirst().get();
    assertNotNull(normal);
    assertNotNull(high);
    assertNotNull(low);
    assertTrue(normal.getNanoentities().contains("Customer.testAttr1"));
    assertTrue(high.getNanoentities().contains("Customer.testAttr2"));
    assertTrue(low.getNanoentities().contains("Customer.testAttr3"));
}
Also used : ContextMappingModel(org.contextmapper.dsl.contextMappingDSL.ContextMappingModel) UserRepresentationsBuilder(org.contextmapper.dsl.generator.servicecutter.input.userrepresentations.UserRepresentationsBuilder) ServiceCutterUserRepresentationsModel(org.contextmapper.servicecutter.dsl.serviceCutterConfigurationDSL.ServiceCutterUserRepresentationsModel) ConsistencyCriticality(org.contextmapper.servicecutter.dsl.serviceCutterConfigurationDSL.ConsistencyCriticality) Compatibilities(org.contextmapper.servicecutter.dsl.serviceCutterConfigurationDSL.Compatibilities) AbstractCMLInputFileTest(org.contextmapper.dsl.AbstractCMLInputFileTest) Test(org.junit.jupiter.api.Test)

Example 2 with UserRepresentationsBuilder

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

Example 3 with UserRepresentationsBuilder

use of org.contextmapper.dsl.generator.servicecutter.input.userrepresentations.UserRepresentationsBuilder 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 4 with UserRepresentationsBuilder

use of org.contextmapper.dsl.generator.servicecutter.input.userrepresentations.UserRepresentationsBuilder in project context-mapper-dsl by ContextMapper.

the class UserRepresentationsBuilderTest method canGeneratePredefinedServicesFromCML.

@Test
public void canGeneratePredefinedServicesFromCML() throws IOException {
    // given
    ContextMappingModel inputModel = getOriginalResourceOfTestCML("user-representations-builder-test-2.cml").getContextMappingModel();
    // when
    UserRepresentationsBuilder builder = new UserRepresentationsBuilder(inputModel);
    ServiceCutterUserRepresentationsModel scModel = builder.build();
    // then
    assertEquals(1, scModel.getPredefinedServices().size());
    PredefinedService predefinedService = scModel.getPredefinedServices().get(0);
    assertEquals("TestContext", predefinedService.getName());
    assertEquals(2, predefinedService.getNanoentities().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) PredefinedService(org.contextmapper.servicecutter.dsl.serviceCutterConfigurationDSL.PredefinedService) AbstractCMLInputFileTest(org.contextmapper.dsl.AbstractCMLInputFileTest) Test(org.junit.jupiter.api.Test)

Example 5 with UserRepresentationsBuilder

use of org.contextmapper.dsl.generator.servicecutter.input.userrepresentations.UserRepresentationsBuilder in project context-mapper-dsl by ContextMapper.

the class UserRepresentationsBuilderTest method canGenerateContentVolatilityCompatibilitiesFromCML.

@Test
public void canGenerateContentVolatilityCompatibilitiesFromCML() throws IOException {
    // given
    ContextMappingModel inputModel = getOriginalResourceOfTestCML("user-representations-builder-test-5.cml").getContextMappingModel();
    // when
    ServiceCutterUserRepresentationsModel scModel = new UserRepresentationsBuilder(inputModel).build();
    // then
    assertNotNull(scModel.getCompatibilities());
    Compatibilities compatibilities = scModel.getCompatibilities();
    assertFalse(compatibilities.getContentVolatility().isEmpty());
    assertEquals(3, compatibilities.getContentVolatility().size());
    ContentVolatility normal = compatibilities.getContentVolatility().stream().filter(sv -> sv.getCharacteristic().equals("Regularly")).findFirst().get();
    ContentVolatility often = compatibilities.getContentVolatility().stream().filter(sv -> sv.getCharacteristic().equals("Often")).findFirst().get();
    ContentVolatility rarely = compatibilities.getContentVolatility().stream().filter(sv -> sv.getCharacteristic().equals("Rarely")).findFirst().get();
    assertNotNull(normal);
    assertNotNull(often);
    assertNotNull(rarely);
    assertTrue(normal.getNanoentities().contains("Customer.testAttr1"));
    assertTrue(often.getNanoentities().contains("Customer.testAttr2"));
    assertTrue(rarely.getNanoentities().contains("Customer.testAttr3"));
}
Also used : ContextMappingModel(org.contextmapper.dsl.contextMappingDSL.ContextMappingModel) UserRepresentationsBuilder(org.contextmapper.dsl.generator.servicecutter.input.userrepresentations.UserRepresentationsBuilder) ServiceCutterUserRepresentationsModel(org.contextmapper.servicecutter.dsl.serviceCutterConfigurationDSL.ServiceCutterUserRepresentationsModel) Compatibilities(org.contextmapper.servicecutter.dsl.serviceCutterConfigurationDSL.Compatibilities) ContentVolatility(org.contextmapper.servicecutter.dsl.serviceCutterConfigurationDSL.ContentVolatility) AbstractCMLInputFileTest(org.contextmapper.dsl.AbstractCMLInputFileTest) Test(org.junit.jupiter.api.Test)

Aggregations

UserRepresentationsBuilder (org.contextmapper.dsl.generator.servicecutter.input.userrepresentations.UserRepresentationsBuilder)14 ServiceCutterUserRepresentationsModel (org.contextmapper.servicecutter.dsl.serviceCutterConfigurationDSL.ServiceCutterUserRepresentationsModel)14 AbstractCMLInputFileTest (org.contextmapper.dsl.AbstractCMLInputFileTest)13 ContextMappingModel (org.contextmapper.dsl.contextMappingDSL.ContextMappingModel)13 Test (org.junit.jupiter.api.Test)13 Compatibilities (org.contextmapper.servicecutter.dsl.serviceCutterConfigurationDSL.Compatibilities)6 IOException (java.io.IOException)1 ContextMapperApplicationException (org.contextmapper.dsl.exception.ContextMapperApplicationException)1 Aggregate (org.contextmapper.servicecutter.dsl.serviceCutterConfigurationDSL.Aggregate)1 AvailabilityCriticality (org.contextmapper.servicecutter.dsl.serviceCutterConfigurationDSL.AvailabilityCriticality)1 ConsistencyCriticality (org.contextmapper.servicecutter.dsl.serviceCutterConfigurationDSL.ConsistencyCriticality)1 ContentVolatility (org.contextmapper.servicecutter.dsl.serviceCutterConfigurationDSL.ContentVolatility)1 PredefinedService (org.contextmapper.servicecutter.dsl.serviceCutterConfigurationDSL.PredefinedService)1 SecurityAccessGroup (org.contextmapper.servicecutter.dsl.serviceCutterConfigurationDSL.SecurityAccessGroup)1 SecurityCriticality (org.contextmapper.servicecutter.dsl.serviceCutterConfigurationDSL.SecurityCriticality)1 SeparatedSecurityZone (org.contextmapper.servicecutter.dsl.serviceCutterConfigurationDSL.SeparatedSecurityZone)1 SharedOwnerGroup (org.contextmapper.servicecutter.dsl.serviceCutterConfigurationDSL.SharedOwnerGroup)1 StorageSimilarity (org.contextmapper.servicecutter.dsl.serviceCutterConfigurationDSL.StorageSimilarity)1 StructuralVolatility (org.contextmapper.servicecutter.dsl.serviceCutterConfigurationDSL.StructuralVolatility)1 UseCase (org.contextmapper.servicecutter.dsl.serviceCutterConfigurationDSL.UseCase)1