FirstFoundLocalLookupStrategy extends AbstractLookupStrategy { @Override public Object getService() { Set<Object> services = context.lookupLocalMicroservice(metaData); if (services.isEmpty()) { throw new RuntimeException("No service found for: " + metaData); } return services.iterator().next(); }  @Override Object getService();  }
@Test public void testGetService() throws Exception { Set<Object> expectedResult = new HashSet<>(asList("1", "2", "3")); new Expectations(Context.class) {{ context.lookupLocalMicroservice(META_DATA); times = 4; result = expectedResult; }}; List<Object> result = new ArrayList<>(); for (int i = 0; i < 4; i++) { result.add(strategy.getService()); } assertThat(result).containsExactly("1", "1", "1", "1"); }