@@ -1267,63 +1267,17 @@ TEST_F(TestCodegenModelViaMocks, IterateOverAcceptedCommands)
1267
1267
CodegenDataModelProviderWithContext model;
1268
1268
1269
1269
// invalid paths should return in "no more data"
1270
- ASSERT_FALSE (model.FirstAcceptedCommand (ConcreteClusterPath (kEndpointIdThatIsMissing , MockClusterId (1 ))).path . HasValidIds ());
1271
- ASSERT_FALSE (model.FirstAcceptedCommand (ConcreteClusterPath (kInvalidEndpointId , MockClusterId (1 ))).path . HasValidIds ());
1272
- ASSERT_FALSE (model.FirstAcceptedCommand (ConcreteClusterPath (kMockEndpoint1 , MockClusterId (10 ))).path . HasValidIds ());
1273
- ASSERT_FALSE (model.FirstAcceptedCommand (ConcreteClusterPath (kMockEndpoint1 , kInvalidClusterId )).path . HasValidIds ());
1270
+ ASSERT_TRUE (model.AcceptedCommands (ConcreteClusterPath (kEndpointIdThatIsMissing , MockClusterId (1 ))).empty ());
1271
+ ASSERT_TRUE (model.AcceptedCommands (ConcreteClusterPath (kInvalidEndpointId , MockClusterId (1 ))).empty ());
1272
+ ASSERT_TRUE (model.AcceptedCommands (ConcreteClusterPath (kMockEndpoint1 , MockClusterId (10 ))).empty ());
1273
+ ASSERT_TRUE (model.AcceptedCommands (ConcreteClusterPath (kMockEndpoint1 , kInvalidClusterId )).empty ());
1274
1274
1275
- // should be able to iterate over valid paths
1276
- CommandEntry entry = model.FirstAcceptedCommand (ConcreteClusterPath (kMockEndpoint2 , MockClusterId (2 )));
1277
- ASSERT_TRUE (entry.path .HasValidIds ());
1278
- EXPECT_EQ (entry.path .mEndpointId , kMockEndpoint2 );
1279
- EXPECT_EQ (entry.path .mClusterId , MockClusterId (2 ));
1280
- EXPECT_EQ (entry.path .mCommandId , 1u );
1281
-
1282
- entry = model.NextAcceptedCommand (entry.path );
1283
- ASSERT_TRUE (entry.path .HasValidIds ());
1284
- EXPECT_EQ (entry.path .mEndpointId , kMockEndpoint2 );
1285
- EXPECT_EQ (entry.path .mClusterId , MockClusterId (2 ));
1286
- EXPECT_EQ (entry.path .mCommandId , 2u );
1287
-
1288
- entry = model.NextAcceptedCommand (entry.path );
1289
- ASSERT_TRUE (entry.path .HasValidIds ());
1290
- EXPECT_EQ (entry.path .mEndpointId , kMockEndpoint2 );
1291
- EXPECT_EQ (entry.path .mClusterId , MockClusterId (2 ));
1292
- EXPECT_EQ (entry.path .mCommandId , 23u );
1293
-
1294
- entry = model.NextAcceptedCommand (entry.path );
1295
- ASSERT_FALSE (entry.path .HasValidIds ());
1296
-
1297
- // attempt some out-of-order requests as well
1298
- entry = model.FirstAcceptedCommand (ConcreteClusterPath (kMockEndpoint2 , MockClusterId (3 )));
1299
- ASSERT_TRUE (entry.path .HasValidIds ());
1300
- EXPECT_EQ (entry.path .mEndpointId , kMockEndpoint2 );
1301
- EXPECT_EQ (entry.path .mClusterId , MockClusterId (3 ));
1302
- EXPECT_EQ (entry.path .mCommandId , 11u );
1303
-
1304
- for (int i = 0 ; i < 10 ; i++)
1305
- {
1306
- entry = model.NextAcceptedCommand (ConcreteCommandPath (kMockEndpoint2 , MockClusterId (2 ), 2 ));
1307
- ASSERT_TRUE (entry.path .HasValidIds ());
1308
- EXPECT_EQ (entry.path .mEndpointId , kMockEndpoint2 );
1309
- EXPECT_EQ (entry.path .mClusterId , MockClusterId (2 ));
1310
- EXPECT_EQ (entry.path .mCommandId , 23u );
1311
- }
1312
-
1313
- for (int i = 0 ; i < 10 ; i++)
1314
- {
1315
- entry = model.NextAcceptedCommand (ConcreteCommandPath (kMockEndpoint2 , MockClusterId (2 ), 1 ));
1316
- ASSERT_TRUE (entry.path .HasValidIds ());
1317
- EXPECT_EQ (entry.path .mEndpointId , kMockEndpoint2 );
1318
- EXPECT_EQ (entry.path .mClusterId , MockClusterId (2 ));
1319
- EXPECT_EQ (entry.path .mCommandId , 2u );
1320
- }
1321
-
1322
- for (int i = 0 ; i < 10 ; i++)
1323
- {
1324
- entry = model.NextAcceptedCommand (ConcreteCommandPath (kMockEndpoint2 , MockClusterId (3 ), 10 ));
1325
- EXPECT_FALSE (entry.path .HasValidIds ());
1326
- }
1275
+ MetadataList<DataModel::AcceptedCommandEntry> cmds =
1276
+ model.AcceptedCommands (ConcreteClusterPath (kMockEndpoint2 , MockClusterId (2 )));
1277
+ ASSERT_EQ (cmds.size (), 3u );
1278
+ ASSERT_EQ (cmds[0 ].commandId , 1u );
1279
+ ASSERT_EQ (cmds[1 ].commandId , 2u );
1280
+ ASSERT_EQ (cmds[2 ].commandId , 23u );
1327
1281
}
1328
1282
1329
1283
TEST_F (TestCodegenModelViaMocks, AcceptedCommandInfo)
@@ -1370,12 +1324,11 @@ TEST_F(TestCodegenModelViaMocks, IterateOverGeneratedCommands)
1370
1324
ASSERT_TRUE (model.GeneratedCommands (ConcreteClusterPath (kMockEndpoint1 , kInvalidClusterId )).empty ());
1371
1325
1372
1326
// should be able to iterate over valid paths
1373
-
1374
- MetadataList<CommandId> cmds = model.GeneratedCommands (ConcreteClusterPath (kMockEndpoint2 , MockClusterId (2 )));
1327
+ MetadataList<CommandId> cmds = model.GeneratedCommands (ConcreteClusterPath (kMockEndpoint2 , MockClusterId (2 )));
1375
1328
const CommandId expectedCommands2[] = { 2 , 10 };
1376
1329
ASSERT_TRUE (cmds.GetSpanValidForLifetime ().data_equal (Span<const CommandId>(expectedCommands2)));
1377
1330
1378
- cmds = model.GeneratedCommands (ConcreteClusterPath (kMockEndpoint2 , MockClusterId (3 )));
1331
+ cmds = model.GeneratedCommands (ConcreteClusterPath (kMockEndpoint2 , MockClusterId (3 )));
1379
1332
const CommandId expectedCommands3[] = { 4 , 6 };
1380
1333
ASSERT_TRUE (cmds.GetSpanValidForLifetime ().data_equal (Span<const CommandId>(expectedCommands3)));
1381
1334
}
@@ -1392,43 +1345,31 @@ TEST_F(TestCodegenModelViaMocks, CommandHandlerInterfaceAcceptedCommands)
1392
1345
1393
1346
// At this point, without overrides, there should be no accepted/generated commands
1394
1347
ASSERT_TRUE (model.GeneratedCommands (ConcreteClusterPath (kMockEndpoint1 , MockClusterId (1 ))).empty ());
1395
- EXPECT_FALSE (model.FirstAcceptedCommand (ConcreteClusterPath (kMockEndpoint1 , MockClusterId (1 ))).IsValid ());
1396
- EXPECT_FALSE (model.GetAcceptedCommandInfo (ConcreteCommandPath (kMockEndpoint1 , MockClusterId (1 ), 1234 )).has_value ());
1348
+ ASSERT_TRUE (model.AcceptedCommands (ConcreteClusterPath (kMockEndpoint1 , MockClusterId (1 ))).empty ());
1397
1349
1398
1350
handler.SetOverrideAccepted (true );
1399
1351
handler.SetOverrideGenerated (true );
1400
1352
1401
1353
// with overrides, the list is still empty ...
1402
- EXPECT_FALSE (model.FirstAcceptedCommand (ConcreteClusterPath (kMockEndpoint1 , MockClusterId (1 ))).IsValid ());
1403
- EXPECT_FALSE (model.GetAcceptedCommandInfo ( ConcreteCommandPath (kMockEndpoint1 , MockClusterId (1 ), 1234 )).has_value ());
1354
+ ASSERT_TRUE (model.GeneratedCommands (ConcreteClusterPath (kMockEndpoint1 , MockClusterId (1 ))).empty ());
1355
+ ASSERT_TRUE (model.AcceptedCommands ( ConcreteClusterPath (kMockEndpoint1 , MockClusterId (1 ))).empty ());
1404
1356
1405
1357
// set some overrides
1406
1358
handler.AcceptedVec ().push_back (1234 );
1407
1359
handler.AcceptedVec ().push_back (999 );
1408
1360
1409
1361
handler.GeneratedVec ().push_back (33 );
1410
1362
1411
- DataModel::CommandEntry entry;
1412
-
1413
- entry = model.FirstAcceptedCommand (ConcreteClusterPath (kMockEndpoint1 , MockClusterId (1 )));
1414
- EXPECT_TRUE (entry.IsValid ());
1415
- EXPECT_EQ (entry.path , ConcreteCommandPath (kMockEndpoint1 , MockClusterId (1 ), 1234 ));
1363
+ MetadataList<DataModel::AcceptedCommandEntry> acceptedCommands =
1364
+ model.AcceptedCommands (ConcreteClusterPath (kMockEndpoint1 , MockClusterId (1 )));
1416
1365
1417
- entry = model. NextAcceptedCommand (entry. path );
1418
- EXPECT_TRUE (entry. IsValid () );
1419
- EXPECT_EQ (entry. path , ConcreteCommandPath ( kMockEndpoint1 , MockClusterId ( 1 ), 999 ) );
1366
+ ASSERT_EQ (acceptedCommands. size (), 2u );
1367
+ ASSERT_EQ (acceptedCommands[ 0 ]. commandId , 1234u );
1368
+ ASSERT_EQ (acceptedCommands[ 1 ]. commandId , 999u );
1420
1369
1421
- entry = model.NextAcceptedCommand (entry.path );
1422
- EXPECT_FALSE (entry.IsValid ());
1423
-
1424
- MetadataList<CommandId> generatedCommands = model.GeneratedCommands (ConcreteClusterPath (kMockEndpoint1 , MockClusterId (1 )));
1425
- const CommandId expectedGeneratedCommands[] = { 33 };
1370
+ MetadataList<CommandId> generatedCommands = model.GeneratedCommands (ConcreteClusterPath (kMockEndpoint1 , MockClusterId (1 )));
1371
+ const CommandId expectedGeneratedCommands[] = { 33 };
1426
1372
ASSERT_TRUE (generatedCommands.GetSpanValidForLifetime ().data_equal (Span<const CommandId>(expectedGeneratedCommands)));
1427
-
1428
- // Command finding should work
1429
- EXPECT_TRUE (model.GetAcceptedCommandInfo (ConcreteCommandPath (kMockEndpoint1 , MockClusterId (1 ), 1234 )).has_value ());
1430
- EXPECT_FALSE (model.GetAcceptedCommandInfo (ConcreteCommandPath (kMockEndpoint1 , MockClusterId (1 ), 88 )).has_value ());
1431
- EXPECT_FALSE (model.GetAcceptedCommandInfo (ConcreteCommandPath (kMockEndpoint1 , MockClusterId (1 ), 33 )).has_value ());
1432
1373
}
1433
1374
1434
1375
TEST_F (TestCodegenModelViaMocks, ReadForInvalidGlobalAttributePath)
0 commit comments