TsCursorAsFiller { @NonNull public static TsFiller of(@NonNull Logger logger, @NonNull HasTsCursor hdc, @NonNull HasDataMoniker hdm, @NonNull HasDataDisplayName hddn) { return new ComposedFiller(new CursorResource(logger, hdc, hdm, hddn)); } private  TsCursorAsFiller(); @NonNull static TsFiller of(@NonNull Logger logger, @NonNull HasTsCursor hdc, @NonNull HasDataMoniker hdm, @NonNull HasDataDisplayName hddn);  }
@Test @SuppressWarnings("null") public void testFactory() { HasTsCursor noOpCursor = new NoOpTsCursorSupport(provider); HasDataDisplayName nameSupport = HasDataDisplayName.usingUri(provider); assertThatThrownBy(() -> TsCursorAsFiller.of(null, noOpCursor, monikers, nameSupport)) .isInstanceOf(NullPointerException.class) .hasMessageContaining("Logger"); assertThatThrownBy(() -> TsCursorAsFiller.of(logger, null, monikers, nameSupport)) .isInstanceOf(NullPointerException.class) .hasMessageContaining("HasTsCursor"); assertThatThrownBy(() -> TsCursorAsFiller.of(logger, noOpCursor, null, nameSupport)) .isInstanceOf(NullPointerException.class) .hasMessageContaining("HasDataMoniker"); assertThatThrownBy(() -> TsCursorAsFiller.of(logger, noOpCursor, monikers, null)) .isInstanceOf(NullPointerException.class) .hasMessageContaining("HasDataDisplayName"); }
@Test @SuppressWarnings("null") public void testNulls() { TsFiller filler = TsCursorAsFiller.of(logger, goodCursor, monikers, goodCursor); assertThatThrownBy(() -> filler.fillCollection(null)).isInstanceOf(NullPointerException.class); assertThatThrownBy(() -> filler.fillSeries(null)).isInstanceOf(NullPointerException.class); }
@Test public void testCollectionFillSource() { TsFiller filler = TsCursorAsFiller.of(logger, goodCursor, monikers, goodCursor); assertThat(new TsCollectionInformation(goodSource, None)).satisfies(info -> { assertThat(filler.fillCollection(info)).isTrue(); assertThat(info).isEqualToIgnoringGivenFields(colInfo(null, goodSource, None, null, null), "items"); assertThat(info.items) .usingFieldByFieldElementComparator() .containsExactly( seriesInfo("node.leaf1", leaf1, None, null, null, null), seriesInfo("node.leaf2", leaf2, None, null, null, null), seriesInfo("leaf3", leaf3, None, null, null, null) ); }); assertThat(new TsCollectionInformation(goodSource, TsInformationType.MetaData)).satisfies(info -> { assertThat(filler.fillCollection(info)).isTrue(); assertThat(info).isEqualToIgnoringGivenFields(colInfo(null, goodSource, TsInformationType.MetaData, null, metaOf("type", "root")), "items"); assertThat(info.items) .usingFieldByFieldElementComparator() .containsExactly( seriesInfo("node.leaf1", leaf1, TsInformationType.MetaData, null, null, null), seriesInfo("node.leaf2", leaf2, TsInformationType.MetaData, null, null, null), seriesInfo("leaf3", leaf3, TsInformationType.MetaData, null, null, customMeta) ); }); assertThat(new TsCollectionInformation(goodSource, All)).satisfies(info -> { assertThat(filler.fillCollection(info)).isTrue(); assertThat(info).isEqualToIgnoringGivenFields(colInfo(null, goodSource, All, null, metaOf("type", "root")), "items"); assertThat(info.items) .usingFieldByFieldElementComparator() .containsExactly( seriesInfo("node.leaf1", leaf1, All, null, "No data available", null), seriesInfo("node.leaf2", leaf2, All, Data.M1, null, null), seriesInfo("leaf3", leaf3, All, Data.M2, null, customMeta) ); }); }
@Test public void testCollectionFillSet() { TsFiller filler = TsCursorAsFiller.of(logger, goodCursor, monikers, goodCursor); assertThat(new TsCollectionInformation(goodCollection, None)).satisfies(info -> { assertThat(filler.fillCollection(info)).isTrue(); assertThat(info).isEqualToIgnoringGivenFields(colInfo(null, goodCollection, None, null, null), "items"); assertThat(info.items) .usingFieldByFieldElementComparator() .containsExactly( seriesInfo("node.leaf1", leaf1, None, null, null, null), seriesInfo("node.leaf2", leaf2, None, null, null, null) ); }); assertThat(new TsCollectionInformation(goodCollection, TsInformationType.MetaData)).satisfies(info -> { assertThat(filler.fillCollection(info)).isTrue(); assertThat(info).isEqualToIgnoringGivenFields(colInfo(null, goodCollection, TsInformationType.MetaData, null, metaOf("type", "node")), "items"); assertThat(info.items) .usingFieldByFieldElementComparator() .containsExactly( seriesInfo("node.leaf1", leaf1, TsInformationType.MetaData, null, null, null), seriesInfo("node.leaf2", leaf2, TsInformationType.MetaData, null, null, null) ); }); assertThat(new TsCollectionInformation(goodCollection, All)).satisfies(info -> { assertThat(filler.fillCollection(info)).isTrue(); assertThat(info).isEqualToIgnoringGivenFields(colInfo(null, goodCollection, All, null, metaOf("type", "node")), "items"); assertThat(info.items) .usingFieldByFieldElementComparator() .containsExactly( seriesInfo("node.leaf1", leaf1, All, null, "No data available", null), seriesInfo("node.leaf2", leaf2, All, Data.M1, null, null) ); }); }
@Test public void testCollectionExSource() { TsFiller filler = TsCursorAsFiller.of(logger, badCursor, monikers, goodCursor); assertThat(new TsCollectionInformation(goodSource, All)).satisfies(info -> { assertThat(filler.fillCollection(info)).isFalse(); assertThat(info).isEqualToIgnoringGivenFields(colInfo(null, goodSource, All, "boom", null), "items"); assertThat(info.items).isEmpty(); }); }
@Test public void testCollectionExSet() { TsFiller filler = TsCursorAsFiller.of(logger, badCursor, monikers, goodCursor); assertThat(new TsCollectionInformation(goodCollection, All)).satisfies(info -> { assertThat(filler.fillCollection(info)).isFalse(); assertThat(info).isEqualToIgnoringGivenFields(colInfo(null, goodCollection, All, "boom", null), "items"); assertThat(info.items).isEmpty(); }); }
@Test public void testCollectionInvalid() { TsFiller filler = TsCursorAsFiller.of(logger, goodCursor, monikers, goodCursor); assertThat(new TsCollectionInformation(goodSeries, All)).satisfies(info -> { assertThat(filler.fillCollection(info)).isFalse(); assertThat(info).isEqualToIgnoringGivenFields(colInfo(null, goodSeries, All, "Invalid moniker", null), "items"); assertThat(info.items).isEmpty(); }); }
@Test public void testSeriesFill() { TsFiller filler = TsCursorAsFiller.of(logger, goodCursor, monikers, goodCursor); assertThat(new TsInformation(null, goodSeries, None)).satisfies(info -> { assertThat(filler.fillSeries(info)).isTrue(); assertThat(info).isEqualToComparingFieldByField(seriesInfo("leaf3", goodSeries, None, null, null, null)); }); assertThat(new TsInformation(null, goodSeries, TsInformationType.MetaData)).satisfies(info -> { assertThat(filler.fillSeries(info)).isTrue(); assertThat(info).isEqualToComparingFieldByField(seriesInfo("leaf3", goodSeries, TsInformationType.MetaData, null, null, customMeta)); }); assertThat(new TsInformation(null, goodSeries, All)).satisfies(info -> { assertThat(filler.fillSeries(info)).isTrue(); assertThat(info).isEqualToComparingFieldByField(seriesInfo("leaf3", goodSeries, All, Data.M2, null, customMeta)); }); }
@Test public void testSeriesEx() { TsFiller filler = TsCursorAsFiller.of(logger, badCursor, monikers, goodCursor); assertThat(new TsInformation(null, goodSeries, All)).satisfies(info -> { assertThat(filler.fillSeries(info)).isFalse(); assertThat(info).isEqualToComparingFieldByField(seriesInfo(null, goodSeries, All, null, "boom", null)); }); }
@Test public void testSeriesInvalid() { TsFiller filler = TsCursorAsFiller.of(logger, goodCursor, monikers, goodCursor); assertThat(new TsInformation(null, goodSource, All)).satisfies(info -> { assertThat(filler.fillSeries(info)).isFalse(); assertThat(info).isEqualToComparingFieldByField(seriesInfo(null, goodSource, All, null, "Invalid moniker", null)); }); assertThat(new TsInformation(null, goodCollection, All)).satisfies(info -> { assertThat(filler.fillSeries(info)).isFalse(); assertThat(info).isEqualToComparingFieldByField(seriesInfo(null, goodCollection, All, null, "Invalid moniker", null)); }); }