Search in sources :

Example 11 with Namespace

use of org.projectnessie.model.Namespace in project nessie by projectnessie.

the class AbstractRestNamespace method testNamespaceDeletion.

@Test
public void testNamespaceDeletion() throws BaseNessieClientServerException {
    Branch branch = createBranch("testNamespaceDeletion");
    CommitMultipleOperationsBuilder commit = getApi().commitMultipleOperations().branch(branch).commitMeta(CommitMeta.fromMessage("verifyAllContentAndOperationTypes"));
    contentAndOperationTypes().flatMap(c -> c.globalOperation == null ? Stream.of(c.operation) : Stream.of(c.operation, c.globalOperation)).forEach(commit::operation);
    commit.commit();
    List<Entry> entries = contentAndOperationTypes().filter(c -> c.operation instanceof Put).map(c -> Entry.builder().type(c.type).name(c.operation.getKey()).build()).collect(Collectors.toList());
    for (Entry e : entries) {
        Namespace namespace = e.getName().getNamespace();
        assertThat(getApi().getNamespace().refName(branch.getName()).namespace(namespace).get()).isEqualTo(namespace);
        assertThatThrownBy(() -> getApi().deleteNamespace().refName(branch.getName()).namespace(namespace).delete()).isInstanceOf(NessieNamespaceNotEmptyException.class).hasMessage(String.format("Namespace '%s' is not empty", namespace));
    }
}
Also used : Arrays(java.util.Arrays) NessieNamespaceNotEmptyException(org.projectnessie.error.NessieNamespaceNotEmptyException) LogResponse(org.projectnessie.model.LogResponse) Put(org.projectnessie.model.Operation.Put) NessieNamespaceAlreadyExistsException(org.projectnessie.error.NessieNamespaceAlreadyExistsException) Assertions.assertThat(org.assertj.core.api.Assertions.assertThat) Branch(org.projectnessie.model.Branch) LogEntry(org.projectnessie.model.LogResponse.LogEntry) Collectors(java.util.stream.Collectors) Entry(org.projectnessie.model.EntriesResponse.Entry) Test(org.junit.jupiter.api.Test) List(java.util.List) Stream(java.util.stream.Stream) Assertions.assertThatThrownBy(org.assertj.core.api.Assertions.assertThatThrownBy) IcebergTable(org.projectnessie.model.IcebergTable) Namespace(org.projectnessie.model.Namespace) NessieReferenceConflictException(org.projectnessie.error.NessieReferenceConflictException) BaseNessieClientServerException(org.projectnessie.error.BaseNessieClientServerException) ContentKey(org.projectnessie.model.ContentKey) CommitMeta(org.projectnessie.model.CommitMeta) CommitMultipleOperationsBuilder(org.projectnessie.client.api.CommitMultipleOperationsBuilder) NessieNamespaceNotFoundException(org.projectnessie.error.NessieNamespaceNotFoundException) LogEntry(org.projectnessie.model.LogResponse.LogEntry) Entry(org.projectnessie.model.EntriesResponse.Entry) CommitMultipleOperationsBuilder(org.projectnessie.client.api.CommitMultipleOperationsBuilder) NessieNamespaceNotEmptyException(org.projectnessie.error.NessieNamespaceNotEmptyException) Branch(org.projectnessie.model.Branch) Put(org.projectnessie.model.Operation.Put) Namespace(org.projectnessie.model.Namespace) Test(org.junit.jupiter.api.Test)

Example 12 with Namespace

use of org.projectnessie.model.Namespace in project nessie by projectnessie.

the class NamespaceParamsTest method testBuilder.

@Test
public void testBuilder() {
    Namespace namespace = Namespace.parse("a.b.c");
    NamespaceParams params = NamespaceParams.builder().refName("xx").namespace(namespace).build();
    assertThat(params.getRefName()).isEqualTo("xx");
    assertThat(params.getNamespace()).isEqualTo(namespace);
    assertThat(params.getHashOnRef()).isNull();
}
Also used : Namespace(org.projectnessie.model.Namespace) Test(org.junit.jupiter.api.Test)

Aggregations

Namespace (org.projectnessie.model.Namespace)12 Test (org.junit.jupiter.api.Test)6 Branch (org.projectnessie.model.Branch)6 CommitMeta (org.projectnessie.model.CommitMeta)5 NessieNamespaceAlreadyExistsException (org.projectnessie.error.NessieNamespaceAlreadyExistsException)4 NessieNamespaceNotFoundException (org.projectnessie.error.NessieNamespaceNotFoundException)4 Entry (org.projectnessie.model.EntriesResponse.Entry)4 IcebergTable (org.projectnessie.model.IcebergTable)4 LogResponse (org.projectnessie.model.LogResponse)4 LogEntry (org.projectnessie.model.LogResponse.LogEntry)4 NessieNamespaceNotEmptyException (org.projectnessie.error.NessieNamespaceNotEmptyException)3 NessieReferenceNotFoundException (org.projectnessie.error.NessieReferenceNotFoundException)3 ContentKey (org.projectnessie.model.ContentKey)3 Put (org.projectnessie.model.Operation.Put)3 BranchName (org.projectnessie.versioned.BranchName)3 ReferenceNotFoundException (org.projectnessie.versioned.ReferenceNotFoundException)3 List (java.util.List)2 Collectors (java.util.stream.Collectors)2 Stream (java.util.stream.Stream)2 NessieReferenceConflictException (org.projectnessie.error.NessieReferenceConflictException)2