use of org.bson.BsonDecimal128 in project mongo-java-driver by mongodb.
the class IdHoldingBsonWriter method writeDecimal128.
@Override
public void writeDecimal128(final Decimal128 value) {
addBsonValue(() -> new BsonDecimal128(value), () -> getIdBsonWriter().writeDecimal128(value));
super.writeDecimal128(value);
}
use of org.bson.BsonDecimal128 in project mongo-java-driver by mongodb.
the class TestWindows method rangeBased.
@Test
void rangeBased() {
assertAll(() -> assertEquals(new BsonDocument("range", new BsonArray(asList(new BsonInt64(-1), new BsonInt64(0)))), range(-1, 0).toBsonDocument()), () -> assertEquals(new BsonDocument("range", new BsonArray(asList(new BsonDouble(0), new BsonDouble(0)))), range(0d, 0d).toBsonDocument()), () -> assertEquals(new BsonDocument("range", new BsonArray(asList(new BsonDecimal128(new Decimal128(1)), new BsonDecimal128(new Decimal128(2))))), range(new Decimal128(1), new Decimal128(2)).toBsonDocument()), () -> assertEquals(new BsonDocument("range", new BsonArray(asList(new BsonString(CURRENT.value()), new BsonDouble(0.1)))), range(CURRENT, 0.1).toBsonDocument()), () -> assertEquals(new BsonDocument("range", new BsonArray(asList(new BsonDouble(0.1), new BsonString(UNBOUNDED.value())))), range(0.1, UNBOUNDED).toBsonDocument()), () -> assertEquals(new BsonDocument("range", new BsonArray(asList(new BsonString(CURRENT.value()), new BsonDecimal128(new Decimal128(Long.MAX_VALUE))))), range(CURRENT, new Decimal128(Long.MAX_VALUE)).toBsonDocument()), () -> assertEquals(new BsonDocument("range", new BsonArray(asList(new BsonDecimal128(new Decimal128(Long.MAX_VALUE)), new BsonString(UNBOUNDED.value())))), range(new Decimal128(Long.MAX_VALUE), UNBOUNDED).toBsonDocument()), () -> assertEquals(new BsonDocument("range", new BsonArray(asList(new BsonInt64(-1), new BsonInt64(0)))).append("unit", new BsonString("millisecond")), timeRange(-1, 0, MILLISECOND).toBsonDocument()), () -> assertEquals(new BsonDocument("range", new BsonArray(asList(new BsonString(CURRENT.value()), new BsonInt64(1)))).append("unit", new BsonString("hour")), timeRange(CURRENT, 1, HOUR).toBsonDocument()), () -> assertEquals(new BsonDocument("range", new BsonArray(asList(new BsonInt64(1), new BsonString(UNBOUNDED.value())))).append("unit", new BsonString("month")), timeRange(1, MONTH, UNBOUNDED).toBsonDocument()));
assertAll(() -> assertThrows(IllegalArgumentException.class, () -> range(1, -1)), () -> assertThrows(IllegalArgumentException.class, () -> range(null, 1)), () -> assertThrows(IllegalArgumentException.class, () -> range(null, 0.1)), () -> assertThrows(IllegalArgumentException.class, () -> range((Bound) null, Decimal128.POSITIVE_ZERO)), () -> assertThrows(IllegalArgumentException.class, () -> range(1, null)), () -> assertThrows(IllegalArgumentException.class, () -> range(0.1, null)), () -> assertThrows(IllegalArgumentException.class, () -> range(Decimal128.POSITIVE_ZERO, (Bound) null)), () -> assertThrows(IllegalArgumentException.class, () -> range((Decimal128) null, Decimal128.POSITIVE_ZERO)), () -> assertThrows(IllegalArgumentException.class, () -> range(Decimal128.POSITIVE_ZERO, (Decimal128) null)), () -> assertThrows(IllegalArgumentException.class, () -> range((Decimal128) null, (Decimal128) null)), () -> assertThrows(IllegalArgumentException.class, () -> timeRange(1, -1, MongoTimeUnit.DAY)), () -> assertThrows(IllegalArgumentException.class, () -> timeRange(1, 2, null)));
}
use of org.bson.BsonDecimal128 in project pinpoint by naver.
the class MongoDBITBase method insertComlexBsonValueData34.
public void insertComlexBsonValueData34(PluginTestVerifier verifier, MongoCollection<Document> collection, Class<?> mongoDatabaseImpl, String collectionInfo, String collectionOption) {
// insert Data
Document document = createComplexDocument();
document.append("decimal128", new BsonDecimal128(new Decimal128(55)));
collection.insertOne(document);
Method insertOneMethod = getMethod(mongoDatabaseImpl, "insertOne", Object.class);
NormalizedBson parsedBson = parseBson(document);
verifier.verifyTrace(event(MONGO_EXECUTE_QUERY, insertOneMethod, null, MongoDBITConstants.MONGODB_ADDRESS, null, new ExpectedAnnotation(MongoConstants.MONGO_COLLECTION_INFO.getName(), collectionInfo), new ExpectedAnnotation(MongoConstants.MONGO_COLLECTION_OPTION.getName(), collectionOption), new ExpectedAnnotation(MongoConstants.MONGO_JSON_DATA.getName(), new StringStringValue(parsedBson.getNormalizedBson(), parsedBson.getParameter()))));
}
Aggregations