Search in sources :

Example 1 with Sample

use of dev.morphia.aggregation.experimental.stages.Sample in project morphia by mongodb.

the class CodecStructureTest method testSample.

@Test
public void testSample() {
    DocumentWriter writer = new DocumentWriter(getMapper());
    getDs().getCodecRegistry().get(Sample.class).encode(writer, Sample.sample(15L), EncoderContext.builder().build());
    Document actual = writer.getDocument();
    assertEquals(((Document) actual.get("$sample")).getLong("size").longValue(), 15L);
}
Also used : DocumentWriter(dev.morphia.mapping.codec.writer.DocumentWriter) Sample(dev.morphia.aggregation.experimental.stages.Sample) Document(org.bson.Document) Test(org.testng.annotations.Test)

Aggregations

Sample (dev.morphia.aggregation.experimental.stages.Sample)1 DocumentWriter (dev.morphia.mapping.codec.writer.DocumentWriter)1 Document (org.bson.Document)1 Test (org.testng.annotations.Test)1