Search in sources :

Example 6 with BsonDecimal128

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);
}
Also used : BsonDecimal128(org.bson.BsonDecimal128)

Example 7 with BsonDecimal128

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)));
}
Also used : BsonInt64(org.bson.BsonInt64) BsonDocument(org.bson.BsonDocument) BsonDecimal128(org.bson.BsonDecimal128) BsonString(org.bson.BsonString) BsonArray(org.bson.BsonArray) BsonDouble(org.bson.BsonDouble) BsonDecimal128(org.bson.BsonDecimal128) Decimal128(org.bson.types.Decimal128) Test(org.junit.jupiter.api.Test)

Example 8 with BsonDecimal128

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()))));
}
Also used : ExpectedAnnotation(com.navercorp.pinpoint.bootstrap.plugin.test.ExpectedAnnotation) BsonDecimal128(org.bson.BsonDecimal128) StringStringValue(com.navercorp.pinpoint.common.util.StringStringValue) NormalizedBson(com.navercorp.pinpoint.plugin.mongo.NormalizedBson) BsonDecimal128(org.bson.BsonDecimal128) Decimal128(org.bson.types.Decimal128) Method(java.lang.reflect.Method) Document(org.bson.Document) BsonDocument(org.bson.BsonDocument)

Aggregations

BsonDecimal128 (org.bson.BsonDecimal128)8 BsonDocument (org.bson.BsonDocument)5 Decimal128 (org.bson.types.Decimal128)5 Test (org.junit.Test)3 BsonArray (org.bson.BsonArray)2 BsonDouble (org.bson.BsonDouble)2 BsonInt64 (org.bson.BsonInt64)2 BsonString (org.bson.BsonString)2 Test (org.junit.jupiter.api.Test)2 JsonReader (com.google.gson.stream.JsonReader)1 BasicDBObject (com.mongodb.BasicDBObject)1 ExpectedAnnotation (com.navercorp.pinpoint.bootstrap.plugin.test.ExpectedAnnotation)1 StringStringValue (com.navercorp.pinpoint.common.util.StringStringValue)1 NormalizedBson (com.navercorp.pinpoint.plugin.mongo.NormalizedBson)1 Method (java.lang.reflect.Method)1 BigDecimal (java.math.BigDecimal)1 ArrayList (java.util.ArrayList)1 Date (java.util.Date)1 List (java.util.List)1 Map (java.util.Map)1