Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
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
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,8 @@
import com.mongodb.client.model.Aggregates;
import com.mongodb.client.model.ChangeStreamPreAndPostImagesOptions;
import com.mongodb.client.model.CreateCollectionOptions;
import com.mongodb.client.model.TimeSeriesOptions;
import com.mongodb.client.model.changestream.ChangeStreamDocument;
import com.mongodb.client.model.changestream.FullDocumentBeforeChange;
import com.mongodb.client.model.changestream.NamespaceType;
import com.mongodb.client.model.changestream.SplitEvent;
import com.mongodb.internal.operation.AggregateResponseBatchCursor;
import org.bson.BsonArray;
Expand All @@ -46,14 +44,12 @@
import static com.mongodb.client.CrudTestHelper.repeat;
import static com.mongodb.client.model.Updates.set;
import static java.util.Arrays.asList;
import static java.util.Collections.singletonList;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertNotEquals;
import static org.junit.jupiter.api.Assertions.assertNotNull;
import static org.junit.jupiter.api.Assertions.assertNull;
import static org.junit.jupiter.api.Assertions.assertTrue;
import static org.junit.jupiter.api.Assertions.fail;
import static org.junit.jupiter.api.Assumptions.assumeFalse;
import static org.junit.jupiter.api.Assumptions.assumeTrue;


Expand Down Expand Up @@ -359,51 +355,6 @@ public void test19SplitChangeStreamEvents() {
}
}

/**
* Not a prose spec test. However, it is additional test case for better coverage.
*/
@Test
public void testNameSpaceTypePresentChangeStreamEvents() {
assumeTrue(serverVersionAtLeast(8, 1));
// TODO-JAVA-6181 temp disabling as failing on latest, while specs are updated
assumeFalse(serverVersionAtLeast(9, 0));
collection.drop();

ChangeStreamIterable<Document> changeStream = database
.watch()
.fullDocumentBeforeChange(FullDocumentBeforeChange.REQUIRED)
.showExpandedEvents(true);

try (MongoChangeStreamCursor<ChangeStreamDocument<Document>> cursor = changeStream.cursor()) {

TimeSeriesOptions timeSeriesOptions = new TimeSeriesOptions("timestampFieldName");
database.createCollection(
"timeSeriesCollection",
new CreateCollectionOptions().timeSeriesOptions(timeSeriesOptions)
);
database.createCollection(
getClass().getName(),
new CreateCollectionOptions().changeStreamPreAndPostImagesOptions(
new ChangeStreamPreAndPostImagesOptions(true)));
database.createView(
"view",
"timeSeriesCollection",
singletonList(Document.parse("{ $match: { field: 1 } }"))
);

ChangeStreamDocument<Document> e1 = Assertions.assertNotNull(cursor.tryNext());
ChangeStreamDocument<Document> e2 = Assertions.assertNotNull(cursor.tryNext());
ChangeStreamDocument<Document> e3 = Assertions.assertNotNull(cursor.tryNext());

assertEquals(NamespaceType.TIMESERIES, e1.getNamespaceType());
assertEquals(NamespaceType.TIMESERIES.getValue(), e1.getNamespaceTypeString());
assertEquals(NamespaceType.COLLECTION, e2.getNamespaceType());
assertEquals(NamespaceType.COLLECTION.getValue(), e2.getNamespaceTypeString());
assertEquals(NamespaceType.VIEW, e3.getNamespaceType());
assertEquals(NamespaceType.VIEW.getValue(), e3.getNamespaceTypeString());
}
}

/**
* Not a prose spec test. However, it is additional test case for better coverage.
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,6 @@ public static void applyCustomizations(final TestDef def) {
def.skipNoncompliantReactive("event sensitive tests. We can't guarantee the amount of GetMore commands sent in the reactive driver")
.test("change-streams", "change-streams", "Test that comment is set on getMore")
.test("change-streams", "change-streams", "Test that comment is not set on getMore - pre 4.4");
def.skipJira("https://jira.mongodb.org/browse/JAVA-6181 temp disabling as failing on latest, while specs are updated")
.test("change-streams", "change-streams-nsType", "nsType is present when creating timeseries");
def.modify(IGNORE_EXTRA_EVENTS)
.test("change-streams", "change-streams", "Test with document comment")
.test("change-streams", "change-streams", "Test with string comment");
Expand Down