public void shouldMatchingCartridgeName() {
// pre-conditions
List<IEmbeddedCartridge> embeddedCartridges = CartridgeTestUtils.createEmbeddedCartridgeMocks(
"Timberlake", "TimAndStrupi");
StringPropertyQuery selector = new StringPropertyQuery("Tim.*") {
@Override
protected <C extends ICartridge> String getProperty(C cartridge) {
return cartridge.getName();
}
};
// operation
IEmbeddedCartridge matchingCartridge = selector.get(embeddedCartridges);
Collection<IEmbeddedCartridge> matchingCartridges = selector.getAll(embeddedCartridges);
// verification
assertThat(matchingCartridge).isNotNull();
assertThat(matchingCartridge.getName()).isEqualTo("Timberlake");
assertThat(matchingCartridges).onProperty("name").containsOnly("Timberlake", "TimAndStrupi");