DataSourcePreconditions { @NonNull public static DataSource checkProvider(@NonNull String providerName, @NonNull DataSource dataSource) throws IllegalArgumentException { checkProvider(providerName, dataSource.getProviderName()); return dataSource; } private  DataSourcePreconditions(); @NonNull static DataSource checkProvider(@NonNull String providerName, @NonNull DataSource dataSource); @NonNull static DataSet checkProvider(@NonNull String providerName, @NonNull DataSet dataSet); @NonNull static TsMoniker checkProvider(@NonNull String providerName, @NonNull TsMoniker moniker);  }
@Test @SuppressWarnings("null") public void testDataSource() { DataSource input = DataSource.of("myprovider", "1234"); assertThat(checkProvider("myprovider", input)) .isSameAs(input); assertThatThrownBy(() -> checkProvider("xxx", input)) .isInstanceOf(IllegalArgumentException.class); assertThatThrownBy(() -> checkProvider(null, input)) .isInstanceOf(NullPointerException.class); assertThatThrownBy(() -> checkProvider("myprovider", (DataSource) null)) .isInstanceOf(NullPointerException.class); }
@Test @SuppressWarnings("null") public void testDataSet() { DataSet input = DataSet.of(DataSource.of("myprovider", "1234"), DataSet.Kind.SERIES); assertThat(checkProvider("myprovider", input)) .isSameAs(input); assertThatThrownBy(() -> checkProvider("xxx", input)) .isInstanceOf(IllegalArgumentException.class); assertThatThrownBy(() -> checkProvider(null, input)) .isInstanceOf(NullPointerException.class); assertThatThrownBy(() -> checkProvider("myprovider", (DataSource) null)) .isInstanceOf(NullPointerException.class); }
@Test @SuppressWarnings("null") public void testTsMoniker() { TsMoniker input = new TsMoniker("myprovider", "id"); assertThat(checkProvider("myprovider", input)) .isSameAs(input); assertThatThrownBy(() -> checkProvider("xxx", input)) .isInstanceOf(IllegalArgumentException.class); assertThatThrownBy(() -> checkProvider(null, input)) .isInstanceOf(NullPointerException.class); assertThatThrownBy(() -> checkProvider("myprovider", (DataSource) null)) .isInstanceOf(NullPointerException.class); }