Package com.fasterxml.jackson.databind.node

Examples of com.fasterxml.jackson.databind.node.ArrayNode


 
  @Test
  public void ValidateCorrectLocalizedArguments(){
    ObjectNode jNode = JsonNodeFactory.instance.objectNode();
    try{
      ArrayNode aNode = JsonNodeFactory.instance.arrayNode();
      aNode.add("NODE-ARRAY-LOCALIZED-ARGUMENTS");
      // ArrayNode
      jNode.put("localizedArguments", aNode);
      APNServer.validatePushPayload(jNode);
    }
    catch(BaasBoxPushException e) {
View Full Code Here


    catch(BaasBoxPushException e) {
      Assert.assertEquals("Validate failed for collapse_key", CustomHttpCode.PUSH_COLLAPSE_KEY_FORMAT_INVALID.getDescription(),e.getMessage());
    }
    try{
      //ArrayNode
      ArrayNode arrayNode = JsonNodeFactory.instance.arrayNode();
      arrayNode.add("It's an element of Array for collapse_key");
      jNode.put("collapse_key", arrayNode);
      GCMServer.validatePushPayload(jNode)
    }
    catch(BaasBoxPushException e) {
      Assert.assertEquals("Validate failed for collapse_key", CustomHttpCode.PUSH_COLLAPSE_KEY_FORMAT_INVALID.getDescription(),e.getMessage());
View Full Code Here

    catch(BaasBoxPushException e) {
      Assert.assertEquals("Validate failed for time_to_live", CustomHttpCode.PUSH_TIME_TO_LIVE_FORMAT_INVALID.getDescription(),e.getMessage());
    }
    try{
      //ArrayNode
      ArrayNode arrayNode = JsonNodeFactory.instance.arrayNode();
      arrayNode.add("It's an element of Array for time_to_live");
      jNode.put("time_to_live", arrayNode);
      GCMServer.validatePushPayload(jNode)
    }
    catch(BaasBoxPushException e) {
      Assert.assertEquals("Validate failed for time_to_live", CustomHttpCode.PUSH_TIME_TO_LIVE_FORMAT_INVALID.getDescription(),e.getMessage());
View Full Code Here

    catch(BaasBoxPushException e) {
      Assert.assertEquals("Validate failed for content-available",CustomHttpCode.PUSH_CONTENT_AVAILABLE_FORMAT_INVALID.getDescription(),e.getMessage());
    }
    try {
      //ArrayNode
      ArrayNode arrayNode = JsonNodeFactory.instance.arrayNode();
      arrayNode.add(10);
      jNode.put("content-available", arrayNode);
      APNServer.validatePushPayload(jNode);
    }
    catch(BaasBoxPushException e) {
      Assert.assertEquals("Validate failed for content-available",CustomHttpCode.PUSH_CONTENT_AVAILABLE_FORMAT_INVALID.getDescription(),e.getMessage());
View Full Code Here

                DbHelper.open("1234567890",TEST_USER,TEST_USER);

                ObjectNode params = MAPPER.createObjectNode();
                ObjectNode users = MAPPER.createObjectNode();
                ArrayNode read = MAPPER.createArrayNode();
                read.add(TEST_ALT_USER);
                users.put("read", read);
                params.put("collection",TEST_COLLECTION);
                params.put("id", sGenIds.get(0));
                params.put("users",users);
                ObjectNode grant = ScriptCommands.createCommand("documents","grant",params);
View Full Code Here

        try {
            List<ODocument> docs = DocumentService.getDocuments(collection, params);

            String s = JSONFormats.prepareDocToJson(docs, JSONFormats.Formats.DOCUMENT_PUBLIC);
            ArrayNode lst = (ArrayNode)Json.mapper().readTree(s);
            lst.forEach((j)->((ObjectNode)j).remove(TO_REMOVE).remove("@rid"));
            return lst;
        } catch (SqlInjectionException | IOException e) {
            throw new CommandExecutionException(command,"error executing command: "+e.getMessage(),e);
        } catch (InvalidCollectionException e) {
            throw new CommandExecutionException(command,"invalid collection: "+collection,e);
View Full Code Here

    }
    return builder.build();
  }

  private static JsonNode toJson(PartitionStrategy strategy) {
    ArrayNode strategyJson = JsonNodeFactory.instance.arrayNode();
    for (FieldPartitioner fp : strategy.getFieldPartitioners()) {
      ObjectNode partitioner = JsonNodeFactory.instance.objectNode();
      partitioner.set(NAME, TextNode.valueOf(fp.getName()));
      if (fp instanceof IdentityFieldPartitioner) {
        partitioner.set(SOURCE, TextNode.valueOf(fp.getSourceName()));
        partitioner.set(TYPE, TextNode.valueOf("identity"));
      } else if (fp instanceof HashFieldPartitioner) {
        partitioner.set(SOURCE, TextNode.valueOf(fp.getSourceName()));
        partitioner.set(TYPE, TextNode.valueOf("hash"));
        partitioner.set(BUCKETS, LongNode.valueOf(fp.getCardinality()));
      } else if (fp instanceof YearFieldPartitioner) {
        partitioner.set(SOURCE, TextNode.valueOf(fp.getSourceName()));
        partitioner.set(TYPE, TextNode.valueOf("year"));
      } else if (fp instanceof MonthFieldPartitioner) {
        partitioner.set(SOURCE, TextNode.valueOf(fp.getSourceName()));
        partitioner.set(TYPE, TextNode.valueOf("month"));
      } else if (fp instanceof DayOfMonthFieldPartitioner) {
        partitioner.set(SOURCE, TextNode.valueOf(fp.getSourceName()));
        partitioner.set(TYPE, TextNode.valueOf("day"));
      } else if (fp instanceof HourFieldPartitioner) {
        partitioner.set(SOURCE, TextNode.valueOf(fp.getSourceName()));
        partitioner.set(TYPE, TextNode.valueOf("hour"));
      } else if (fp instanceof MinuteFieldPartitioner) {
        partitioner.set(SOURCE, TextNode.valueOf(fp.getSourceName()));
        partitioner.set(TYPE, TextNode.valueOf("minute"));
      } else if (fp instanceof DateFormatPartitioner) {
        partitioner.set(SOURCE, TextNode.valueOf(fp.getSourceName()));
        partitioner.set(TYPE, TextNode.valueOf("dateFormat"));
        partitioner.set(FORMAT,
            TextNode.valueOf(((DateFormatPartitioner) fp).getPattern()));
      } else if (fp instanceof ProvidedFieldPartitioner) {
        partitioner.set(TYPE, TextNode.valueOf("provided"));
        partitioner.set(VALUES,
            TextNode.valueOf(((ProvidedFieldPartitioner) fp).getTypeAsString()));
      } else {
        throw new ValidationException(
            "Unknown partitioner class: " + fp.getClass());
      }
      strategyJson.add(partitioner);
    }
    return strategyJson;
  }
View Full Code Here

    }
    return writer.toString();
  }

  private static JsonNode toJson(ColumnMapping mapping) {
    ArrayNode mappingJson = JsonNodeFactory.instance.arrayNode();
    for (FieldMapping fm : mapping.getFieldMappings()) {
      mappingJson.add(toJson(fm));
    }
    return mappingJson;
  }
View Full Code Here

        return gmState;
    }

    protected ArrayNode getPortfolio() {
        ArrayNode stocks = Json.newObject().arrayNode();
        GameManager gm = new GameManager();
        for (PortfolioStock portfoilioStock : gameState.getCurrentPlayer().getPortfolios()) {
            ObjectNode stockNode = Json.newObject();
            stockNode.put("id", portfoilioStock.getId());
            String ticker = portfoilioStock.getStock().getTicker();
            stockNode.put("ticker", ticker);
            stockNode.put("company", portfoilioStock.getStock().getCompanyName());
            stockNode.put("quantity", portfoilioStock.getQuantity());
            StockPrice currentStockPrice = null;
            try {
                currentStockPrice = gm.getStockPrice(ticker, gameState.getGame().getVirtualCurrentDate());
            } catch (IOException ex) {
                play.Logger.warn("error occured while retrieving price", ex);
            }
            stockNode.put("currentPrice", currentStockPrice != null ? currentStockPrice.getStockPrice() : 0);
            //stockNode.put("purchasePrice", purchasePrice);
            stocks.add(stockNode);
        }
        return stocks;
    }
View Full Code Here

        @Override
        public Event deserialize(JsonParser jp, DeserializationContext ctxt) throws IOException,
                JsonProcessingException {
            ObjectMapper mapper = (ObjectMapper) jp.getCodec();
            ArrayNode root = (ArrayNode) mapper.readTree(jp);
            String eventName = root.get(0).asText();
            if (!eventMapping.containsKey(eventName)) {
                return new Event(eventName, Collections.emptyList());
            }

            List<Object> eventArgs = new ArrayList<Object>();
            Event event = new Event(eventName, eventArgs);
            if (root.size() > 1) {
                Iterator<JsonNode> iterator = root.elements();
                // skip 0 node
                iterator.next();
                List<Class<?>> eventClasses = eventMapping.get(eventName);
                int i = 0;
                while (iterator.hasNext()) {
View Full Code Here

TOP

Related Classes of com.fasterxml.jackson.databind.node.ArrayNode

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.