Search in sources :

Example 1 with Compatibilities

use of org.contextmapper.servicecutter.dsl.serviceCutterConfigurationDSL.Compatibilities 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 Compatibilities

use of org.contextmapper.servicecutter.dsl.serviceCutterConfigurationDSL.Compatibilities 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)

Example 3 with Compatibilities

use of org.contextmapper.servicecutter.dsl.serviceCutterConfigurationDSL.Compatibilities in project context-mapper-dsl by ContextMapper.

the class UserRepresentationsBuilderTest method canGenerateStorageSimilarityCompatibilitiesFromCML.

@Test
public void canGenerateStorageSimilarityCompatibilitiesFromCML() throws IOException {
    // given
    ContextMappingModel inputModel = getOriginalResourceOfTestCML("user-representations-builder-test-8.cml").getContextMappingModel();
    // when
    ServiceCutterUserRepresentationsModel scModel = new UserRepresentationsBuilder(inputModel).build();
    // then
    assertNotNull(scModel.getCompatibilities());
    Compatibilities compatibilities = scModel.getCompatibilities();
    assertFalse(compatibilities.getStorageSimilarity().isEmpty());
    assertEquals(3, compatibilities.getStorageSimilarity().size());
    StorageSimilarity normal = compatibilities.getStorageSimilarity().stream().filter(sv -> sv.getCharacteristic().equals("Normal")).findFirst().get();
    StorageSimilarity high = compatibilities.getStorageSimilarity().stream().filter(sv -> sv.getCharacteristic().equals("Huge")).findFirst().get();
    StorageSimilarity low = compatibilities.getStorageSimilarity().stream().filter(sv -> sv.getCharacteristic().equals("Tiny")).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) Compatibilities(org.contextmapper.servicecutter.dsl.serviceCutterConfigurationDSL.Compatibilities) StorageSimilarity(org.contextmapper.servicecutter.dsl.serviceCutterConfigurationDSL.StorageSimilarity) AbstractCMLInputFileTest(org.contextmapper.dsl.AbstractCMLInputFileTest) Test(org.junit.jupiter.api.Test)

Example 4 with Compatibilities

use of org.contextmapper.servicecutter.dsl.serviceCutterConfigurationDSL.Compatibilities in project context-mapper-dsl by ContextMapper.

the class UserRepresentationsBuilderTest method canGenerateAvailabilityCriticalityCompatibilitiesFromCML.

@Test
public void canGenerateAvailabilityCriticalityCompatibilitiesFromCML() throws IOException {
    // given
    ContextMappingModel inputModel = getOriginalResourceOfTestCML("user-representations-builder-test-6.cml").getContextMappingModel();
    // when
    ServiceCutterUserRepresentationsModel scModel = new UserRepresentationsBuilder(inputModel).build();
    // then
    assertNotNull(scModel.getCompatibilities());
    Compatibilities compatibilities = scModel.getCompatibilities();
    assertFalse(compatibilities.getAvailabilityCriticality().isEmpty());
    assertEquals(3, compatibilities.getAvailabilityCriticality().size());
    AvailabilityCriticality normal = compatibilities.getAvailabilityCriticality().stream().filter(sv -> sv.getCharacteristic().equals("Normal")).findFirst().get();
    AvailabilityCriticality high = compatibilities.getAvailabilityCriticality().stream().filter(sv -> sv.getCharacteristic().equals("Critical")).findFirst().get();
    AvailabilityCriticality low = compatibilities.getAvailabilityCriticality().stream().filter(sv -> sv.getCharacteristic().equals("Low")).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) AvailabilityCriticality(org.contextmapper.servicecutter.dsl.serviceCutterConfigurationDSL.AvailabilityCriticality) ServiceCutterUserRepresentationsModel(org.contextmapper.servicecutter.dsl.serviceCutterConfigurationDSL.ServiceCutterUserRepresentationsModel) Compatibilities(org.contextmapper.servicecutter.dsl.serviceCutterConfigurationDSL.Compatibilities) AbstractCMLInputFileTest(org.contextmapper.dsl.AbstractCMLInputFileTest) Test(org.junit.jupiter.api.Test)

