/** Test that WindowAndTrigger namespaces are prefixed by the related Window namespace. */
 @Test
 public void testIntervalWindowPrefixing() {
   StateNamespace window = StateNamespaces.window(intervalCoder, intervalWindow(1000, 87392));
   StateNamespace windowAndTrigger =
       StateNamespaces.windowAndTrigger(intervalCoder, intervalWindow(1000, 87392), 57);
   assertThat(windowAndTrigger.stringKey(), Matchers.startsWith(window.stringKey()));
   assertThat(
       StateNamespaces.global().stringKey(),
       Matchers.not(Matchers.startsWith(window.stringKey())));
 }
 /** Test that WindowAndTrigger namespaces are prefixed by the related Window namespace. */
 @Test
 public void testGlobalWindowPrefixing() {
   StateNamespace window =
       StateNamespaces.window(GlobalWindow.Coder.INSTANCE, GlobalWindow.INSTANCE);
   StateNamespace windowAndTrigger =
       StateNamespaces.windowAndTrigger(GlobalWindow.Coder.INSTANCE, GlobalWindow.INSTANCE, 57);
   assertThat(windowAndTrigger.stringKey(), Matchers.startsWith(window.stringKey()));
   assertThat(
       StateNamespaces.global().stringKey(),
       Matchers.not(Matchers.startsWith(window.stringKey())));
 }
  /**
   * This test should not be changed. It verifies that the stringKey matches certain expectations.
   * If this changes, the ability to reload any pipeline that has persisted these namespaces will be
   * impacted.
   */
  @Test
  public void testStability() {
    StateNamespace global = StateNamespaces.global();
    StateNamespace intervalWindow =
        StateNamespaces.window(intervalCoder, intervalWindow(1000, 87392));
    StateNamespace intervalWindowAndTrigger =
        StateNamespaces.windowAndTrigger(intervalCoder, intervalWindow(1000, 87392), 57);
    StateNamespace globalWindow =
        StateNamespaces.window(GlobalWindow.Coder.INSTANCE, GlobalWindow.INSTANCE);
    StateNamespace globalWindowAndTrigger =
        StateNamespaces.windowAndTrigger(GlobalWindow.Coder.INSTANCE, GlobalWindow.INSTANCE, 12);

    assertEquals("/", global.stringKey());
    assertEquals("/gAAAAAABVWD4ogU/", intervalWindow.stringKey());
    assertEquals("/gAAAAAABVWD4ogU/1L/", intervalWindowAndTrigger.stringKey());
    assertEquals("//", globalWindow.stringKey());
    assertEquals("//C/", globalWindowAndTrigger.stringKey());
  }
 private void assertStringKeyRoundTrips(
     Coder<? extends BoundedWindow> coder, StateNamespace namespace) {
   assertEquals(namespace, StateNamespaces.fromString(namespace.stringKey(), coder));
 }