use of org.apache.flink.shaded.jackson2.com.fasterxml.jackson.databind.ObjectMapper in project buck by facebook.
the class GenStringSourceMapStep method execute.
@Override
public StepExecutionResult execute(ExecutionContext context) {
// Read the R.txt file that was generated by aapt during GenRDotTxtUtil.
// This file contains all the resource names and the integer id that aapt assigned.
Path rDotTxtPath = rDotTxtDir.resolve("R.txt");
try {
CompileStringsStep.buildResourceNameToIdMap(filesystem, rDotTxtPath, stringResourceNameToIdMap, pluralsResourceNameToIdMap, arrayResourceNameToIdMap);
} catch (FileNotFoundException ex) {
context.logError(ex, "The '%s' file is not present.", rDotTxtPath);
return StepExecutionResult.ERROR;
} catch (IOException ex) {
context.logError(ex, "Failure parsing R.txt file.");
return StepExecutionResult.ERROR;
}
Map<String, Map<String, NativeResourceInfo>> nativeStrings = parseStringFiles(context);
// write nativeStrings out to a file
Path outputPath = destinationPath.resolve("strings.json");
try {
ObjectMapper mapper = ObjectMappers.newDefaultInstance();
mapper.writeValue(filesystem.getPathForRelativePath(outputPath).toFile(), nativeStrings);
} catch (IOException ex) {
context.logError(ex, "Failed when trying to save the output file: '%s'", outputPath.toString());
return StepExecutionResult.ERROR;
}
return StepExecutionResult.SUCCESS;
}
use of org.apache.flink.shaded.jackson2.com.fasterxml.jackson.databind.ObjectMapper in project buck by facebook.
the class BuildReport method generateJsonBuildReport.
public String generateJsonBuildReport() throws IOException {
Map<BuildRule, Optional<BuildResult>> ruleToResult = buildExecutionResult.getResults();
LinkedHashMap<String, Object> results = Maps.newLinkedHashMap();
LinkedHashMap<String, Object> failures = Maps.newLinkedHashMap();
boolean isOverallSuccess = true;
for (Map.Entry<BuildRule, Optional<BuildResult>> entry : ruleToResult.entrySet()) {
BuildRule rule = entry.getKey();
Optional<BuildRuleSuccessType> success = Optional.empty();
Optional<BuildResult> result = entry.getValue();
if (result.isPresent()) {
success = Optional.ofNullable(result.get().getSuccess());
}
Map<String, Object> value = Maps.newLinkedHashMap();
boolean isSuccess = success.isPresent();
value.put("success", isSuccess);
if (!isSuccess) {
isOverallSuccess = false;
}
if (isSuccess) {
value.put("type", success.get().name());
SourcePath outputFile = rule.getSourcePathToOutput();
value.put("output", outputFile != null ? pathResolver.getRelativePath(outputFile).toString() : null);
}
results.put(rule.getFullyQualifiedName(), value);
}
for (BuildResult failureResult : buildExecutionResult.getFailures()) {
Throwable failure = Preconditions.checkNotNull(failureResult.getFailure());
failures.put(failureResult.getRule().getFullyQualifiedName(), failure.getMessage());
}
Map<String, Object> report = Maps.newLinkedHashMap();
report.put("success", isOverallSuccess);
report.put("results", results);
report.put("failures", failures);
ObjectMapper objectMapper = ObjectMappers.newDefaultInstance();
objectMapper.enable(SerializationFeature.INDENT_OUTPUT);
return objectMapper.writeValueAsString(report);
}
use of org.apache.flink.shaded.jackson2.com.fasterxml.jackson.databind.ObjectMapper in project druid by druid-io.
the class NoneShardSpecTest method testPartitionFieldIgnored.
@Test
public void testPartitionFieldIgnored() throws IOException {
final String jsonStr = "{\"type\": \"none\",\"partitionNum\": 2}";
ObjectMapper mapper = new TestObjectMapper();
final ShardSpec noneShardSpec = mapper.readValue(jsonStr, ShardSpec.class);
noneShardSpec.equals(NoneShardSpec.instance());
}
use of org.apache.flink.shaded.jackson2.com.fasterxml.jackson.databind.ObjectMapper in project druid by druid-io.
the class SketchEstimateWithErrorBoundsTest method testSerde.
@Test
public void testSerde() throws IOException {
ObjectMapper mapper = new DefaultObjectMapper();
SketchEstimateWithErrorBounds est = new SketchEstimateWithErrorBounds(100.0, 101.5, 98.5, 2);
Assert.assertEquals(est, mapper.readValue(mapper.writeValueAsString(est), SketchEstimateWithErrorBounds.class));
}
use of org.apache.flink.shaded.jackson2.com.fasterxml.jackson.databind.ObjectMapper in project druid by druid-io.
the class AuthenticationKerberosConfigTest method testserde.
@Test
public void testserde() {
Injector injector = Guice.createInjector(new Module() {
@Override
public void configure(Binder binder) {
binder.install(new PropertiesModule(Arrays.asList("test.runtime.properties")));
binder.install(new ConfigModule());
binder.install(new DruidGuiceExtensions());
JsonConfigProvider.bind(binder, "druid.hadoop.security.kerberos", AuthenticationKerberosConfig.class);
}
@Provides
@LazySingleton
public ObjectMapper jsonMapper() {
return new DefaultObjectMapper();
}
});
Properties props = injector.getInstance(Properties.class);
AuthenticationKerberosConfig config = injector.getInstance(AuthenticationKerberosConfig.class);
Assert.assertEquals(props.getProperty("druid.hadoop.security.kerberos.principal"), config.getPrincipal());
Assert.assertEquals(props.getProperty("druid.hadoop.security.kerberos.keytab"), config.getKeytab());
}
Aggregations