@Test @SuppressWarnings("unchecked") public void testLookupDefinitionsByLabels() { Set<String> expected = new HashSet<String>(1) {{ add(DEF_ID1); }}; when(cache.getDefinitions(eq(ROLE2))).thenReturn(expected); LookupDefinitionsByLabels function = new LookupDefinitionsByLabels(new HashSet<String>(1) {{ add(ROLE2); }}, id -> true); assertTrue(function.execute(context).contains(DEF_ID1)); }