use of org.projectnessie.client.api.NessieApiV1 in project nessie by projectnessie.
the class ITGenerateContent method basicGenerateContentTest.
@ParameterizedTest
@EnumSource(Content.Type.class)
void basicGenerateContentTest(Content.Type contentType) throws Exception {
Assumptions.assumeTrue(contentType != Content.Type.UNKNOWN && contentType != Type.NAMESPACE);
int numCommits = 20;
try (NessieApiV1 api = buildNessieApi()) {
String testCaseBranch = "type_" + contentType.name();
assertThat(NessieContentGenerator.runMain(new String[] { "generate", "-n", Integer.toString(numCommits), "-u", NESSIE_API_URI, "-D", testCaseBranch, "--type=" + contentType.name() })).isEqualTo(0);
assertThat(api.getCommitLog().refName(testCaseBranch).get().getLogEntries()).hasSize(numCommits);
}
}
use of org.projectnessie.client.api.NessieApiV1 in project nessie by projectnessie.
the class ITReadCommits method readCommitsVerbose.
@Test
void readCommitsVerbose() throws UnsupportedEncodingException, NessieNotFoundException {
ByteArrayOutputStream baos = new ByteArrayOutputStream();
try (PrintWriter out = new PrintWriter(new PrintStream(baos), true)) {
assertThat(NessieContentGenerator.runMain(out, new String[] { "commits", "--uri", NESSIE_API_URI, "--ref", branch.getName(), "--verbose" })).isEqualTo(0);
String[] output = baos.toString(StandardCharsets.UTF_8.toString()).split("\n");
assertThat(output).anySatisfy(s -> assertThat(s).contains(COMMIT_MSG));
assertThat(output).anySatisfy(s -> assertThat(s).contains(CONTENT_KEY.toString()));
assertThat(output).anySatisfy(s -> assertThat(s).contains("key[0]: " + CONTENT_KEY.getElements().get(0)));
assertThat(output).anySatisfy(s -> assertThat(s).contains("key[1]: " + CONTENT_KEY.getElements().get(1)));
assertThat(output).anySatisfy(s -> assertThat(s).contains(contentId));
}
try (NessieApiV1 api = buildNessieApi()) {
List<LogEntry> logEntries = api.getCommitLog().refName(branch.getName()).fetch(FetchOption.ALL).get().getLogEntries();
assertThat(logEntries).hasSize(1);
assertThat(logEntries.get(0).getOperations()).isNotEmpty();
assertThat(logEntries.get(0).getParentCommitHash()).isNotNull();
}
}
use of org.projectnessie.client.api.NessieApiV1 in project nessie by projectnessie.
the class TestNessieHttpClient method testTracing.
@Test
void testTracing() throws Exception {
AtomicReference<String> traceId = new AtomicReference<>();
try (TestServer server = new TestServer(handlerForHeaderTest("Uber-trace-id", traceId))) {
NessieApiV1 api = HttpClientBuilder.builder().withUri(server.getUri()).withTracing(true).build(NessieApiV1.class);
try (Scope ignore = GlobalTracer.get().activateSpan(GlobalTracer.get().buildSpan("testOpenTracing").start())) {
api.getConfig();
}
}
// Cannot really assert on the value of the Uber-trace-id header, because the APIs don't
// give us access to that. Verifying that the Uber-trace-id header is being sent should
// be good enough though.
assertNotNull(traceId.get());
}
use of org.projectnessie.client.api.NessieApiV1 in project nessie by projectnessie.
the class TestNessieHttpClient method testNotFoundOnBaseUri.
@Test
void testNotFoundOnBaseUri() throws IOException {
try (TestServer server = errorServer(404)) {
NessieApiV1 api = HttpClientBuilder.builder().withUri(server.getUri().resolve("/unknownPath")).build(NessieApiV1.class);
assertThatThrownBy(api::getConfig).isInstanceOf(RuntimeException.class).hasMessageContaining("Not Found");
}
}
use of org.projectnessie.client.api.NessieApiV1 in project nessie by projectnessie.
the class TestNessieHttpClient method testInternalServerError.
@Test
void testInternalServerError() throws IOException {
try (TestServer server = errorServer(500)) {
NessieApiV1 api = HttpClientBuilder.builder().withUri(server.getUri().resolve("/broken")).build(NessieApiV1.class);
assertThatThrownBy(api::getConfig).isInstanceOf(NessieInternalServerException.class).hasMessageContaining("Internal Server Error");
}
}
Aggregations