@Test @DirtiesContext public void testExecute() throws Exception { final String host = "north_arrow"; requestFactory.registerHandler( input -> (("" + input.getHost()).contains(host + ".osm")) || input.getAuthority().contains(host + ".osm"), new TestHttpClientFactory.Handler() { @Override public MockClientHttpRequest handleRequest(URI uri, HttpMethod httpMethod) throws Exception { try { byte[] bytes = getFileBytes("/map-data/osm" + uri.getPath()); return ok(uri, bytes, httpMethod); } catch (AssertionError e) { return error404(uri, httpMethod); } } } ); final Configuration config = configurationFactory.getConfig(getFile(BASE_DIR + "config.yaml")); final Template template = config.getTemplate("main"); PJsonObject requestData = loadJsonRequestData(); Values values = new Values("test", requestData, template, getTaskDirectory(), this.requestFactory, new File(".")); this.forkJoinPool.invoke(template.getProcessorGraph().createTask(values)); String northArrowGraphic = values.getObject("northArrowGraphic", String.class); new ImageSimilarity(new File(new URI(northArrowGraphic))) .assertSimilarity(getFile(BASE_DIR + "expectedNorthArrow.png"), 1); assertNotNull(values.getObject("northArrowOut", String.class)); final Configuration configNoReport = configurationFactory.getConfig( getFile(BASE_DIR + "config-no-report.yaml")); final Template templateNoReport = configNoReport.getTemplate("main"); Values valuesNoReport = new Values("test", requestData, templateNoReport, getTaskDirectory(), this.requestFactory, new File(".")); this.forkJoinPool.invoke(template.getProcessorGraph().createTask(valuesNoReport)); assertNull(valuesNoReport.getObject("northArrowOut", String.class)); }
@Override public final Output execute(final Input values, final ExecutionContext context) throws Exception { context.stopIfCanceled(); final double dpiRatio = values.map.getDpi() / PDF_DPI; final Dimension size = new Dimension( (int) (values.northArrow.getSize().getWidth() * dpiRatio), (int) (values.northArrow.getSize().getHeight() * dpiRatio)); final URI northArrowGraphicFile = NorthArrowGraphic.create( size, values.northArrow.getGraphic(), values.northArrow.getBackgroundColor(), values.map.getRotation(), values.tempTaskDirectory, values.clientHttpRequestFactoryProvider.get(), !values.template.isPdfA()); context.stopIfCanceled(); String strScalebarSubReport = null; if (values.northArrow.isCreateSubReport()) { final URI scalebarSubReport = createNorthArrowSubReport( values.tempTaskDirectory, values.northArrow.getSize(), Collections.singletonList(northArrowGraphicFile), values.map.getDpi()); strScalebarSubReport = scalebarSubReport.toString(); } return new Output(northArrowGraphicFile.toString(), strScalebarSubReport); }
CreateNorthArrowProcessor extends AbstractProcessor<CreateNorthArrowProcessor.Input, CreateNorthArrowProcessor.Output> { @Override public final Output execute(final Input values, final ExecutionContext context) throws Exception { context.stopIfCanceled(); final double dpiRatio = values.map.getDpi() / PDF_DPI; final Dimension size = new Dimension( (int) (values.northArrow.getSize().getWidth() * dpiRatio), (int) (values.northArrow.getSize().getHeight() * dpiRatio)); final URI northArrowGraphicFile = NorthArrowGraphic.create( size, values.northArrow.getGraphic(), values.northArrow.getBackgroundColor(), values.map.getRotation(), values.tempTaskDirectory, values.clientHttpRequestFactoryProvider.get(), !values.template.isPdfA()); context.stopIfCanceled(); String strScalebarSubReport = null; if (values.northArrow.isCreateSubReport()) { final URI scalebarSubReport = createNorthArrowSubReport( values.tempTaskDirectory, values.northArrow.getSize(), Collections.singletonList(northArrowGraphicFile), values.map.getDpi()); strScalebarSubReport = scalebarSubReport.toString(); } return new Output(northArrowGraphicFile.toString(), strScalebarSubReport); } }
CreateNorthArrowProcessor extends AbstractProcessor<CreateNorthArrowProcessor.Input, CreateNorthArrowProcessor.Output> { @Override public final Output execute(final Input values, final ExecutionContext context) throws Exception { context.stopIfCanceled(); final double dpiRatio = values.map.getDpi() / PDF_DPI; final Dimension size = new Dimension( (int) (values.northArrow.getSize().getWidth() * dpiRatio), (int) (values.northArrow.getSize().getHeight() * dpiRatio)); final URI northArrowGraphicFile = NorthArrowGraphic.create( size, values.northArrow.getGraphic(), values.northArrow.getBackgroundColor(), values.map.getRotation(), values.tempTaskDirectory, values.clientHttpRequestFactoryProvider.get(), !values.template.isPdfA()); context.stopIfCanceled(); String strScalebarSubReport = null; if (values.northArrow.isCreateSubReport()) { final URI scalebarSubReport = createNorthArrowSubReport( values.tempTaskDirectory, values.northArrow.getSize(), Collections.singletonList(northArrowGraphicFile), values.map.getDpi()); strScalebarSubReport = scalebarSubReport.toString(); } return new Output(northArrowGraphicFile.toString(), strScalebarSubReport); } protected  CreateNorthArrowProcessor(); }
CreateNorthArrowProcessor extends AbstractProcessor<CreateNorthArrowProcessor.Input, CreateNorthArrowProcessor.Output> { @Override public final Output execute(final Input values, final ExecutionContext context) throws Exception { context.stopIfCanceled(); final double dpiRatio = values.map.getDpi() / PDF_DPI; final Dimension size = new Dimension( (int) (values.northArrow.getSize().getWidth() * dpiRatio), (int) (values.northArrow.getSize().getHeight() * dpiRatio)); final URI northArrowGraphicFile = NorthArrowGraphic.create( size, values.northArrow.getGraphic(), values.northArrow.getBackgroundColor(), values.map.getRotation(), values.tempTaskDirectory, values.clientHttpRequestFactoryProvider.get(), !values.template.isPdfA()); context.stopIfCanceled(); String strScalebarSubReport = null; if (values.northArrow.isCreateSubReport()) { final URI scalebarSubReport = createNorthArrowSubReport( values.tempTaskDirectory, values.northArrow.getSize(), Collections.singletonList(northArrowGraphicFile), values.map.getDpi()); strScalebarSubReport = scalebarSubReport.toString(); } return new Output(northArrowGraphicFile.toString(), strScalebarSubReport); } protected  CreateNorthArrowProcessor(); @Override final Input createInputParameter(); @Override final Output execute(final Input values, final ExecutionContext context); }
CreateNorthArrowProcessor extends AbstractProcessor<CreateNorthArrowProcessor.Input, CreateNorthArrowProcessor.Output> { @Override public final Output execute(final Input values, final ExecutionContext context) throws Exception { context.stopIfCanceled(); final double dpiRatio = values.map.getDpi() / PDF_DPI; final Dimension size = new Dimension( (int) (values.northArrow.getSize().getWidth() * dpiRatio), (int) (values.northArrow.getSize().getHeight() * dpiRatio)); final URI northArrowGraphicFile = NorthArrowGraphic.create( size, values.northArrow.getGraphic(), values.northArrow.getBackgroundColor(), values.map.getRotation(), values.tempTaskDirectory, values.clientHttpRequestFactoryProvider.get(), !values.template.isPdfA()); context.stopIfCanceled(); String strScalebarSubReport = null; if (values.northArrow.isCreateSubReport()) { final URI scalebarSubReport = createNorthArrowSubReport( values.tempTaskDirectory, values.northArrow.getSize(), Collections.singletonList(northArrowGraphicFile), values.map.getDpi()); strScalebarSubReport = scalebarSubReport.toString(); } return new Output(northArrowGraphicFile.toString(), strScalebarSubReport); } protected  CreateNorthArrowProcessor(); @Override final Input createInputParameter(); @Override final Output execute(final Input values, final ExecutionContext context);  }