StateV1HealthModel implements AutoCloseable { static boolean portTaggedWith(PortInfo portInfo, List<String> requiredTags) { Collection<String> upperCasePortTags = portInfo.getTags().stream().map(String::toUpperCase).collect(Collectors.toSet()); for (var tag : requiredTags) { if (!upperCasePortTags.contains(tag.toUpperCase())) { return false; } } return true; } StateV1HealthModel(Duration targetHealthStaleness,
                       Duration requestTimeout,
                       Duration connectionKeepAlive,
                       RunletExecutor executor); @Override void close(); static final List<String> HTTP_HEALTH_PORT_TAGS; }
@Test public void caseInsensitiveTagMatching() { PortInfo portInfo = mock(PortInfo.class); when(portInfo.getTags()).thenReturn(List.of("http", "STATE", "foo")); assertTrue(StateV1HealthModel.portTaggedWith(portInfo, StateV1HealthModel.HTTP_HEALTH_PORT_TAGS)); assertTrue(StateV1HealthModel.portTaggedWith(portInfo, List.of("HTTP", "state"))); when(portInfo.getTags()).thenReturn(List.of("http", "foo")); assertFalse(StateV1HealthModel.portTaggedWith(portInfo, StateV1HealthModel.HTTP_HEALTH_PORT_TAGS)); assertFalse(StateV1HealthModel.portTaggedWith(portInfo, List.of("HTTP", "state"))); }