use of org.contextmapper.servicecutter.dsl.serviceCutterConfigurationDSL.SecurityCriticality 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;
}
use of org.contextmapper.servicecutter.dsl.serviceCutterConfigurationDSL.SecurityCriticality in project context-mapper-dsl by ContextMapper.
the class CompatibilityBuilder method createSecurityCriticality.
private SecurityCriticality createSecurityCriticality(String characteristic, Set<String> nanoentities) {
SecurityCriticality securityCriticality = ServiceCutterConfigurationDSLFactory.eINSTANCE.createSecurityCriticality();
securityCriticality.setCharacteristic(characteristic);
securityCriticality.getNanoentities().addAll(nanoentities);
return securityCriticality;
}
use of org.contextmapper.servicecutter.dsl.serviceCutterConfigurationDSL.SecurityCriticality in project context-mapper-dsl by ContextMapper.
the class UserRepresentationsBuilderTest method canGenerateSecurityCriticalityCompatibilitiesFromCML.
@Test
public void canGenerateSecurityCriticalityCompatibilitiesFromCML() throws IOException {
// given
ContextMappingModel inputModel = getOriginalResourceOfTestCML("user-representations-builder-test-9.cml").getContextMappingModel();
// when
ServiceCutterUserRepresentationsModel scModel = new UserRepresentationsBuilder(inputModel).build();
// then
assertNotNull(scModel.getCompatibilities());
Compatibilities compatibilities = scModel.getCompatibilities();
assertFalse(compatibilities.getSecurityCriticality().isEmpty());
assertEquals(3, compatibilities.getSecurityCriticality().size());
SecurityCriticality normal = compatibilities.getSecurityCriticality().stream().filter(sv -> sv.getCharacteristic().equals("Internal")).findFirst().get();
SecurityCriticality high = compatibilities.getSecurityCriticality().stream().filter(sv -> sv.getCharacteristic().equals("Critical")).findFirst().get();
SecurityCriticality low = compatibilities.getSecurityCriticality().stream().filter(sv -> sv.getCharacteristic().equals("Public")).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"));
}
Aggregations