Example 5 with Compatibilities

use of org.contextmapper.servicecutter.dsl.serviceCutterConfigurationDSL.Compatibilities in project context-mapper-dsl by ContextMapper.

the class UserRepresentationsExampleFactory method createSampleCompatibilities.

private Compatibilities createSampleCompatibilities() {
    Compatibilities compatibilities = factory.createCompatibilities();
    compatibilities.setDoc("/* Compatibilities can be used to import all coupling criteria of type Compatability.\n" + " * https://github.com/ServiceCutter/ServiceCutter/wiki/Compatibilities\n" + " * The following compatibilities are just examples to provide you a template! You have to specify or remove them. " + " */");
    // difficult to create examples, if there are no attributes in the model
    if (allModelAttributes.size() <= 0)
        return compatibilities;
    ContentVolatility exampleContentVolatility = factory.createContentVolatility();
    exampleContentVolatility.setDoc("/* See: https://github.com/ServiceCutter/ServiceCutter/wiki/CC-8-Content-Volatility */");
    exampleContentVolatility.setCharacteristic("Often");
    exampleContentVolatility.setCharacteristicDoc("// Allowed characteristics: Often, Regularly, Rarely");
    exampleContentVolatility.getNanoentities().add(randomlyPickAttribute(allModelAttributes));
    exampleContentVolatility.getNanoentities().add(randomlyPickAttribute(allModelAttributes));
    compatibilities.getContentVolatility().add(exampleContentVolatility);
    StructuralVolatility exampleStructuralVolatility = factory.createStructuralVolatility();
    exampleStructuralVolatility.setDoc("/* See: https://github.com/ServiceCutter/ServiceCutter/wiki/CC-4-Structural-Volatility */");
    exampleStructuralVolatility.setCharacteristic("Normal");
    exampleStructuralVolatility.setCharacteristicDoc("// Allowed characteristics: Often, Normal, Rarely");
    exampleStructuralVolatility.getNanoentities().add(randomlyPickAttribute(allModelAttributes));
    exampleStructuralVolatility.getNanoentities().add(randomlyPickAttribute(allModelAttributes));
    compatibilities.getStructuralVolatility().add(exampleStructuralVolatility);
    AvailabilityCriticality exampleAvailabilityCriticality = factory.createAvailabilityCriticality();
    exampleAvailabilityCriticality.setDoc("/* See: https://github.com/ServiceCutter/ServiceCutter/wiki/CC-7-Availability-Criticality */");
    exampleAvailabilityCriticality.setCharacteristic("Normal");
    exampleAvailabilityCriticality.setCharacteristicDoc("// Allowed characteristics: Critical, Normal, Low");
    exampleAvailabilityCriticality.getNanoentities().add(randomlyPickAttribute(allModelAttributes));
    exampleAvailabilityCriticality.getNanoentities().add(randomlyPickAttribute(allModelAttributes));
    compatibilities.getAvailabilityCriticality().add(exampleAvailabilityCriticality);
    ConsistencyCriticality exampleConsistencyCriticality = factory.createConsistencyCriticality();
    exampleConsistencyCriticality.setDoc("/* See: https://github.com/ServiceCutter/ServiceCutter/wiki/CC-6-Consistency-Criticality */");
    exampleConsistencyCriticality.setCharacteristic("Eventually");
    exampleConsistencyCriticality.setCharacteristicDoc("// Allowed characteristics: High, Eventually, Weak");
    exampleConsistencyCriticality.getNanoentities().add(randomlyPickAttribute(allModelAttributes));
    exampleConsistencyCriticality.getNanoentities().add(randomlyPickAttribute(allModelAttributes));
    compatibilities.getConsistencyCriticality().add(exampleConsistencyCriticality);
    StorageSimilarity exampleStorageSimilarity = factory.createStorageSimilarity();
    exampleStorageSimilarity.setDoc("/* See: https://github.com/ServiceCutter/ServiceCutter/wiki/CC-11-Storage-Similarity */");
    exampleStorageSimilarity.setCharacteristic("Normal");
    exampleStorageSimilarity.setCharacteristicDoc("// Allowed characteristics: Tiny, Normal, Huge");
    exampleStorageSimilarity.getNanoentities().add(randomlyPickAttribute(allModelAttributes));
    exampleStorageSimilarity.getNanoentities().add(randomlyPickAttribute(allModelAttributes));
    compatibilities.getStorageSimilarity().add(exampleStorageSimilarity);
    SecurityCriticality exampleSecurityCriticality = factory.createSecurityCriticality();
    exampleSecurityCriticality.setDoc("/* See: https://github.com/ServiceCutter/ServiceCutter/wiki/CC-15-Security-Criticality */");
    exampleSecurityCriticality.setCharacteristic("Internal");
    exampleSecurityCriticality.setCharacteristicDoc("// Allowed characteristics: Critical, Internal, Public");
    exampleSecurityCriticality.getNanoentities().add(randomlyPickAttribute(allModelAttributes));
    exampleSecurityCriticality.getNanoentities().add(randomlyPickAttribute(allModelAttributes));
    compatibilities.getSecurityCriticality().add(exampleSecurityCriticality);
    return compatibilities;
}
Also used : AvailabilityCriticality(org.contextmapper.servicecutter.dsl.serviceCutterConfigurationDSL.AvailabilityCriticality) ConsistencyCriticality(org.contextmapper.servicecutter.dsl.serviceCutterConfigurationDSL.ConsistencyCriticality) SecurityCriticality(org.contextmapper.servicecutter.dsl.serviceCutterConfigurationDSL.SecurityCriticality) Compatibilities(org.contextmapper.servicecutter.dsl.serviceCutterConfigurationDSL.Compatibilities) ContentVolatility(org.contextmapper.servicecutter.dsl.serviceCutterConfigurationDSL.ContentVolatility) StorageSimilarity(org.contextmapper.servicecutter.dsl.serviceCutterConfigurationDSL.StorageSimilarity) StructuralVolatility(org.contextmapper.servicecutter.dsl.serviceCutterConfigurationDSL.StructuralVolatility)

