use of org.apache.flink.shaded.jackson2.com.fasterxml.jackson.databind.ObjectMapper in project buck by facebook.
the class BuildCommandTest method testGenerateJsonBuildReport.
@Test
public void testGenerateJsonBuildReport() throws IOException {
ObjectMapper mapper = ObjectMappers.newDefaultInstance();
String rule1TxtPath = mapper.valueToTree(MorePaths.pathWithPlatformSeparators("buck-out/gen/fake/rule1.txt")).toString();
String expectedReport = Joiner.on(System.lineSeparator()).join("{", " \"success\" : false,", " \"results\" : {", " \"//fake:rule1\" : {", " \"success\" : true,", " \"type\" : \"BUILT_LOCALLY\",", " \"output\" : " + rule1TxtPath, " },", " \"//fake:rule2\" : {", " \"success\" : false", " },", " \"//fake:rule3\" : {", " \"success\" : true,", " \"type\" : \"FETCHED_FROM_CACHE\",", " \"output\" : null", " },", " \"//fake:rule4\" : {", " \"success\" : false", " }", " },", " \"failures\" : {", " \"//fake:rule2\" : \"some\"", " }", "}");
String observedReport = new BuildReport(buildExecutionResult, resolver).generateJsonBuildReport();
assertEquals(expectedReport, observedReport);
}
use of org.apache.flink.shaded.jackson2.com.fasterxml.jackson.databind.ObjectMapper in project buck by facebook.
the class AuditClasspathCommandTest method testJsonClassPathWithVersions.
@Test
public void testJsonClassPathWithVersions() throws Exception {
// Build the test target graph.
TargetNode<?, ?> javaLibrary = JavaLibraryBuilder.createBuilder(BuildTargetFactory.newInstance("//:test-java-library")).addSrc(Paths.get("src/com/facebook/TestJavaLibrary.java")).build();
TargetNode<?, ?> androidLibrary = JavaLibraryBuilder.createBuilder(BuildTargetFactory.newInstance("//:test-android-library")).addSrc(Paths.get("src/com/facebook/TestAndroidLibrary.java")).addDep(javaLibrary.getBuildTarget()).build();
TargetNode<?, ?> version = new VersionedAliasBuilder(BuildTargetFactory.newInstance("//:version")).setVersions("1.0", "//:test-android-library").build();
TargetNode<?, ?> binary = new JavaBinaryRuleBuilder(BuildTargetFactory.newInstance("//:rule")).setDeps(ImmutableSortedSet.of(version.getBuildTarget())).build();
TargetGraph targetGraph = TargetGraphFactory.newInstance(javaLibrary, androidLibrary, version, binary);
// Run the command.
auditClasspathCommand.printJsonClasspath(params.withBuckConfig(FakeBuckConfig.builder().setSections(ImmutableMap.of("build", ImmutableMap.of("versions", "true"))).build()), targetGraph, ImmutableSet.of(androidLibrary.getBuildTarget(), javaLibrary.getBuildTarget()));
// Verify output.
Path root = javaLibrary.getBuildTarget().getCellPath();
ObjectMapper mapper = ObjectMappers.newDefaultInstance();
String expected = String.format(EXPECTED_JSON, mapper.valueToTree(root.resolve(BuildTargets.getGenPath(params.getCell().getFilesystem(), javaLibrary.getBuildTarget(), "lib__%s__output").resolve(javaLibrary.getBuildTarget().getShortName() + ".jar"))), mapper.valueToTree(root.resolve(BuildTargets.getGenPath(params.getCell().getFilesystem(), androidLibrary.getBuildTarget(), "lib__%s__output").resolve(androidLibrary.getBuildTarget().getShortName() + ".jar"))), mapper.valueToTree(root.resolve(BuildTargets.getGenPath(params.getCell().getFilesystem(), javaLibrary.getBuildTarget(), "lib__%s__output").resolve(javaLibrary.getBuildTarget().getShortName() + ".jar"))));
assertEquals(expected, console.getTextWrittenToStdOut());
assertEquals("", console.getTextWrittenToStdErr());
}
use of org.apache.flink.shaded.jackson2.com.fasterxml.jackson.databind.ObjectMapper in project buck by facebook.
the class AuditInputCommandTest method setUp.
@Before
public void setUp() throws IOException, InterruptedException {
console = new TestConsole();
FakeProjectFilesystem projectFilesystem = new FakeProjectFilesystem();
projectFilesystem.touch(Paths.get("src/com/facebook/AndroidLibraryTwo.java"));
projectFilesystem.touch(Paths.get("src/com/facebook/TestAndroidLibrary.java"));
projectFilesystem.touch(Paths.get("src/com/facebook/TestJavaLibrary.java"));
Cell cell = new TestCellBuilder().setFilesystem(projectFilesystem).build();
ArtifactCache artifactCache = new NoopArtifactCache();
BuckEventBus eventBus = BuckEventBusFactory.newInstance();
ObjectMapper objectMapper = ObjectMappers.newDefaultInstance();
auditInputCommand = new AuditInputCommand();
params = CommandRunnerParamsForTesting.createCommandRunnerParamsForTesting(console, cell, new FakeAndroidDirectoryResolver(), artifactCache, eventBus, FakeBuckConfig.builder().build(), Platform.detect(), ImmutableMap.copyOf(System.getenv()), new FakeJavaPackageFinder(), objectMapper, Optional.empty());
}
use of org.apache.flink.shaded.jackson2.com.fasterxml.jackson.databind.ObjectMapper in project buck by facebook.
the class QueryCommandTest method setUp.
@Before
public void setUp() throws IOException, InterruptedException {
TestConsole console = new TestConsole();
ProjectWorkspace workspace = TestDataHelper.createProjectWorkspaceForScenario(this, "query_command", tmp);
workspace.setUp();
ProjectFilesystem filesystem = new ProjectFilesystem(workspace.getDestPath().toRealPath().normalize());
Cell cell = new TestCellBuilder().setFilesystem(filesystem).build();
AndroidDirectoryResolver androidDirectoryResolver = new FakeAndroidDirectoryResolver();
ArtifactCache artifactCache = new NoopArtifactCache();
BuckEventBus eventBus = BuckEventBusFactory.newInstance();
ObjectMapper objectMapper = ObjectMappers.newDefaultInstance();
queryCommand = new QueryCommand();
queryCommand.outputAttributes = Suppliers.ofInstance(ImmutableSet.<String>of());
params = CommandRunnerParamsForTesting.createCommandRunnerParamsForTesting(console, cell, androidDirectoryResolver, artifactCache, eventBus, FakeBuckConfig.builder().build(), Platform.detect(), ImmutableMap.copyOf(System.getenv()), new FakeJavaPackageFinder(), objectMapper, Optional.empty());
executor = MoreExecutors.listeningDecorator(Executors.newSingleThreadExecutor());
}
use of org.apache.flink.shaded.jackson2.com.fasterxml.jackson.databind.ObjectMapper in project buck by facebook.
the class TargetsCommandIntegrationTest method testJsonOutputWithShowCellPath.
@Test
public void testJsonOutputWithShowCellPath() throws IOException {
ProjectWorkspace workspace = TestDataHelper.createProjectWorkspaceForScenario(this, "output_path", tmp);
workspace.setUp();
ProcessResult result = workspace.runBuckCommand("targets", "--json", "--show-cell-path", "//:test");
ObjectMapper objectMapper = ObjectMappers.newDefaultInstance();
// Parse the observed JSON.
JsonNode observed = objectMapper.readTree(objectMapper.getFactory().createParser(result.getStdout()));
assertTrue(observed.isArray());
JsonNode targetNode = observed.get(0);
assertTrue(targetNode.isObject());
JsonNode cellPath = targetNode.get("buck.cell_path");
assertNotNull(cellPath);
assertEquals(cellPath.asText(), MorePaths.pathWithPlatformSeparators(tmp.getRoot().toRealPath()));
}
Aggregations