Skip to content

Commit

Permalink
fixed find with boolean
Browse files Browse the repository at this point in the history
  • Loading branch information
NehaSelvan1512 committed Sep 25, 2023
1 parent e3042b4 commit d763c08
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -781,6 +781,8 @@ private static Object transformBsonToPrimitive( BsonValue doc ) {
return doc.asDocument().entrySet().stream().collect( Collectors.toMap( Entry::getKey, e -> transformBsonToPrimitive( e.getValue() ) ) );
case ARRAY:
return doc.asArray().stream().map( MqlFunctions::transformBsonToPrimitive ).collect( Collectors.toList() );
case BOOLEAN:
return doc.asBoolean().getValue();
default:
return null;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,9 +78,9 @@ private AlgRoot processMqlQuery() {
} else if ( isNumber( msg ) ) {
double value = Double.parseDouble( msg );
msgDoc = new BsonDocument( "$$ROOT", new BsonDouble( value ) );
/*} else if ( isBoolean( msg ) ) {
} else if ( isBoolean( msg ) ) {
boolean value = Boolean.parseBoolean( msg );
msgDoc = new BsonDocument( "$$ROOT", new BsonBoolean( value ) );*/
msgDoc = new BsonDocument( "$$ROOT", new BsonBoolean( value ) );
} else {
// msg is String
msgDoc = new BsonDocument( "$$ROOT", new BsonString( msg ) );
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -190,5 +190,17 @@ public void filterTestForJsonStringMessage2() {
assertTrue( streamProcessor.applyFilter());
}

//TODO: remove this test:
@Test
public void nestedDoctest() {
Transaction transaction = TestHelper.getInstance().getTransaction();
Statement st = transaction.createStatement();
String filterQuery = "{\"mqtt.status\":\"online\"}";
MqttMessage mqttMessage = new MqttMessage( "{\"mqtt\":{\"status\":\"online\"}}", "button/battery");
FilteringMqttMessage filteringMqttMessage = new FilteringMqttMessage(mqttMessage, filterQuery );
MqttStreamProcessor streamProcessor = new MqttStreamProcessor( filteringMqttMessage, st );
assertTrue( streamProcessor.applyFilter());
}


}

0 comments on commit d763c08

Please sign in to comment.