Aggregations

Compatibilities (org.contextmapper.servicecutter.dsl.serviceCutterConfigurationDSL.Compatibilities)8 AbstractCMLInputFileTest (org.contextmapper.dsl.AbstractCMLInputFileTest)6 ContextMappingModel (org.contextmapper.dsl.contextMappingDSL.ContextMappingModel)6 UserRepresentationsBuilder (org.contextmapper.dsl.generator.servicecutter.input.userrepresentations.UserRepresentationsBuilder)6 ServiceCutterUserRepresentationsModel (org.contextmapper.servicecutter.dsl.serviceCutterConfigurationDSL.ServiceCutterUserRepresentationsModel)6 Test (org.junit.jupiter.api.Test)6 AvailabilityCriticality (org.contextmapper.servicecutter.dsl.serviceCutterConfigurationDSL.AvailabilityCriticality)2 ConsistencyCriticality (org.contextmapper.servicecutter.dsl.serviceCutterConfigurationDSL.ConsistencyCriticality)2 ContentVolatility (org.contextmapper.servicecutter.dsl.serviceCutterConfigurationDSL.ContentVolatility)2 SecurityCriticality (org.contextmapper.servicecutter.dsl.serviceCutterConfigurationDSL.SecurityCriticality)2 StorageSimilarity (org.contextmapper.servicecutter.dsl.serviceCutterConfigurationDSL.StorageSimilarity)2 StructuralVolatility (org.contextmapper.servicecutter.dsl.serviceCutterConfigurationDSL.StructuralVolatility)2