### Question:
ECSPlugin implements Plugin { @Override public boolean isEnabled() { String ecsMetadataUri = System.getenv(ECS_METADATA_KEY); if (ecsMetadataUri == null) { return false; } return ecsMetadataUri.startsWith(HTTP_PREFIX); } ECSPlugin(); @Override boolean isEnabled(); @Override String getServiceName(); void populateRuntimeContext(); @Override Map<String, @Nullable Object> getRuntimeContext(); @Override String getOrigin(); @Override boolean equals(@Nullable Object o); @Override int hashCode(); static final String ORIGIN; }### Answer:
@Test @SetEnvironmentVariable(key = ECS_METADATA_KEY, value = GOOD_URI) public void testIsEnabled() { boolean enabled = plugin.isEnabled(); assertThat(enabled).isTrue(); }
@Test @SetEnvironmentVariable(key = ECS_METADATA_KEY, value = BAD_URI) public void testNotEnabled() { boolean enabled = plugin.isEnabled(); assertThat(enabled).isFalse(); }
@Test public void testNotEnabledWithoutEnvironmentVariable() { boolean enabled = plugin.isEnabled(); assertThat(enabled).isFalse(); }