Esempio n. 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());
   }
 }
Esempio n. 2
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());
   }
 }
Esempio n. 3
0
 @Test
 public void testTableBodyMixedUid() {
   try {
     MetaData data = UidParser.parse("{row:3, column -> bad} as Search");
     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("3", tbmd.getRow().getValue());
     assertEquals(IndexType.VAL, tbmd.getRow().getType());
     assertEquals("bad", tbmd.getColumn().getValue());
     assertEquals(IndexType.REF, tbmd.getColumn().getType());
   } catch (RecognitionException e) {
     e.printStackTrace();
     fail(e.getMessage());
   }
 }
Esempio n. 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());
   }
 }
Esempio n. 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());
   }
 }