ClusterTag { public String name() { String tag = this.config.tag(this.cluster); if (tag.isEmpty()) { tag = this.config.defaultTag(); } if (tag.isEmpty()) { throw new RuntimeException( String.format( "No tags specified for '%s'", this.cluster ) ); } return String.format("tag:%s", tag); } ClusterTag(final String cluster, final Config config); String name(); String value();  }
@Test public void usesDefaultTagIfNoSpecificTagProvided() { Assertions.assertThat( new ClusterTag( "blah", new ClusterTagTest.FakeConfig("default-tag", "", "") ).name() ).isEqualTo("tag:default-tag"); }
@Test public void usesGivenTag() { Assertions.assertThat( new ClusterTag( "blah", new ClusterTagTest.FakeConfig("default-tag", "blah-tag", "") ).name() ).isEqualTo("tag:blah-tag"); }
@Test public void throwsExceptionWhenNoTags() { Assertions.assertThatThrownBy( () -> new ClusterTag( "blah", new ClusterTagTest.FakeConfig("", "", "") ).name() ).isInstanceOf(RuntimeException.class) .hasMessageContaining("No tags specified for 'blah'"); }