@@ -1174,4 +1174,66 @@ public void testSyncLifeCycleQuery() throws InterruptedException {
11741174 // Check the last Life Cycle State is SYNCHRONIZED
11751175 assertEquals (LifeCycleState .SYNCHRONIZED , ((LifeCycleVariationRecord )resultList .get (0 )).getLifeCycleState ());
11761176 }
1177+
1178+ @ Test
1179+ @ Order (14 )
1180+ public void testDigitalAdapterQueryExecutorSync () throws WldtConfigurationException , EventBusException , ModelException , InterruptedException , WldtRuntimeException , StorageException {
1181+
1182+ //Set EventBus Logger
1183+ WldtEventBus .getInstance ().setEventLogger (new DefaultWldtEventLogger ());
1184+
1185+ //Wait until all the messages have been received
1186+ Thread .sleep ((DemoPhysicalAdapter .DEFAULT_MESSAGE_SLEEP_PERIOD_MS + ((DemoPhysicalAdapter .DEFAULT_TARGET_PHYSICAL_ASSET_PROPERTY_UPDATE_MESSAGES + DemoPhysicalAdapter .DEFAULT_TARGET_PHYSICAL_ASSET_EVENT_UPDATES ) * DemoPhysicalAdapter .DEFAULT_MESSAGE_SLEEP_PERIOD_MS )));
1187+
1188+ Thread .sleep (5000 );
1189+
1190+ // Create Query Request to the Storage Manager for the Last Digital Twin State
1191+ QueryRequest queryRequest = new QueryRequest ();
1192+ queryRequest .setResourceType (QueryResourceType .DIGITAL_TWIN_STATE );
1193+ queryRequest .setRequestType (QueryRequestType .LAST_VALUE );
1194+
1195+ // Send the Query Request to the Storage Manager for the target DT
1196+ QueryResult <?> queryResult = digitalAdapter .testSyncQuery (queryRequest );
1197+
1198+ assertNotNull (queryResult );
1199+ assertEquals (queryResult .getOriginalRequest ().getRequestType (), QueryRequestType .LAST_VALUE );
1200+ assertEquals (queryResult .getOriginalRequest ().getResourceType (), QueryResourceType .DIGITAL_TWIN_STATE );
1201+
1202+ }
1203+
1204+ @ Test
1205+ @ Order (15 )
1206+ public void testDigitalAdapterQueryExecutorAsync () throws InterruptedException {
1207+
1208+ //Set EventBus Logger
1209+ WldtEventBus .getInstance ().setEventLogger (new DefaultWldtEventLogger ());
1210+
1211+ //Wait until all the messages have been received
1212+ Thread .sleep ((DemoPhysicalAdapter .DEFAULT_MESSAGE_SLEEP_PERIOD_MS + ((DemoPhysicalAdapter .DEFAULT_TARGET_PHYSICAL_ASSET_PROPERTY_UPDATE_MESSAGES + DemoPhysicalAdapter .DEFAULT_TARGET_PHYSICAL_ASSET_EVENT_UPDATES ) * DemoPhysicalAdapter .DEFAULT_MESSAGE_SLEEP_PERIOD_MS )));
1213+
1214+ Thread .sleep (5000 );
1215+
1216+ // Create Query Request to the Storage Manager for the Last Digital Twin State
1217+ QueryRequest queryRequest = new QueryRequest ();
1218+ queryRequest .setResourceType (QueryResourceType .DIGITAL_TWIN_STATE );
1219+ queryRequest .setRequestType (QueryRequestType .LAST_VALUE );
1220+
1221+ final QueryResult <?>[] receivedQueryResult = {null };
1222+
1223+ // Send the Query Request to the Storage Manager for the target DT
1224+ digitalAdapter .testAsyncQuery (queryRequest , new IQueryResultListener () {
1225+ @ Override
1226+ public void onQueryResult (QueryResult <?> queryResult ) {
1227+ receivedQueryResult [0 ] = queryResult ;
1228+ }
1229+ });
1230+
1231+ Thread .sleep (5000 );
1232+
1233+ assertNotNull (receivedQueryResult [0 ]);
1234+ assertEquals (receivedQueryResult [0 ].getOriginalRequest ().getRequestType (), QueryRequestType .LAST_VALUE );
1235+ assertEquals (receivedQueryResult [0 ].getOriginalRequest ().getResourceType (), QueryResourceType .DIGITAL_TWIN_STATE );
1236+
1237+ Thread .sleep (10000 );
1238+ }
11771239}
0 commit comments