@Test public void testGenerateReferenceDomain() { Domain dom = MVCoreFactoryImpl.eINSTANCE.createDomain(); dom.setName("Person"); MVCore.Reference ref = MVCoreFactoryImpl.eINSTANCE.createReference(); ref.setName("ref"); ref.setSrc(dom); ref.setTarget(dom); ref.setUpperBound(1); dom.getReferences().add(ref); GrailsGenerator gen = new GrailsGenerator(); String s = gen.buildEDomainClass(dom, "test"); System.out.println(s); assertTrue(s.contains("Person ref")); }
@Test public void testFindMutiplicity() { MVCore.Reference ref = MVCoreFactoryImpl.eINSTANCE.createReference(); ref.setName("ref"); ref.setLowerBound(0); ref.setUpperBound(1); GrailsGenerator gen = new GrailsGenerator(); assertEquals("0-1", gen.findMultiplicity(ref)); ref.setUpperBound(-1); assertEquals("0-M", gen.findMultiplicity(ref)); ref.setLowerBound(1); ref.setUpperBound(1); assertEquals("1", gen.findMultiplicity(ref)); ref.setLowerBound(1); ref.setUpperBound(-1); assertEquals("1-M", gen.findMultiplicity(ref)); }