Skip to content

Commit

Permalink
Update to Junit5
Browse files Browse the repository at this point in the history
  • Loading branch information
Jotschi committed May 24, 2023
1 parent 451da6e commit 8396b74
Show file tree
Hide file tree
Showing 10 changed files with 37 additions and 32 deletions.
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package io.metaloom.qdrant.client.http;

import org.junit.Test;
import org.junit.jupiter.api.Test;

import io.metaloom.qdrant.client.AbstractContainerTest;
import io.metaloom.qdrant.client.http.model.collection.CollectionCreateRequest;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
import java.time.Duration;
import java.util.concurrent.atomic.AtomicReference;

import org.junit.Test;
import org.junit.jupiter.api.Test;

import io.metaloom.qdrant.client.AbstractContainerTest;
import io.metaloom.qdrant.client.http.model.collection.CollectionCreateRequest;
Expand All @@ -26,31 +26,33 @@ public void testCustomClient() throws Exception {
OkHttpClient customClient = createCustomOkClient(interceptedUrl);

try (QDrantHttpClient client = QDrantHttpClient.builder()
.setHostname(host)
.setOkHttpClient(customClient)
.setPort(port)
.build()) {
.setHostname(host)
.setOkHttpClient(customClient)
.setPort(port)
.build()) {

// Create a collection
CollectionCreateRequest req = new CollectionCreateRequest();
req.setVectors("colors", 4, Distance.EUCLID);
client.createCollection("the-collection-name", req)
.sync();
.sync();
assertEquals("The intercetor did not catch the correct url", "/collections/the-collection-name", interceptedUrl.get()
.encodedPath()
.toString());
.encodedPath()
.toString());
}
}

@Test(expected = RuntimeException.class)
@Test
public void testConflictingBuildParams() {
try (QDrantHttpClient client = QDrantHttpClient.builder()
org.junit.jupiter.api.Assertions.assertThrows(RuntimeException.class, () -> {
try (QDrantHttpClient client = QDrantHttpClient.builder()
.setHostname("localhost")
.setOkHttpClient(createCustomOkClient(null))
.setConnectTimeout(Duration.ofMinutes(1))
.setPort(123)
.build()) {
}
}
});
}

private OkHttpClient createCustomOkClient(AtomicReference<HttpUrl> interceptedUrl) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@

import java.util.List;

import org.junit.Ignore;
import org.junit.Test;
import org.junit.jupiter.api.Disabled;
import org.junit.jupiter.api.Test;

import io.metaloom.qdrant.client.http.AbstractHTTPClientTest;
import io.metaloom.qdrant.client.http.model.collection.AliasDescription;
Expand Down Expand Up @@ -43,7 +43,7 @@ public void testCreateCollectionWithUnnamedVectorParams() throws Exception {
}

@Test
@Ignore
@Disabled
public void testCreateMultipleCollections() throws Exception {
CollectionCreateRequest request = new CollectionCreateRequest();
request.setVectors(VectorParams.of(4, EUCLID));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
import java.nio.file.StandardCopyOption;
import java.util.List;

import org.junit.Ignore;
import org.junit.jupiter.api.Disabled;
import org.junit.jupiter.api.Test;

import io.metaloom.qdrant.client.http.AbstractHTTPClientTest;
Expand Down Expand Up @@ -147,7 +147,7 @@ public void testDownloadStorageSnapshot() throws Exception {

@Test
@Override
@Ignore("It is unclear how to recover from a storage snapshot. No endpoint defined.")
@Disabled("It is unclear how to recover from a storage snapshot. No endpoint defined.")
public void testRecoverStorageSnapshot() throws Exception {

}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;

import org.junit.Test;
import org.junit.jupiter.api.Test;

import io.metaloom.qdrant.client.http.model.cluster.ClusterStatusResponse;
import io.metaloom.qdrant.client.http.model.cluster.CollectionUpdateClusterSetupRequest;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;

import org.junit.Test;
import org.junit.jupiter.api.Test;

import io.metaloom.qdrant.client.http.model.collection.CollectionCreateRequest;
import io.metaloom.qdrant.client.http.model.collection.CollectionResponse;
Expand All @@ -17,7 +17,6 @@
import io.metaloom.qdrant.client.http.model.collection.config.VectorParams;
import io.metaloom.qdrant.client.http.model.collection.config.VectorsConfig;
import io.metaloom.qdrant.client.http.model.collection.schema.CollectionCreateIndexFieldRequest;
import io.metaloom.qdrant.client.http.model.collection.schema.recommend.CollectionRecommendPointsResponse;
import io.metaloom.qdrant.client.json.Json;

public class CollectionModelTest extends AbstractModelTest {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package io.metaloom.qdrant.client.http.model;

import org.junit.Test;
import org.junit.jupiter.api.Test;

import io.metaloom.qdrant.client.http.model.service.ServiceTelemetryResponse;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,15 +1,14 @@
package io.metaloom.qdrant.client.http.model;

import static io.metaloom.qdrant.client.http.model.snapshot.SnapshotPriority.SNAPSHOT;
import static org.junit.Assert.assertEquals;

import org.junit.Test;
import org.junit.jupiter.api.Test;

import io.metaloom.qdrant.client.http.model.snapshot.SnapshotListResponse;
import io.metaloom.qdrant.client.http.model.snapshot.SnapshotRecoverRequest;
import io.metaloom.qdrant.client.http.model.snapshot.SnapshotResponse;

import static io.metaloom.qdrant.client.http.model.snapshot.SnapshotPriority.SNAPSHOT;

public class SnapshotModelTest extends AbstractModelTest {

@Test
Expand Down
2 changes: 1 addition & 1 deletion http/src/test/java/io/metaloom/qdrant/json/JsonTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertTrue;

import org.junit.Test;
import org.junit.jupiter.api.Test;

import com.fasterxml.jackson.databind.JsonNode;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,23 +2,28 @@

import java.util.UUID;

import org.junit.Test;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.Test;

import io.metaloom.qdrant.client.http.model.point.PointIdLong;
import io.metaloom.qdrant.client.util.QDrantClientUtil;

public class QDrantClientUtilTest {

@Test(expected = NullPointerException.class)
@Test
public void testAssertPoint() {
QDrantClientUtil.assertPointId(new PointIdLong());
QDrantClientUtil.assertPointId(null);
Assertions.assertThrows(NullPointerException.class, () -> {
QDrantClientUtil.assertPointId(new PointIdLong());
QDrantClientUtil.assertPointId(null);
});
}

@Test(expected = NullPointerException.class)
@Test
public void testUUID() {
QDrantClientUtil.assertUuid(UUID.randomUUID());
QDrantClientUtil.assertUuid(null);
Assertions.assertThrows(NullPointerException.class, () -> {
QDrantClientUtil.assertUuid(UUID.randomUUID());
QDrantClientUtil.assertUuid(null);
});
}

}

0 comments on commit 8396b74

Please sign in to comment.