Package com.baasbox.service.query

Examples of com.baasbox.service.query.PartsParser


  public void testUpdateString(){
    List<PartsLexer.Part> parts = new ArrayList<PartsLexer.Part>();
    for(int i = 0;i<3;i++){
      parts.add(PartFactory.parse(".field"+i, i+1));
    }
    PartsParser parser = new PartsParser(parts);
    String jn = parser.treeFields();
    assertEquals(jn, "field0.field1.field2");
    assertEquals(parser.last().getName(), "field2");
    assertEquals(parser.lastParent().getName(), "field1");
    assertEquals(parser.first().getName(), "field0");
   
   
  }
View Full Code Here


  @Test
  public void testPrivateFieldError(){
    List<PartsLexer.Part> parts = new ArrayList<PartsLexer.Part>();
    try{
      parts.add(PartFactory.parse(".id",1));
      new PartsParser(parts);
      fail();
    }catch(Exception e ){
      assertEquals(PartsLexer.PartValidationException.class,e.getClass());
      assertTrue(e.getMessage().indexOf("private")>-1);
    }
View Full Code Here

  @Test
  public void testPrivateFieldWithAtError(){
    List<PartsLexer.Part> parts = new ArrayList<PartsLexer.Part>();
    try{
      parts.add(PartFactory.parse(".@id",1));
      new PartsParser(parts);
      fail();
    }catch(Exception e ){
      assertEquals(PartsLexer.PartValidationException.class,e.getClass());
      System.out.println(e.getMessage());
      assertTrue(e.getMessage().toLowerCase().indexOf("unrecognized")>-1);
View Full Code Here

 
  @Test
  public void testUpdateStringOnlyOneField(){
    List<PartsLexer.Part> parts = new ArrayList<PartsLexer.Part>();
    parts.add(PartFactory.parse(".field0",1));
    PartsParser parser = new PartsParser(parts);
    String jn = parser.treeFields();
    assertEquals("field0", jn);
    assertEquals(parser.last().getName(), "field0");
    assertEquals(parser.lastParent().getName(), "field0");
    assertEquals(parser.first().getName(), "field0");
   
   
  }
View Full Code Here

    List<PartsLexer.Part> parts = new ArrayList<PartsLexer.Part>();
    PartsLexer pl = new PartsLexer();
    parts.add(pl.parse(".coll[0]", 1));

    PartsParser pp = new PartsParser(parts);

    ObjectMapper om = new ObjectMapper();
    JsonNode json = om.readTree(content);
    JsonNode root = JsonTree.read(json, pp);
    if(root.isMissingNode()){
View Full Code Here

    List<PartsLexer.Part> parts = new ArrayList<PartsLexer.Part>();
    PartsLexer pl = new PartsLexer();
    parts.add(pl.parse(".title2", 1));

    PartsParser pp = new PartsParser(parts);

    ObjectMapper om = new ObjectMapper();
    JsonNode json = om.readTree(content);
    JsonNode root = JsonTree.read(json, pp);
    if(root.isMissingNode()){
View Full Code Here

    List<PartsLexer.Part> parts = new ArrayList<PartsLexer.Part>();
    PartsLexer pl = new PartsLexer();
    parts.add(pl.parse(".title", 1));

    PartsParser pp = new PartsParser(parts);

    ObjectMapper om = new ObjectMapper();
    JsonNode json = om.readTree(content);
    JsonNode root = JsonTree.read(json, pp);
    if(root.isMissingNode()){
View Full Code Here

    List<PartsLexer.Part> parts = new ArrayList<PartsLexer.Part>();
    PartsLexer pl = new PartsLexer();
    parts.add(pl.parse(".coll[3]", 1));

    PartsParser pp = new PartsParser(parts);

    ObjectMapper om = new ObjectMapper();
    JsonNode json = om.readTree(content);
    JsonNode root = JsonTree.read(json, pp);
    if(root.isMissingNode()){
View Full Code Here

    String data = "{\"data\":\"title2\"}";
    List<PartsLexer.Part> parts = new ArrayList<PartsLexer.Part>();
    PartsLexer pl = new PartsLexer();
    parts.add(pl.parse(".title", 1));

    PartsParser pp = new PartsParser(parts);

    ObjectMapper om = new ObjectMapper();
    JsonNode json = om.readTree(content);
    JsonNode jsonData = om.readTree(data);
    JsonTree.write(json, pp, jsonData.get("data"));
View Full Code Here

    String content = "{\"@rid\":\"#20:0\",\"@version\":25,\"@class\":\"posts\",\"title\":\"title\",\"content\":\"content\",\"id\":\"a843d3f0-25fb-468c-8452-f14b1f0c6f42\",\"coll\":[1,2,3],\"tags\":[\"one\",\"two\",\"three\"]}";
    String data = "{\"data\":\"title2\"}";
    List<PartsLexer.Part> parts = new ArrayList<PartsLexer.Part>();
    PartsLexer pl = new PartsLexer();
    parts.add(pl.parse(".title2", 1));
    PartsParser pp = new PartsParser(parts);
    ObjectMapper om = new ObjectMapper();
    JsonNode json = om.readTree(content);
    JsonNode jsonData = om.readTree(data);
    JsonTree.write(json, pp, jsonData.get("data"));
    assertEquals("title2",JsonTree.read(json, pp).asText());
View Full Code Here

TOP

Related Classes of com.baasbox.service.query.PartsParser

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.