use of com.fasterxml.jackson.databind.node.TextNode in project jsonschema2pojo by joelittlejohn.
the class DescriptionRuleTest method applyAddsDescriptionToJavadoc.
@Test
public void applyAddsDescriptionToJavadoc() throws JClassAlreadyExistsException {
JDefinedClass jclass = new JCodeModel()._class(TARGET_CLASS_NAME);
ObjectMapper mapper = new ObjectMapper();
TextNode descriptionNode = mapper.createObjectNode().textNode("some description");
JDocComment result = rule.apply("fooBar", descriptionNode, jclass, null);
assertThat(result, sameInstance(jclass.javadoc()));
assertThat(result.size(), is(1));
assertThat((String) result.get(0), is("some description"));
}
use of com.fasterxml.jackson.databind.node.TextNode in project jsonschema2pojo by joelittlejohn.
the class TypeRuleTest method applyGeneratesDate.
@Test
public void applyGeneratesDate() {
JPackage jpackage = new JCodeModel()._package(getClass().getPackage().getName());
ObjectNode objectNode = new ObjectMapper().createObjectNode();
objectNode.put("type", "string");
TextNode formatNode = TextNode.valueOf("date-time");
objectNode.set("format", formatNode);
JType mockDateType = mock(JType.class);
FormatRule mockFormatRule = mock(FormatRule.class);
when(mockFormatRule.apply(eq("fooBar"), eq(formatNode), Mockito.isA(JType.class), isNull(Schema.class))).thenReturn(mockDateType);
when(ruleFactory.getFormatRule()).thenReturn(mockFormatRule);
JType result = rule.apply("fooBar", objectNode, jpackage, null);
assertThat(result, equalTo(mockDateType));
}
use of com.fasterxml.jackson.databind.node.TextNode in project jackson-databind by FasterXML.
the class TestTreeTraversingParser method testTextAsBinary.
public void testTextAsBinary() throws Exception {
TextNode n = new TextNode(" APs=\n");
JsonParser p = n.traverse();
assertNull(p.getCurrentToken());
assertToken(JsonToken.VALUE_STRING, p.nextToken());
byte[] data = p.getBinaryValue();
assertNotNull(data);
assertArrayEquals(new byte[] { 0, -5 }, data);
assertNull(p.nextToken());
p.close();
assertTrue(p.isClosed());
// Also: let's verify we get an exception for garbage...
n = new TextNode("?!??");
p = n.traverse();
assertToken(JsonToken.VALUE_STRING, p.nextToken());
try {
p.getBinaryValue();
} catch (InvalidFormatException e) {
verifyException(e, "Illegal character");
}
p.close();
}
use of com.fasterxml.jackson.databind.node.TextNode in project infoarchive-sip-sdk by Enterprise-Content-Management.
the class InfoArchiveRestClient method getValidJsonRequestForExport.
private String getValidJsonRequestForExport(String exportConfigurationUri, List<SearchResult> searchResults) {
JsonNodeFactory jsonNodeFactory = new ObjectMapper().getNodeFactory();
ObjectNode root = jsonNodeFactory.objectNode();
ArrayNode includedRows = jsonNodeFactory.arrayNode();
for (SearchResult searchResult : searchResults) {
for (Row row : searchResult.getRows()) {
includedRows.add(row.getId());
}
}
TextNode exportConfiguration = jsonNodeFactory.textNode(exportConfigurationUri);
root.set("exportConfiguration", exportConfiguration);
root.set("includedRows", includedRows);
return root.toString();
}
use of com.fasterxml.jackson.databind.node.TextNode in project XRTB by benmfaul.
the class Impression method doNative.
/**
* Handle the native impression
*/
void doNative() {
JsonNode node = rnode.get("native");
if (node != null) {
JsonNode child = null;
nativead = true;
nativePart = new NativePart();
child = node.path("layout");
if (child != null) {
nativePart.layout = child.intValue();
}
if (node.path("assets") instanceof MissingNode == false) {
ArrayNode array = (ArrayNode) node.path("assets");
for (JsonNode x : array) {
child = x.path("title");
if (child instanceof MissingNode == false) {
nativePart.title = new Title();
nativePart.title.len = child.path("len").intValue();
if (x.path("required") instanceof MissingNode == false) {
nativePart.title.required = x.path("required").intValue();
}
}
child = x.path("img");
if (child instanceof MissingNode == false) {
nativePart.img = new Img();
nativePart.img.w = child.path("w").intValue();
nativePart.img.h = child.path("h").intValue();
if (x.path("required") instanceof MissingNode == false) {
nativePart.img.required = x.path("required").intValue();
}
if (child.path("mimes") instanceof MissingNode == false) {
if (child.path("mimes") instanceof TextNode) {
nativePart.img.mimes.add(child.get("mimes").asText());
} else {
array = (ArrayNode) child.path("mimes");
for (JsonNode nx : array) {
nativePart.img.mimes.add(nx.textValue());
}
}
}
}
child = x.path("video");
if (child instanceof MissingNode == false) {
nativePart.video = new NativeVideo();
nativePart.video.linearity = child.path("linearity").intValue();
nativePart.video.minduration = child.path("minduration").intValue();
nativePart.video.maxduration = child.path("maxduration").intValue();
if (x.path("required") instanceof MissingNode == false) {
nativePart.video.required = x.path("required").intValue();
}
if (child.path("mimes") instanceof MissingNode == false) {
array = (ArrayNode) child.path("protocols");
for (JsonNode nx : array) {
nativePart.video.protocols.add(nx.textValue());
}
}
}
child = x.path("data");
if (child instanceof MissingNode == false) {
Data data = new Data();
if (x.path("required") instanceof MissingNode == false) {
data.required = x.path("required").intValue();
}
if (child.path("len") instanceof MissingNode == false) {
data.len = child.path("len").intValue();
}
data.type = child.path("type").intValue();
nativePart.data.add(data);
}
}
}
}
}
Aggregations