コード例 #1
0
  @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));
  }
コード例 #2
0
  @Test
  public void testGenerateHasManyDomain() {
    Domain dom = MVCoreFactoryImpl.eINSTANCE.createDomain();
    dom.setName("Person");

    MVCore.Reference ref = MVCoreFactoryImpl.eINSTANCE.createReference();
    ref.setName("ref");
    ref.setSrc(dom);
    ref.setTarget(dom);
    ref.setLowerBound(0);
    ref.setUpperBound(-1);
    dom.getReferences().add(ref);

    GrailsGenerator gen = new GrailsGenerator();

    String s = gen.buildEDomainClass(dom, "test");
    System.out.println(s);

    assertTrue(s.contains("static hasMany = [ref:Person]"));
  }