Package org.mapfish.print.output

Examples of org.mapfish.print.output.Values


    @Test
    public void testBasicTableProperties() throws Exception {
        final Configuration config = configurationFactory.getConfig(getFile(BASE_DIR + "config.yaml"));
        final Template template = config.getTemplate("main");
        PJsonObject requestData = loadJsonRequestData();
        Values values = new Values(requestData, template, parser, getTaskDirectory(), this.httpRequestFactory, new File("."));
        forkJoinPool.invoke(template.getProcessorGraph().createTask(values));

        final DataSourceAttributeValue datasource = values.getObject("datasource", DataSourceAttributeValue.class);

        assertEquals(2, datasource.attributesValues.length);
    }
View Full Code Here


    public void testAttributesFromYaml() throws Exception {
        final File configFile = getFile(MapAttributeTest.class, "map_attributes/config-yaml.yaml");
        final Configuration config = configurationFactory.getConfig(configFile);
        final Template template = config.getTemplate("main");
        final PJsonObject pJsonObject = parseJSONObjectFromFile(MapAttributeTest.class, "map_attributes/requestData-yaml.json");
        final Values values = new Values(pJsonObject, template, new MapfishParser(), getTaskDirectory(), this.httpRequestFactory, new File("."));
        final MapAttribute.MapAttributeValues value = values.getObject("mapDef", MapAttribute.MapAttributeValues.class);

        assertEquals(80.0, value.getDpi(), 0.1);
        assertNotNull(value.getLayers());

        Object proj = value.getMapBounds().getProjection();
View Full Code Here

    public void testAttributesFromBoth() throws Exception {
        final File configFile = getFile(MapAttributeTest.class, "map_attributes/config-yaml.yaml");
        final Configuration config = configurationFactory.getConfig(configFile);
        final Template template = config.getTemplate("main");
        final PJsonObject pJsonObject = parseJSONObjectFromFile(MapAttributeTest.class, "map_attributes/requestData-json.json");
        final Values values = new Values(pJsonObject, template, new MapfishParser(), getTaskDirectory(), this.httpRequestFactory, new File("."));
        final MapAttribute.MapAttributeValues value = values.getObject("mapDef", MapAttribute.MapAttributeValues.class);

        assertEquals(90.0, value.getDpi(), 0.1);
        assertNotNull(value.getLayers());

        Object proj = value.getMapBounds().getProjection();
View Full Code Here

        final Template template = config.getTemplates().values().iterator().next();

        final Map<String, Attribute> attributes = template.getAttributes();

        PJsonObject jsonData = parseJSONObjectFromFile(DataSourceAttributeTest.class, "datasource/requestData.json");
        final Values values = new Values();
        values.populateFromAttributes(template, parser, attributes, jsonData);

        final Class<DataSourceAttribute.DataSourceAttributeValue> type = DataSourceAttribute.DataSourceAttributeValue.class;
        final DataSourceAttribute.DataSourceAttributeValue value = values.getObject("datasource", type);
        assertNotNull(value);

        assertEquals(2, value.attributesValues.length);
        Map<String, Object> val1 = value.attributesValues[0];
        Map<String, Object> val2 = value.attributesValues[1];
View Full Code Here

        configurationFactory.setDoValidation(false);
        final File configFile = getFile(StyleAttributeTest.class, "style_attributes/config.yaml");
        final Configuration config = configurationFactory.getConfig(configFile);
        final Template template = config.getTemplate("main");
        final PJsonObject pJsonObject = parseJSONObjectFromFile(StyleAttributeTest.class, "style_attributes/request.json");
        final Values values = new Values(pJsonObject, template, new MapfishParser(), this.folder.getRoot(),
                this.clientHttpRequestFactory, new File("."));
        final StyleAttribute.StylesAttributeValues value = values.getObject("styleDef", StyleAttribute.StylesAttributeValues.class);

        assertNotNull(value.getStyle(clientHttpRequestFactory, mapContext));
    }
View Full Code Here

    double[] daVal = new double[] {1.2, 2.3};

    @Test
    public void testPopulateInputParameter() throws Exception {

        Values values = new Values();
        values.put(iMappingName, intVal);
        values.put(bMappingName, true);
        values.put("s", sVal);
        values.put("ls", lsVal);
        values.put("da", daVal);

        TestProcessor processor = new TestProcessor();
        processor.getInputMapperBiMap().put(iMappingName, "i");
        processor.getInputMapperBiMap().put(bMappingName, "b");
        DataTransferObject param = ProcessorUtils.populateInputParameter(processor, values);
View Full Code Here

    }

    @Test (expected = RuntimeException.class)
    public void testNullableProperty() throws Exception {

        Values values = new Values();
        values.put(iMappingName, intVal);
        values.put(bMappingName, true);
        values.put("s", sVal);
        values.put("ls", lsVal);
        // NO da value is specified so an exception should be thrown.

        TestProcessor processor = new TestProcessor();
        processor.getInputMapperBiMap().put(iMappingName, "i");
        processor.getInputMapperBiMap().put(bMappingName, "b");
View Full Code Here

    }

    @Test
    public void testWriteProcessorOutputToValues() throws Exception {
        Values values = new Values();

        final DataTransferObject dto = new DataTransferObject();
        dto.b = true;
        dto.da = daVal;
        dto.defaultI = 32;
        dto.ls = lsVal;

        TestProcessor processor = new TestProcessor();
        processor.getOutputMapperBiMap().put("i", iMappingName);
        processor.getOutputMapperBiMap().put("b", bMappingName);

        ProcessorUtils.writeProcessorOutputToValues(dto, processor, values);

        assertEquals(dto.defaultI, values.getInteger("defaultI").intValue());
        assertEquals(dto.i, values.getInteger(iMappingName).intValue());
        assertEquals(dto.b, values.getBoolean(bMappingName));
        assertNull(values.getBoolean("s"));
        assertEquals(lsVal, values.getObject("ls", Object.class));
        assertArrayEquals(daVal, (double[]) values.getObject("da", Object.class), 0.00001);
    }
View Full Code Here

        assertArrayEquals(daVal, (double[]) values.getObject("da", Object.class), 0.00001);
    }

    @Test
    public void testWritePrefixedOutputToValues() throws Exception {
        Values values = new Values();

        final DataTransferObject dto = new DataTransferObject();
        dto.b = true;
        dto.da = daVal;
        dto.defaultI = 32;
        dto.ls = lsVal;


        TestProcessor processor = new TestProcessor();
        processor.getOutputMapperBiMap().put("i", iMappingName);
        processor.getOutputMapperBiMap().put("b", bMappingName);

        processor.setOutputPrefix("   prefix   ");
        ProcessorUtils.writeProcessorOutputToValues(dto, processor, values);

        assertEquals(dto.defaultI, values.getInteger("prefixDefaultI").intValue());
        assertEquals(dto.i, values.getInteger(iMappingName).intValue());
        assertEquals(dto.b, values.getBoolean(bMappingName));
        assertNull(values.getBoolean("prefixS"));
        assertEquals(lsVal, values.getObject("prefixLs", Object.class));
        assertArrayEquals(daVal, (double[]) values.getObject("prefixDa", Object.class), 0.00001);
    }
View Full Code Here

        final ArrayList<TestProcessor> processors = Lists.newArrayList(RootNoOutput, NeedsTable, NeedsMap, RootMapOut,
                RootTableAndWidthOut);
        ProcessorDependencyGraph graph = this.processorDependencyGraphFactory.build(processors);
        assertContainsProcessors(graph.getRoots(), RootMapOut, RootNoOutput, RootTableAndWidthOut);
        final TestOrderExecution execution = new TestOrderExecution();
        Values values = new Values();
        values.put(EXECUTION_TRACKER, execution);
        forkJoinPool.invoke(graph.createTask(values));

        assertEquals(execution.testOrderExecution.toString(), 5, execution.testOrderExecution.size());
        assertHasOrdering(execution, RootMapOut, NeedsMap);
        assertHasOrdering(execution, RootTableAndWidthOut, NeedsTable);
View Full Code Here

TOP

Related Classes of org.mapfish.print.output.Values

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.