Skip to content

Commit

Permalink
Prepare implementation of $geoNear stage #138
Browse files Browse the repository at this point in the history
  • Loading branch information
bwaldvogel committed May 23, 2020
1 parent f2e508e commit 0082800
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@
import de.bwaldvogel.mongo.bson.Document;
import de.bwaldvogel.mongo.exception.FailedToParseException;
import de.bwaldvogel.mongo.exception.MongoServerError;
import de.bwaldvogel.mongo.exception.MongoServerNotYetImplementedException;
import de.bwaldvogel.mongo.exception.TypeMismatchException;

public class Aggregation {
Expand Down Expand Up @@ -157,6 +158,8 @@ private static Aggregation fromPipeline(List<Document> pipeline, MongoDatabase d
Document redactExpression = (Document) stage.get(stageOperation);
aggregation.addStage(new RedactStage(redactExpression));
break;
case "$geoNear":
throw new MongoServerNotYetImplementedException(138, stageOperation);
default:
throw new MongoServerError(40324, "Unrecognized pipeline stage name: '" + stageOperation + "'");
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1955,6 +1955,16 @@ void testAggregateWithRedact() {
.containsOnly(json("_id: 1"));
}

// https://github.com/bwaldvogel/mongo-java-server/issues/138
@Test
public void testAggregateWithGeoNear() throws Exception {
List<Document> pipeline = jsonList("$geoNear: {}");

assertThatExceptionOfType(MongoCommandException.class)
.isThrownBy(() -> collection.aggregate(pipeline).first())
.withMessageContaining("Command failed with error -1: '$geoNear is not yet implemented. See https://github.com/bwaldvogel/mongo-java-server/issues/138'");
}

private static Function<Document, Document> withSortedStringList(String key) {
return document -> {
@SuppressWarnings("unchecked")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import java.net.InetSocketAddress;

import org.junit.Assume;
import org.junit.jupiter.api.AfterAll;
import org.junit.jupiter.api.BeforeAll;
import org.testcontainers.containers.GenericContainer;
Expand Down Expand Up @@ -33,4 +34,9 @@ protected MongoBackend createBackend() throws Exception {
throw new UnsupportedOperationException();
}

@Override
public void testAggregateWithGeoNear() throws Exception {
Assume.assumeTrue(false);
super.testAggregateWithGeoNear();
}
}

0 comments on commit 0082800

Please sign in to comment.