mjsax commented on a change in pull request #8847: URL: https://github.com/apache/kafka/pull/8847#discussion_r438482415
########## File path: streams/src/test/java/org/apache/kafka/streams/processor/internals/InternalTopologyBuilderTest.java ########## @@ -372,48 +373,112 @@ public void testAddStateStoreWithSink() { @Test public void shouldNotAllowToAddStoresWithSameName() { + final StoreBuilder<KeyValueStore<Object, Object>> otherBuilder = + new MockKeyValueStoreBuilder("testStore", false); + builder.addStateStore(storeBuilder); - final StoreBuilder otherBuilder = new MockKeyValueStoreBuilder("store", false); - try { - builder.addStateStore(otherBuilder); - fail("Should throw TopologyException with store name conflict"); - } catch (final TopologyException expected) { /* ok */ } + + final TopologyException exception = assertThrows( + TopologyException.class, + () -> builder.addStateStore(otherBuilder) + ); + + assertThat( + exception.getMessage(), + equalTo("Invalid topology: A different StateStore has already been added with the name testStore") + ); } @Test public void shouldNotAllowToAddStoresWithSameNameWhenFirstStoreIsGlobal() { - final StoreBuilder storeBuilder = new MockKeyValueStoreBuilder("store", false).withLoggingDisabled(); + final StoreBuilder<KeyValueStore<Object, Object>> globalBuilder = + new MockKeyValueStoreBuilder("testStore", false).withLoggingDisabled(); + builder.addGlobalStore( - storeBuilder, + globalBuilder, + "global-store", + null, + null, + null, + "global-topic", + "global-processor", + new MockProcessorSupplier<>() + ); + + final TopologyException exception = assertThrows( + TopologyException.class, + () -> builder.addStateStore(storeBuilder) + ); + + assertThat( + exception.getMessage(), + equalTo("Invalid topology: A different GlobalStateStore has already been added with the name testStore") + ); + } + + @Test + public void shouldNotAllowToAddStoresWithSameNameWhenSecondStoreIsGlobal() { Review comment: As above (the diff is just weird... this is an existing test; cf. below) ---------------------------------------------------------------- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: us...@infra.apache.org