Skip to content

2.0 beta #30

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 10 commits into from
Nov 30, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
removing the stack from the logs
  • Loading branch information
clun committed Nov 30, 2024
commit 4d832cf1813a8ccc99f88a64c6fc1eb86170711a
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@
* #L%
*/

import com.fasterxml.jackson.annotation.JsonIgnore;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import lombok.Getter;
import lombok.Setter;

Expand All @@ -30,6 +32,7 @@
*/
@Getter
@Setter
@JsonIgnoreProperties({"stackTrace", "suppressed", "cause", "localizedMessage"})
public class DataAPIErrorDescriptor extends RuntimeException {

/**
Expand Down Expand Up @@ -77,6 +80,7 @@ public DataAPIErrorDescriptor() {
* @return A concatenated string representing the full error message, which may include the exception class name,
* the error code in parentheses, and the detailed error message. Each element is included only if it is not {@code null}.
*/
@JsonIgnore
public String getErrorMessage() {
StringBuilder sb = new StringBuilder();
if (exceptionClass != null) {
Expand All @@ -90,4 +94,11 @@ public String getErrorMessage() {
}
return sb.toString().trim();
}

@Override
@JsonIgnore
public String getLocalizedMessage() {
return super.getLocalizedMessage();
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -152,10 +152,10 @@ public EntityBeanDefinition(Class<T> clazz) {
}

/**
* Build the partition Key based on annotated fields.
* Build the partition Key based on annotated fields with @PartitionBy with position.
*
* @return
* list of partition keys
* An ordered list of partition keys (partition key)
*/
public List<String> getPartitionBy() {
return getFields().values().stream()
Expand All @@ -171,10 +171,10 @@ public List<String> getPartitionBy() {
}

/**
* Build the clustering Key based on annotated fields.
* Build the partition sort based on annotated fields @PartitionSort with position and order.
*
* @return
* list of clustering keys
* an ordered map representing the partition sort (clustering columns)
*/
public Map<String, Integer> getPartitionSort() {
List<EntityFieldDefinition> fields = getFields().values().stream()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,9 @@
*/

import com.datastax.astra.client.collections.documents.Document;
import com.datastax.astra.client.core.commands.Command;
import com.datastax.astra.client.exception.DataAPIErrorDescriptor;
import com.datastax.astra.client.exception.UnexpectedDataAPIResponseException;
import com.datastax.astra.internal.serdes.DataAPISerializer;
import com.datastax.astra.internal.utils.Assert;
import com.fasterxml.jackson.annotation.JsonIgnore;
Expand Down Expand Up @@ -89,7 +91,9 @@ public DataAPIResponse() {
*/
@SuppressWarnings("unchecked")
public Stream<String> getStatusKeyAsStringStream(@NonNull String key) {
Assert.isTrue(status.containsKey(key), "Key not found in status map");
if (!status.containsKey(key)) {
throw new UnexpectedDataAPIResponseException(new Command(), this, "Key '" + key + "' has not been found in response.");
}
return ((ArrayList<String>) status.get(key)).stream();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,9 +45,18 @@ public abstract class AbstractDatabaseTest extends AbstractDataAPITest {
// --------- Collections --------------
// ------------------------------------

public void cleanupCollections() {
// Removing a few collections to test mores elements
getDatabase().listCollectionNames().forEach(c -> {
System.out.println("Dropping collection ..." + c);
getDatabase().dropCollection(c);
});
}

@Test
@Order(1)
public void shouldCreateCollectionSimple() {
cleanupCollections();
// When
getDatabase().createCollection(COLLECTION_SIMPLE);
assertThat(getDatabase().collectionExists(COLLECTION_SIMPLE)).isTrue();
Expand Down Expand Up @@ -227,8 +236,6 @@ public void shouldCollectionWorkWithUUIDs() {
resultsList.getInsertedIds().forEach(id -> assertThat(id).isInstanceOf(UUID.class));
}



@Test
@Order(11)
public void shouldCollectionWorkWithObjectIds() {
Expand Down Expand Up @@ -263,13 +270,14 @@ public void shouldCollectionWorkWithObjectIds() {
product.setCode(UUID.randomUUID());
product.setPrice(0d);
Collection<ProductObjectId> collectionObjectId = getDatabase().createCollection(COLLECTION_OBJECTID,
new CollectionDefinition().defaultId(OBJECT_ID), ProductObjectId.class);
new CollectionDefinition().defaultId(OBJECT_ID), ProductObjectId.class);
collectionObjectId.deleteAll();
collectionObjectId.insertOne(product);
Optional<ProductObjectId> productObjectId = collectionObjectId.findOne(eq(product.getId()));
assertThat(productObjectId).isPresent();
}


@Test
@Order(12)
public void shouldCollectionWorkWithUUIDv6() {
Expand Down Expand Up @@ -302,6 +310,7 @@ public void shouldCollectionWorkWithUUIDv6() {
@Test
@Order(13)
public void shouldCollectionWorkWithUUIDv7() {
cleanupCollections();
// When
Collection<Document> collectionUUID = getDatabase()
.createCollection(COLLECTION_UUID_V7, new CollectionDefinition()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,12 @@
import com.datastax.astra.client.core.options.DataAPIClientOptions;
import com.datastax.astra.client.databases.Database;
import com.datastax.astra.client.core.auth.UsernamePasswordTokenProvider;
import com.datastax.astra.client.exception.DataAPIException;
import com.datastax.astra.client.exception.DataAPIResponseException;
import com.datastax.astra.client.core.commands.Command;
import com.datastax.astra.client.collections.documents.Document;
import com.datastax.astra.client.core.http.HttpProxy;
import com.datastax.astra.client.exception.UnexpectedDataAPIResponseException;
import com.datastax.astra.test.integration.AbstractDatabaseTest;
import com.dtsx.astra.sdk.db.domain.CloudProviderType;
import com.dtsx.astra.sdk.utils.AstraEnvironment;
Expand Down Expand Up @@ -56,10 +58,8 @@ void shouldRunInvalidCommand() {
//getDatabase().registerListener("demo", new MockCommandObserver());
getDatabase().runCommand(new Command("invalid", new Document()));
//getDatabase().deleteListener("demo");
} catch(DataAPIResponseException dat) {
assertThat(dat.getMessage()).contains("No \"invalid\" command found ");
assertThat(dat.getApiErrors()).isNotEmpty();
assertThat(dat.getCommandsList()).isNotEmpty();
} catch(DataAPIException dat) {
assertThat(dat.getMessage()).contains("COMMAND_UNKNOWN");;
}
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.datastax.astra.test.integration.local;
package com.datastax.astra.test.unit;

import com.datastax.astra.client.DataAPIClients;
import com.datastax.astra.client.core.query.Filter;
Expand Down
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy