use of org.projectnessie.model.ContentKey in project nessie by projectnessie.
the class AbstractRestMergeTransplant method mergeWithNamespaces.
@ParameterizedTest
@EnumSource(value = ReferenceMode.class, mode = Mode.EXCLUDE, // merge requires the hash
names = "NAME_ONLY")
public void mergeWithNamespaces(ReferenceMode refMode) throws BaseNessieClientServerException {
Branch base = createBranch("merge-base");
Branch branch = createBranch("merge-branch");
Namespace ns = Namespace.parse("a.b.c");
// create the same namespace on both branches
getApi().createNamespace().namespace(ns).refName(branch.getName()).create();
getApi().createNamespace().namespace(ns).refName(base.getName()).create();
IcebergTable table1 = IcebergTable.of("merge-table1", 42, 42, 42, 42);
IcebergTable table2 = IcebergTable.of("merge-table2", 43, 43, 43, 43);
ContentKey key1 = ContentKey.of(ns, "key1");
ContentKey key2 = ContentKey.of(ns, "key2");
Branch committed1 = getApi().commitMultipleOperations().branchName(branch.getName()).hash(branch.getHash()).commitMeta(CommitMeta.fromMessage("test-merge-branch1")).operation(Put.of(key1, table1)).commit();
assertThat(committed1.getHash()).isNotNull();
Branch committed2 = getApi().commitMultipleOperations().branchName(branch.getName()).hash(committed1.getHash()).commitMeta(CommitMeta.fromMessage("test-merge-branch2")).operation(Put.of(key1, table1, table1)).commit();
assertThat(committed2.getHash()).isNotNull();
getApi().commitMultipleOperations().branchName(base.getName()).hash(base.getHash()).commitMeta(CommitMeta.fromMessage("test-merge-main")).operation(Put.of(key2, table2)).commit();
getApi().mergeRefIntoBranch().branch(base).fromRef(refMode.transform(committed2)).merge();
LogResponse log = getApi().getCommitLog().refName(base.getName()).untilHash(base.getHash()).get();
assertThat(log.getLogEntries().stream().map(LogEntry::getCommitMeta).map(CommitMeta::getMessage)).containsExactly("test-merge-branch2", "test-merge-branch1", "create namespace a.b.c", "test-merge-main", "create namespace a.b.c");
assertThat(getApi().getEntries().refName(base.getName()).get().getEntries().stream().map(Entry::getName)).containsExactlyInAnyOrder(key1, key2, ContentKey.of(ns.getElements()));
assertThat(getApi().getNamespace().refName(base.getName()).namespace(ns).get()).isNotNull();
}
use of org.projectnessie.model.ContentKey in project nessie by projectnessie.
the class AbstractRestContents method verifyContentAndOperationTypesIndividually.
@ParameterizedTest
@MethodSource("contentAndOperationTypes")
public void verifyContentAndOperationTypesIndividually(ContentAndOperationType contentAndOperationType) throws BaseNessieClientServerException {
Branch branch = createBranch("contentAndOperation_" + contentAndOperationType);
CommitMultipleOperationsBuilder commit = getApi().commitMultipleOperations().branch(branch).commitMeta(CommitMeta.fromMessage("commit " + contentAndOperationType)).operation(contentAndOperationType.operation);
if (contentAndOperationType.globalOperation != null) {
commit.operation(contentAndOperationType.globalOperation);
}
commit.commit();
List<Entry> entries = getApi().getEntries().refName(branch.getName()).get().getEntries();
// Oh, yea - this is weird. The property ContentAndOperationType.operation.key.namespace is null
// (!!!)
// here, because somehow JUnit @MethodSource implementation re-constructs the objects returned
// from
// the source-method contentAndOperationTypes.
ContentKey fixedContentKey = ContentKey.of(contentAndOperationType.operation.getKey().getElements());
List<Entry> expect = contentAndOperationType.operation instanceof Put ? singletonList(Entry.builder().name(fixedContentKey).type(contentAndOperationType.type).build()) : emptyList();
assertThat(entries).containsExactlyInAnyOrderElementsOf(expect);
}
use of org.projectnessie.model.ContentKey in project nessie by projectnessie.
the class AbstractResteasyTest method testGetRefLog.
@Test
public void testGetRefLog() {
Branch branch = makeBranch("branch-temp");
IcebergTable table = IcebergTable.of("content-table", 42, 42, 42, 42);
ContentKey contentKey = ContentKey.of("key1");
commit(contentKey, table, branch, "code");
RefLogResponse refLogResponse = rest().get("reflogs").then().statusCode(200).extract().as(RefLogResponse.class);
assertThat(refLogResponse.getLogEntries().get(0).getOperation()).isEqualTo("COMMIT");
assertThat(refLogResponse.getLogEntries().get(0).getRefName()).isEqualTo("branch-temp");
assertThat(refLogResponse.getLogEntries().get(1).getOperation()).isEqualTo("CREATE_REFERENCE");
assertThat(refLogResponse.getLogEntries().get(1).getRefName()).isEqualTo("branch-temp");
RefLogResponse refLogResponse1 = rest().queryParam("endHash", refLogResponse.getLogEntries().get(1).getRefLogId()).get("reflogs").then().statusCode(200).extract().as(RefLogResponse.class);
assertThat(refLogResponse1.getLogEntries().get(0).getRefLogId()).isEqualTo(refLogResponse.getLogEntries().get(1).getRefLogId());
}
use of org.projectnessie.model.ContentKey in project nessie by projectnessie.
the class AbstractResteasyTest method testGetDiff.
@Test
public void testGetDiff() {
Branch fromBranch = makeBranch("getdiff-test-from");
Branch toBranch = makeBranch("getdiff-test-to");
IcebergTable fromTable = IcebergTable.of("content-table", 42, 42, 42, 42);
IcebergTable toTable = IcebergTable.of("content-table", 43, 43, 43, 43);
ContentKey contentKey = ContentKey.of("key1");
commit(contentKey, fromTable, fromBranch, "diffAuthor");
commit(contentKey, toTable, toBranch, "diffAuthor2");
DiffResponse diffResponse = rest().get(String.format("diffs/%s...%s", fromBranch.getName(), toBranch.getName())).then().statusCode(200).extract().as(DiffResponse.class);
assertThat(diffResponse).isNotNull();
assertThat(diffResponse.getDiffs()).hasSize(1);
DiffEntry diff = diffResponse.getDiffs().get(0);
assertThat(diff.getKey()).isEqualTo(contentKey);
assertThat(diff.getFrom()).isEqualTo(fromTable);
assertThat(diff.getTo()).isEqualTo(toTable);
}
use of org.projectnessie.model.ContentKey in project nessie by projectnessie.
the class TreeApiImpl method truncate.
private EntriesResponse.Entry truncate(EntriesResponse.Entry entry, Integer depth) {
if (depth == null || depth < 1) {
return entry;
}
Type type = entry.getName().getElements().size() > depth ? Type.NAMESPACE : entry.getType();
ContentKey key = ContentKey.of(entry.getName().getElements().subList(0, depth));
return EntriesResponse.Entry.builder().type(type).name(key).build();
}
Aggregations