use of org.contextmapper.dsl.quickfixes.tactic.ExtractIDValueObjectQuickFix in project context-mapper-dsl by ContextMapper.
the class ExtractIDValueObjectQuickFixTest method canCheckThatAttributeIsContainedInDomainObject.
@Test
public void canCheckThatAttributeIsContainedInDomainObject() {
// given
Attribute attr = TacticdslFactory.eINSTANCE.createAttribute();
attr.setName("singleAttr");
// when, then
assertThrows(ContextMapperApplicationException.class, () -> {
new ExtractIDValueObjectQuickFix().applyQuickfix(attr);
});
}
use of org.contextmapper.dsl.quickfixes.tactic.ExtractIDValueObjectQuickFix in project context-mapper-dsl by ContextMapper.
the class ExtractIDValueObjectQuickFixTest method canExtractValueObjectFromPrimitiveAttributeInModule.
@Test
public void canExtractValueObjectFromPrimitiveAttributeInModule() throws IOException {
// given
CMLResource cmlResource = getResourceCopyOfTestCML("extract-vo-for-primitive-id-test-2.cml");
ContextMappingModel model = cmlResource.getContextMappingModel();
Attribute idAttr = EcoreUtil2.getAllContentsOfType(model, Attribute.class).stream().filter(a -> a.getName().equals("customerId")).findFirst().get();
// when
new ExtractIDValueObjectQuickFix().applyQuickfix(idAttr);
// then
SculptorModule module = model.getBoundedContexts().get(0).getModules().get(0);
assertEquals("TestModule", module.getName());
assertEquals(2, module.getDomainObjects().size());
Entity entity = (Entity) module.getDomainObjects().stream().filter(o -> o.getName().equals("Customer")).findFirst().get();
assertEquals(2, entity.getAttributes().size());
assertEquals(1, entity.getReferences().size());
ValueObject vo = (ValueObject) module.getDomainObjects().stream().filter(o -> o.getName().equals("CustomerId")).findFirst().get();
assertNotNull(vo);
assertEquals(1, vo.getAttributes().size());
assertEquals("id", vo.getAttributes().get(0).getName());
}
use of org.contextmapper.dsl.quickfixes.tactic.ExtractIDValueObjectQuickFix in project context-mapper-dsl by ContextMapper.
the class CMLActionRegistry method registerAllQuickFixes.
private void registerAllQuickFixes() {
// register quick fixes here:
registerActionQuickFix(DomainObjectValidator.ID_IS_PRIMITIVE_CODE, new ExtractIDValueObjectQuickFix());
registerCommandQuickFix(UserRequirementsValidator.ID_SPLIT_FEATURE_BY_VERB_SUGGESTION, new SplitStoryByVerbCommandMapper(new SplitStoryByVerb()));
registerCommandQuickFix(ApplicationFlowSemanticsValidator.SKETCH_MINER_INFO_ID, new OpenFlowInSketchMinerCommandMapper());
}
use of org.contextmapper.dsl.quickfixes.tactic.ExtractIDValueObjectQuickFix in project context-mapper-dsl by ContextMapper.
the class ExtractIDValueObjectQuickFixTest method canExtractValueObjectFromPrimitiveAttribute.
@Test
public void canExtractValueObjectFromPrimitiveAttribute() throws IOException {
// given
CMLResource cmlResource = getResourceCopyOfTestCML("extract-vo-for-primitive-id-test-1.cml");
ContextMappingModel model = cmlResource.getContextMappingModel();
Attribute idAttr = EcoreUtil2.getAllContentsOfType(model, Attribute.class).stream().filter(a -> a.getName().equals("customerId")).findFirst().get();
// when
new ExtractIDValueObjectQuickFix().applyQuickfix(idAttr);
// then
Aggregate aggregate = model.getBoundedContexts().get(0).getAggregates().get(0);
assertEquals("TestAggregate", aggregate.getName());
assertEquals(2, aggregate.getDomainObjects().size());
Entity entity = (Entity) aggregate.getDomainObjects().stream().filter(o -> o.getName().equals("Customer")).findFirst().get();
assertEquals(2, entity.getAttributes().size());
assertEquals(1, entity.getReferences().size());
ValueObject vo = (ValueObject) aggregate.getDomainObjects().stream().filter(o -> o.getName().equals("CustomerId")).findFirst().get();
assertNotNull(vo);
assertEquals(1, vo.getAttributes().size());
assertEquals("id", vo.getAttributes().get(0).getName());
}
use of org.contextmapper.dsl.quickfixes.tactic.ExtractIDValueObjectQuickFix in project context-mapper-dsl by ContextMapper.
the class ExtractIDValueObjectQuickFixTest method canProvideName.
@Test
public void canProvideName() {
// given
ExtractIDValueObjectQuickFix quickFix = new ExtractIDValueObjectQuickFix();
// when
String name = quickFix.getName();
// then
assertEquals("Extract Value Object", name);
}
Aggregations