Contexts { public static <T> Context<T> get( @Nonnull final Class<T> type ) { return get( type, DEFAULT_QUALIFIER ); } private  Contexts(); static void register( @Nonnull final Class<T> type ); static void register( @Nonnull final Class<T> type, @Nullable final T defaultValue ); static void register( @Nonnull final Class<T> type, @Nonnull final String qualifier ); static void register( @Nonnull final Class<T> type,
                                   @Nonnull final String qualifier,
                                   @Nullable final T defaultValue ); static Context<T> get( @Nonnull final Class<T> type ); @SuppressWarnings( "unchecked" ) static Context<T> get( @Nonnull final Class<T> type, @Nonnull final String qualifier );  }
@Test public void get_missing() { final IllegalStateException exception = expectThrows( IllegalStateException.class, () -> Contexts.get( Runnable.class, "someQual" ) ); assertEquals( exception.getMessage(), "Attempting to retrieve React context with type interface java.lang.Runnable and qualifier 'someQual' but no such context exists with that type and name" ); }
@Test public void get_primitiveType() { final IllegalStateException exception = expectThrows( IllegalStateException.class, () -> Contexts.get( int.class, "port" ) ); assertEquals( exception.getMessage(), "Attempting to access primitive type int from the React context. Access using the boxed type instead" ); }
@Test public void get_withoutQualifier_missing() { final IllegalStateException exception = expectThrows( IllegalStateException.class, () -> Contexts.get( Runnable.class ) ); assertEquals( exception.getMessage(), "Attempting to retrieve React context with type interface java.lang.Runnable and qualifier '' but no such context exists with that type and name" ); }