List of usage examples for com.fasterxml.jackson.databind.node ObjectNode put
public ObjectNode put(String paramString1, String paramString2)
From source file:controllers.FeaturesTest.java
@Test public void createFeatureExisting() { ObjectNode feature = Json.newObject(); feature.put("name", "ExistingFeature"); feature.put("description", "..."); feature.put("type", "atomic"); feature.put("uuid", "008da956-fcdb-4a62-adef-c96d8cea3f02"); Result result = callAction(controllers.routes.ref.Features.create(), fakeRequest().withSession("username", "user@example.com").withJsonBody(feature)); assertThat(status(result)).isEqualTo(Status.BAD_REQUEST); }
From source file:com.dhenton9000.jersey.client.CodeBaseClass.java
protected void updateRestaurant(JsonNode restaurant, String fieldName, String newValue) { ClientConfig config = new ClientConfig(); Client client = ClientBuilder.newClient(config); WebTarget target = client.target(getBaseURI()); ObjectNode sampleObj = (ObjectNode) restaurant; sampleObj.put(fieldName, newValue); String newString = restaurant.toString(); assertTrue(StringUtils.isNotEmpty(newString)); Entity<String> itemToSend = Entity.json(newString); target.path("restaurant").path("4").request(MediaType.APPLICATION_JSON).put(itemToSend); }
From source file:controllers.FeaturesTest.java
@Test public void createFeatureSuccess() { ObjectNode feature = Json.newObject(); feature.put("name", "NonExistingFeature"); feature.put("description", "..."); feature.put("type", "complex"); feature.put("uuid", "e9612ab6-0ed8-4bcc-8930-464a7745125d"); Result result = callAction(controllers.routes.ref.Features.create(), fakeRequest().withSession("username", "user@example.com").withJsonBody(feature)); assertThat(status(result)).isEqualTo(Status.OK); assert (Feature.nodes.exists(feature).get(ASYNC_TIMEOUT)); }
From source file:org.gitana.platform.client.node.type.TypeDefinitionImpl.java
@Override public Form createForm(String formKey, ObjectNode object) { // create the form object.put(Node.FIELD_TYPE_QNAME, Form.QNAME.toString()); Form form = (Form) getBranch().createNode(object); // create the association HasFormAssociation association = (HasFormAssociation) associate(form, HasFormAssociation.QNAME); association.set(HasFormAssociation.FIELD_FORM_KEY, formKey); association.update();// w ww . ja v a2 s.c o m return form; }
From source file:com.github.fge.jsonschema.core.keyword.syntax.checkers.BasicSyntaxCheckerTest.java
@Test(dataProvider = "invalidTypes") public void syntaxCheckingFailsOnInvalidTypes(final JsonNode node) throws ProcessingException { final NodeType type = NodeType.getNodeType(node); final ObjectNode schema = FACTORY.objectNode(); schema.put(KEYWORD, node); final SchemaTree tree = new CanonicalSchemaTree(SchemaKey.anonymousKey(), schema); final AbstractSyntaxChecker checker = spy(new DummyChecker()); final ProcessingReport report = mock(ProcessingReport.class); final ArgumentCaptor<ProcessingMessage> captor = ArgumentCaptor.forClass(ProcessingMessage.class); checker.checkSyntax(null, BUNDLE, report, tree); verify(report).error(captor.capture()); verify(checker, never()).checkValue(null, BUNDLE, report, tree); final ProcessingMessage msg = captor.getValue(); assertMessage(msg).hasField("keyword", KEYWORD).hasField("schema", tree) .hasMessage(BUNDLE.printf("common.incorrectType", type, VALID_TYPES)).hasField("domain", "syntax") .hasField("expected", EnumSet.of(ARRAY, INTEGER, STRING)) .hasField("found", NodeType.getNodeType(node)); }
From source file:transformation.CsvExportTest.java
@Test public void testNestedFields() { ObjectNode org1 = Json.newObject(); ObjectNode sub1 = Json.newObject();/*from ww w .j a v a2 s. c om*/ org1.put("field1", "org1-value1"); org1.put("field2", "org1-value2"); org1.set("field3", sub1); sub1.put("field1", "org1-sub1"); sub1.put("field2", "org1-sub2"); sub1.put("field3", "org1-sub3"); ObjectNode org2 = Json.newObject(); ObjectNode sub2 = Json.newObject(); org2.put("field1", "org2-value1"); org2.put("field2", "org2-value2"); org2.set("field3", sub2); sub2.put("field1", "org2-sub1"); sub2.put("field2", "org2-sub2"); sub2.put("field3", "org2-sub3"); List<ObjectNode> orgs = Arrays.asList(org1, org2); CsvExport export = new CsvExport(Json.stringify(Json.toJson(orgs))); String expected = String.format("%s,%s\n%s,%s\n%s,%s\n", // "field1", "field3.field2", // "\"org1-value1\"", "\"org1-sub2\"", // "\"org2-value1\"", "\"org2-sub2\""); assertThat(export.of("field1,field3.field2")).isEqualTo(expected); }
From source file:org.envirocar.server.rest.encoding.json.AnnouncementJSONEncoder.java
@Override public ObjectNode encodeJSON(Announcement a, AccessRights rights, MediaType mediaType) { ObjectNode anno = getJsonFactory().objectNode(); if (a.hasCreationTime()) { anno.put(JSONConstants.CREATED_KEY, getDateTimeFormat().print(a.getCreationTime())); }// www . j a va 2s . c o m if (a.hasModificationTime()) { anno.put(JSONConstants.MODIFIED_KEY, getDateTimeFormat().print(a.getModificationTime())); } if (a.getIdentifier() != null) { anno.put(JSONConstants.IDENTIFIER_KEY, a.getIdentifier()); } if (a.getVersions() != null) { anno.put(JSONConstants.VERSIONS, a.getVersions()); } if (a.getCategory() != null) { anno.put(JSONConstants.CATEGORY, a.getCategory()); } if (a.getPriority() != null) { anno.put(JSONConstants.PRIORITY, a.getPriority()); } if (a.getContents() != null) { ObjectNode values = anno.putObject(JSONConstants.CONTENT); for (Entry<String, String> e : a.getContents().entrySet()) { values.put(e.getKey(), e.getValue()); } } return anno; }
From source file:org.trustedanalytics.h2oscoringengine.publisher.steps.AppRouteCreatingStep.java
private String createRouteBody(String subdomain, String domainGuid, String spaceGuid) { ObjectMapper mapper = new ObjectMapper(); ObjectNode requestBody = mapper.createObjectNode(); requestBody.put("host", subdomain); requestBody.put("domain_guid", domainGuid); requestBody.put("space_guid", spaceGuid); return requestBody.toString(); }
From source file:com.rusticisoftware.tincan.Agent.java
@Override public ObjectNode toJSONNode(TCAPIVersion version) { ObjectNode node = Mapper.getInstance().createObjectNode(); node.put("objectType", this.getObjectType()); if (this.name != null) { node.put("name", this.getName()); }//from w w w . ja v a2s . co m if (this.mbox != null) { node.put("mbox", this.getMbox()); } if (this.mboxSHA1Sum != null) { node.put("mbox_sha1sum", this.getMboxSHA1Sum()); } if (this.openID != null) { node.put("openid", this.getOpenID()); } if (this.account != null) { node.put("account", this.getAccount().toJSONNode(version)); } return node; }