Skip to content

Commit

Permalink
style: fix styling
Browse files Browse the repository at this point in the history
  • Loading branch information
Emrehzl94 committed Nov 28, 2024
1 parent 129e928 commit e05550d
Showing 1 changed file with 65 additions and 61 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -20,88 +20,92 @@
import static org.apache.beam.it.truthmatchers.PipelineAsserts.assertThatPipeline;
import static org.apache.beam.it.truthmatchers.PipelineAsserts.assertThatResult;

import java.io.IOException;
import java.util.List;
import java.util.Map;
import org.apache.beam.it.common.PipelineLauncher.LaunchConfig;
import org.apache.beam.it.common.PipelineLauncher.LaunchInfo;
import org.apache.beam.it.common.PipelineOperator;
import org.apache.beam.it.common.TestProperties;
import org.apache.beam.it.common.utils.ResourceManagerUtils;
import org.apache.beam.it.gcp.TemplateTestBase;
import org.apache.beam.it.neo4j.Neo4jResourceManager;
import org.apache.beam.it.common.PipelineLauncher.LaunchConfig;
import org.apache.beam.it.common.PipelineLauncher.LaunchInfo;
import org.apache.beam.it.neo4j.conditions.Neo4jQueryCheck;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
import org.junit.experimental.categories.Category;

import java.io.IOException;
import java.util.List;
import java.util.Map;

@Category(Neo4jCustomTestCategory.class)
public class MinimalServiceAccountIT extends TemplateTestBase {

private final String MINIMAL_SERVICE_ACCOUNT = "[email protected]";
private final String MINIMAL_SERVICE_ACCOUNT =
"[email protected]";

private Neo4jResourceManager neo4jClient;
private Neo4jResourceManager neo4jClient;

@Before
public void setup() {
neo4jClient = Neo4jResourceManager.builder(testName)
.setAdminPassword("letmein!")
.setHost(TestProperties.hostIp())
.build();
}
@Before
public void setup() {
neo4jClient =
Neo4jResourceManager.builder(testName)
.setAdminPassword("letmein!")
.setHost(TestProperties.hostIp())
.build();
}

@After
public void tearDown() {
ResourceManagerUtils.cleanResources(neo4jClient);
}
@After
public void tearDown() {
ResourceManagerUtils.cleanResources(neo4jClient);
}

@Test
public void test() {
assertThat(2).isEqualTo(1 + 2);
}
@Test
public void test() {
assertThat(2).isEqualTo(1 + 2);
}

@Test
public void runsWithProjectAndDataset() throws IOException {
gcsClient.createArtifact(
"project-and-dataset.json",
contentOf("/testing-specs/minimal-service-account/project-and-dataset.json"));
gcsClient.createArtifact(
"neo4j.json",
String.format(
"{\n"
+ " \"server_url\": \"%s\",\n"
+ " \"database\": \"%s\",\n"
+ " \"auth_type\": \"basic\",\n"
+ " \"username\": \"neo4j\",\n"
+ " \"pwd\": \"%s\"\n"
+ "}",
neo4jClient.getUri(), neo4jClient.getDatabaseName(), neo4jClient.getAdminPassword()));
@Test
public void runsWithProjectAndDataset() throws IOException {
gcsClient.createArtifact(
"project-and-dataset.json",
contentOf("/testing-specs/minimal-service-account/project-and-dataset.json"));
gcsClient.createArtifact(
"neo4j.json",
String.format(
"{\n"
+ " \"server_url\": \"%s\",\n"
+ " \"database\": \"%s\",\n"
+ " \"auth_type\": \"basic\",\n"
+ " \"username\": \"neo4j\",\n"
+ " \"pwd\": \"%s\"\n"
+ "}",
neo4jClient.getUri(), neo4jClient.getDatabaseName(), neo4jClient.getAdminPassword()));

LaunchConfig.Builder options = LaunchConfig.builder(testName, specPath)
.addParameter("jobSpecUri", getGcsPath("spec.json"))
.addParameter("neo4jConnectionUri", getGcsPath("neo4j.json"))
.addParameter("serviceAccount", MINIMAL_SERVICE_ACCOUNT);
LaunchConfig.Builder options =
LaunchConfig.builder(testName, specPath)
.addParameter("jobSpecUri", getGcsPath("spec.json"))
.addParameter("neo4jConnectionUri", getGcsPath("neo4j.json"))
.addParameter("serviceAccount", MINIMAL_SERVICE_ACCOUNT);

LaunchInfo info = launchTemplate(options);
assertThatPipeline(info).isRunning();
PipelineOperator.Result result = pipelineOperator()
.waitForCondition(
createConfig(info),
Neo4jQueryCheck.builder(neo4jClient)
.setQuery("RETURN EXISTS {\n" +
" MATCH (p:Person)\n" +
" RETURN p\n" +
"} AS personExists")
.setExpectedResult(List.of(Map.of("personExists", true)))
.build());
assertThatResult(result).meetsConditions();
}
LaunchInfo info = launchTemplate(options);
assertThatPipeline(info).isRunning();
PipelineOperator.Result result =
pipelineOperator()
.waitForCondition(
createConfig(info),
Neo4jQueryCheck.builder(neo4jClient)
.setQuery(
"RETURN EXISTS {\n"
+ " MATCH (p:Person)\n"
+ " RETURN p\n"
+ "} AS personExists")
.setExpectedResult(List.of(Map.of("personExists", true)))
.build());
assertThatResult(result).meetsConditions();
}

@Test
public void runsWithOnlyDataset() {}
@Test
public void runsWithOnlyDataset() {}

@Test
public void failsWithoutProjectAndDataset() {}
@Test
public void failsWithoutProjectAndDataset() {}
}

0 comments on commit e05550d

Please sign in to comment.