use of org.n52.io.response.PlatformOutput in project series-rest-api by 52North.
the class ChartRendererTest method shouldFormatTitleTemplateWhenPrerenderingTriggerIsActive.
@Test
public void shouldFormatTitleTemplateWhenPrerenderingTriggerIsActive() {
QuantityDatasetOutput metadata = new QuantityDatasetOutput();
SeriesParameters parameters = new SeriesParameters();
parameters.setCategory(createParameter(new CategoryOutput(), "cat_1", "category"));
parameters.setFeature(createParameter(new FeatureOutput(), "feat_1", "feature"));
parameters.setOffering(createParameter(new OfferingOutput(), "off_1", "offering"));
parameters.setPhenomenon(createParameter(new PhenomenonOutput(), "phen_1", "phenomenon"));
parameters.setProcedure(createParameter(new ProcedureOutput(), "proc_1", "procedure"));
parameters.setService(createParameter(new ServiceOutput(), "ser_1", "service"));
metadata.setSeriesParameters(parameters);
metadata.setId("timeseries");
metadata.setUom("");
PlatformOutput platformOutput = new PlatformOutput(PlatformType.STATIONARY_INSITU);
platformOutput.setId("sta_1");
platformOutput.setLabel("station");
parameters.setPlatform(platformOutput);
// build expected title
StringBuilder expected = new StringBuilder();
expected.append(parameters.getPlatform().getLabel());
expected.append(" ").append(parameters.getPhenomenon().getLabel());
expected.append(" ").append(parameters.getProcedure().getLabel());
// expected.append(" ").append(parameters.getCategory().getLabel());
expected.append(" (4 opted-out)");
expected.append(" ").append(parameters.getOffering().getLabel());
expected.append(" ").append(parameters.getFeature().getLabel());
expected.append(" ").append(parameters.getService().getLabel());
expected.append(" ").append(metadata.getUom());
IoParameters ioConfig = createDefaults().extendWith("rendering_trigger", "prerendering");
IoStyleContext context = IoStyleContext.createContextForSingleSeries(metadata, ioConfig);
MyChartRenderer chartRenderer = new MyChartRenderer(context);
// String template = "%1$s %2$s %3$s %4$s %5$s %6$s %7$s %8$s";
String template = "%1$s %2$s %3$s (4 opted-out) %5$s %6$s %7$s %8$s";
String actual = chartRenderer.formatTitle(metadata, template);
assertThat(actual, is(expected.toString()));
}
Aggregations