Exemple #1
0
 @Test
 public void testBaseUid() {
   CharStream stream = new ANTLRStringStream("Tellurium");
   UdlLexer lexer = new UdlLexer(stream);
   TokenStream tokenStream = new CommonTokenStream(lexer);
   UdlParser parser = new UdlParser(tokenStream);
   try {
     MetaData data = parser.uid();
     assertNotNull(data);
     assertEquals("Tellurium", data.getId());
   } catch (RecognitionException e) {
     fail(e.getMessage());
   }
 }
Exemple #2
0
 @Test
 public void testTableHeaderUidNoId() {
   CharStream stream = new ANTLRStringStream("{header: 3}");
   UdlLexer lexer = new UdlLexer(stream);
   TokenStream tokenStream = new CommonTokenStream(lexer);
   UdlParser parser = new UdlParser(tokenStream);
   try {
     MetaData data = parser.uid();
     assertNotNull(data);
     assertTrue(data instanceof TableHeaderMetaData);
     TableHeaderMetaData th = (TableHeaderMetaData) data;
     assertEquals("_3", th.getId());
     assertEquals("3", th.getIndex().getValue());
     assertEquals(IndexType.VAL, th.getIndex().getType());
   } catch (RecognitionException e) {
     fail(e.getMessage());
   }
 }
Exemple #3
0
 @Test
 public void testListUidNoId() {
   CharStream stream = new ANTLRStringStream("{10}");
   UdlLexer lexer = new UdlLexer(stream);
   TokenStream tokenStream = new CommonTokenStream(lexer);
   UdlParser parser = new UdlParser(tokenStream);
   try {
     MetaData data = parser.uid();
     assertNotNull(data);
     assertEquals("_10", data.getId());
     assertTrue(data instanceof ListMetaData);
     ListMetaData lm = (ListMetaData) data;
     assertEquals("10", lm.getIndex().getValue());
     assertEquals(IndexType.VAL, lm.getIndex().getType());
   } catch (RecognitionException e) {
     fail(e.getMessage());
   }
 }
Exemple #4
0
 @Test
 public void testTableBodyRefUid() {
   CharStream stream = new ANTLRStringStream("{tbody : 1, row -> good, column -> bad} as Search");
   UdlLexer lexer = new UdlLexer(stream);
   TokenStream tokenStream = new CommonTokenStream(lexer);
   UdlParser parser = new UdlParser(tokenStream);
   try {
     MetaData data = parser.uid();
     assertNotNull(data);
     assertEquals("Search", data.getId());
     assertTrue(data instanceof TableBodyMetaData);
     TableBodyMetaData tbmd = (TableBodyMetaData) data;
     assertEquals("1", tbmd.getTbody().getValue());
     assertEquals(IndexType.VAL, tbmd.getTbody().getType());
     assertEquals("good", tbmd.getRow().getValue());
     assertEquals(IndexType.REF, tbmd.getRow().getType());
     assertEquals("bad", tbmd.getColumn().getValue());
     assertEquals(IndexType.REF, tbmd.getColumn().getType());
   } catch (RecognitionException e) {
     fail(e.getMessage());
   }
 }
Exemple #5
0
 @Test
 public void testTableBodyValUidNoId() {
   CharStream stream = new ANTLRStringStream("{tbody : 1, row : 2, column : 3}");
   UdlLexer lexer = new UdlLexer(stream);
   TokenStream tokenStream = new CommonTokenStream(lexer);
   UdlParser parser = new UdlParser(tokenStream);
   try {
     MetaData data = parser.uid();
     assertNotNull(data);
     assertEquals("_1_2_3", data.getId());
     assertTrue(data instanceof TableBodyMetaData);
     TableBodyMetaData tb = (TableBodyMetaData) data;
     assertEquals("1", tb.getTbody().getValue());
     assertEquals(IndexType.VAL, tb.getTbody().getType());
     assertEquals("2", tb.getRow().getValue());
     assertEquals(IndexType.VAL, tb.getRow().getType());
     assertEquals("3", tb.getColumn().getValue());
     assertEquals(IndexType.VAL, tb.getColumn().getType());
   } catch (RecognitionException e) {
     fail(e.getMessage());
   }
 }