use of org.apache.flink.shaded.jackson2.com.fasterxml.jackson.databind.ObjectMapper in project spring-boot-admin by codecentric.
the class ApplicationTest method test_json_format.
@Test
public void test_json_format() throws JsonProcessingException, IOException {
ObjectMapper objectMapper = Jackson2ObjectMapperBuilder.json().build();
Application app = Application.create("test").withHealthUrl("http://health").withServiceUrl("http://service").withManagementUrl("http://management").build();
DocumentContext json = JsonPath.parse(objectMapper.writeValueAsString(app));
assertThat((String) json.read("$.name")).isEqualTo("test");
assertThat((String) json.read("$.serviceUrl")).isEqualTo("http://service");
assertThat((String) json.read("$.managementUrl")).isEqualTo("http://management");
assertThat((String) json.read("$.healthUrl")).isEqualTo("http://health");
}
use of org.apache.flink.shaded.jackson2.com.fasterxml.jackson.databind.ObjectMapper in project cas by apereo.
the class RegisteredServiceJsonSerializer method initializeObjectMapper.
/**
* Mixins are added to the object mapper in order to
* ignore certain method signatures from serialization
* that are otherwise treated as getters. Each mixin
* implements the appropriate interface as a private
* dummy class and is annotated with JsonIgnore elements
* throughout. This helps us catch errors at compile-time
* when the interface changes.
*
* @return the prepped object mapper.
*/
@Override
protected ObjectMapper initializeObjectMapper() {
final ObjectMapper mapper = super.initializeObjectMapper();
mapper.addHandler(new JasigRegisteredServiceDeserializationProblemHandler());
return mapper;
}
use of org.apache.flink.shaded.jackson2.com.fasterxml.jackson.databind.ObjectMapper in project buck by facebook.
the class TargetsCommand method printJsonForTargets.
@VisibleForTesting
void printJsonForTargets(CommandRunnerParams params, ListeningExecutorService executor, Iterable<TargetNode<?, ?>> targetNodes, ImmutableMap<BuildTarget, ShowOptions> showRulesResult, ImmutableSet<String> outputAttributes) throws BuildFileParseException {
PatternsMatcher attributesPatternsMatcher = new PatternsMatcher(outputAttributes);
// Print the JSON representation of the build node for the specified target(s).
params.getConsole().getStdOut().println("[");
ObjectMapper mapper = params.getObjectMapper();
Iterator<TargetNode<?, ?>> targetNodeIterator = targetNodes.iterator();
while (targetNodeIterator.hasNext()) {
TargetNode<?, ?> targetNode = targetNodeIterator.next();
Map<String, Object> sortedTargetRule;
sortedTargetRule = params.getParser().getRawTargetNode(params.getBuckEventBus(), params.getCell(), getEnableParserProfiling(), executor, targetNode);
if (sortedTargetRule == null) {
params.getConsole().printErrorText("unable to find rule for target " + targetNode.getBuildTarget().getFullyQualifiedName());
continue;
}
sortedTargetRule = attributesPatternsMatcher.filterMatchingMapKeys(sortedTargetRule);
ShowOptions showOptions = showRulesResult.get(targetNode.getBuildTarget());
if (showOptions != null) {
putIfValuePresentAndMatches(ShowOptionsName.RULE_KEY.getName(), showOptions.getRuleKey(), sortedTargetRule, attributesPatternsMatcher);
putIfValuePresentAndMatches(ShowOptionsName.OUTPUT_PATH.getName(), showOptions.getOutputPath(), sortedTargetRule, attributesPatternsMatcher);
putIfValuePresentAndMatches(ShowOptionsName.TARGET_HASH.getName(), showOptions.getTargetHash(), sortedTargetRule, attributesPatternsMatcher);
}
String fullyQualifiedNameAttribute = "fully_qualified_name";
if (attributesPatternsMatcher.matches(fullyQualifiedNameAttribute)) {
sortedTargetRule.put(fullyQualifiedNameAttribute, targetNode.getBuildTarget().getFullyQualifiedName());
}
String cellPathAttribute = "buck.cell_path";
if (isShowCellPath() && attributesPatternsMatcher.matches(cellPathAttribute)) {
sortedTargetRule.put(cellPathAttribute, targetNode.getBuildTarget().getCellPath());
}
// Print the build rule information as JSON.
StringWriter stringWriter = new StringWriter();
try {
mapper.writerWithDefaultPrettyPrinter().writeValue(stringWriter, sortedTargetRule);
} catch (IOException e) {
// Shouldn't be possible while writing to a StringWriter...
throw new RuntimeException(e);
}
String output = stringWriter.getBuffer().toString();
if (targetNodeIterator.hasNext()) {
output += ",";
}
params.getConsole().getStdOut().println(output);
}
params.getConsole().getStdOut().println("]");
}
use of org.apache.flink.shaded.jackson2.com.fasterxml.jackson.databind.ObjectMapper in project buck by facebook.
the class BuckEventsHandlerTest method testResultSummaryExternalInterfaceKnowsResultType.
@Test
public void testResultSummaryExternalInterfaceKnowsResultType() throws Exception {
final String json = "{\n" + " \"testCaseName\": \"ok.api.ApiTest\",\n" + " \"type\": \"FAILURE\",\n" + " \"time\": 3348,\n" + " \"message\": null,\n" + " \"stacktrace\": null,\n" + " \"stdOut\": \"sup from test stdout\",\n" + " \"stdErr\": null,\n" + " \"testName\": \"logoutAll\"\n" + "}";
final ObjectMapper objectMapper = BuckEventsHandler.createObjectMapper();
final TestResultSummaryExternalInterface res = objectMapper.readValue(json, TestResultSummaryExternalInterface.class);
// because it is @JsonIgnore'd
assertFalse(res.isSuccess());
assertEquals(ResultType.FAILURE, res.getType());
}
use of org.apache.flink.shaded.jackson2.com.fasterxml.jackson.databind.ObjectMapper in project buck by facebook.
the class ArtifactConfig method fromCommandLineArgs.
public static ArtifactConfig fromCommandLineArgs(String[] args) throws CmdLineException, IOException {
CmdLineArgs parsedArgs = new CmdLineArgs();
CmdLineParser parser = new CmdLineParser(parsedArgs);
parser.parseArgument(args);
if (parsedArgs.showHelp) {
usage(parser);
}
ArtifactConfig artifactConfig;
// If the -config argument was specified, load a config from JSON.
if (parsedArgs.artifactConfigJson != null) {
ObjectMapper mapper = new ObjectMapper();
File jsonFile = new File(parsedArgs.artifactConfigJson);
artifactConfig = mapper.readValue(jsonFile, ArtifactConfig.class);
} else {
artifactConfig = new ArtifactConfig();
}
if (artifactConfig.buckRepoRoot == null && parsedArgs.buckRepoRoot == null) {
usage(parser);
}
artifactConfig.mergeCmdLineArgs(parsedArgs);
return artifactConfig;
}
Aggregations