예제 #1
0
  @Test
  public void testJPAEntityFieldInfoAnnotations() {
    JPAResponderGen rg = new JPAResponderGen();

    EntityMetadata mdEntity = new EntityMetadata("Flight");
    Vocabulary voc = new Vocabulary();
    voc.setTerm(new TermValueType(TermValueType.INTEGER_NUMBER));
    voc.setTerm(new TermIdField(true));
    mdEntity.setPropertyVocabulary("ID", voc);
    voc = new Vocabulary();
    voc.setTerm(new TermValueType(TermValueType.TIMESTAMP));
    mdEntity.setPropertyVocabulary("departureDT", voc);
    voc = new Vocabulary();
    voc.setTerm(new TermValueType(TermValueType.DATE));
    mdEntity.setPropertyVocabulary("departureDate", voc);
    voc = new Vocabulary();
    voc.setTerm(new TermValueType(TermValueType.TIME));
    mdEntity.setPropertyVocabulary("departureTime", voc);
    EntityInfo p = rg.createEntityInfoFromEntityMetadata("AirlineModel", mdEntity);

    // Annotations
    FieldInfo dateOnlyFI = p.getFieldInfos().get(0);
    assertEquals(1, dateOnlyFI.getAnnotations().size());
    assertEquals("@Temporal(TemporalType.DATE)", dateOnlyFI.getAnnotations().get(0));

    FieldInfo timeFI = p.getFieldInfos().get(1);
    assertEquals(1, timeFI.getAnnotations().size());
    assertEquals("@Temporal(TemporalType.TIME)", timeFI.getAnnotations().get(0));

    FieldInfo dateFI = p.getFieldInfos().get(2);
    assertEquals(1, dateFI.getAnnotations().size());
    assertEquals("@Temporal(TemporalType.TIMESTAMP)", dateFI.getAnnotations().get(0));
  }
예제 #2
0
  @Test
  public void testJPAEntityFieldInfo() {
    JPAResponderGen rg = new JPAResponderGen();

    EntityMetadata mdEntity = new EntityMetadata("Flight");
    Vocabulary voc = new Vocabulary();
    voc.setTerm(new TermValueType(TermValueType.INTEGER_NUMBER));
    voc.setTerm(new TermIdField(true));
    mdEntity.setPropertyVocabulary("ID", voc);
    voc = new Vocabulary();
    voc.setTerm(new TermValueType(TermValueType.INTEGER_NUMBER));
    mdEntity.setPropertyVocabulary("flightID", voc);
    mdEntity.setPropertyVocabulary("number", new Vocabulary());
    mdEntity.setPropertyVocabulary("runway", new Vocabulary());
    voc = new Vocabulary();
    voc.setTerm(new TermValueType(TermValueType.TIMESTAMP));
    mdEntity.setPropertyVocabulary("departureDT", voc);
    voc = new Vocabulary();
    voc.setTerm(new TermValueType(TermValueType.DATE));
    mdEntity.setPropertyVocabulary("departureDate", voc);
    voc = new Vocabulary();
    voc.setTerm(new TermValueType(TermValueType.TIME));
    mdEntity.setPropertyVocabulary("departureTime", voc);
    EntityInfo p = rg.createEntityInfoFromEntityMetadata("AirlineModel", mdEntity);

    assertEquals(6, p.getFieldInfos().size());
    assertTrue(p.getFieldInfos().contains(new FieldInfo("flightID", "Long", null)));
    assertTrue(p.getFieldInfos().contains(new FieldInfo("number", "String", null)));
    assertTrue(p.getFieldInfos().contains(new FieldInfo("runway", "String", null)));
    assertTrue(p.getFieldInfos().contains(new FieldInfo("departureDT", "java.util.Date", null)));
    assertTrue(p.getFieldInfos().contains(new FieldInfo("departureDate", "java.util.Date", null)));
    assertTrue(p.getFieldInfos().contains(new FieldInfo("departureTime", "java.util.Date", null)));
  }
예제 #3
0
  @Test
  public void testJPAEntityKeyInfo() {
    JPAResponderGen rg = new JPAResponderGen();

    EntityMetadata mdEntity = new EntityMetadata("Flight");
    Vocabulary voc = new Vocabulary();
    voc.setTerm(new TermValueType(TermValueType.INTEGER_NUMBER));
    voc.setTerm(new TermIdField(true));
    mdEntity.setPropertyVocabulary("flightID", voc);
    EntityInfo p = rg.createEntityInfoFromEntityMetadata("AirlineModel", mdEntity);

    assertEquals("flightID", p.getKeyInfo().getName());
    assertEquals("Long", p.getKeyInfo().getType());
    assertEquals(0, p.getFieldInfos().size());
  }
예제 #4
0
  @Test
  public void testEntityInfo() {
    JPAResponderGen rg = new JPAResponderGen();

    EntityMetadata mdEntity = new EntityMetadata("Flight");
    Vocabulary voc = new Vocabulary();
    voc.setTerm(new TermValueType(TermValueType.INTEGER_NUMBER));
    voc.setTerm(new TermIdField(true));
    mdEntity.setPropertyVocabulary("ID", voc);
    EntityInfo p = rg.createEntityInfoFromEntityMetadata("AirlineModel", mdEntity);

    assertEquals("Flight", p.getClazz());
    assertEquals("AirlineModel", p.getPackage());
    assertEquals("AirlineModel.Flight", p.getFQTypeName());
  }