@Test public void shouldStoreSpecificationInTemporaryDirectory() { final SpecificationResourceCustomizer customizer = new SpecificationResourceCustomizer(); final Map<String, Object> options = new HashMap<>(); options.put("specification", "the specification is here"); customizer.customize(NOT_USED, options); assertThat(options).containsKey("specificationUri"); assertThat(options).doesNotContainKey("specification"); assertThat(new File(StringHelper.after(ConnectorOptions.extractOption(options, "specificationUri"), "file:"))).hasContent("the specification is here"); }
@Override public void customize(final ComponentProxyComponent component, final Map<String, Object> options) { consumeOption(options, "specification", specificationObject -> { try { final String authenticationType = ConnectorOptions.extractOption(options, "authenticationType"); final String specification = updateSecuritySpecification((String) specificationObject, authenticationType); final File tempSpecification = File.createTempFile("rest-swagger", ".json"); tempSpecification.deleteOnExit(); final String swaggerSpecificationPath = tempSpecification.getAbsolutePath(); try (OutputStream out = new FileOutputStream(swaggerSpecificationPath)) { IOUtils.write(specification, out, StandardCharsets.UTF_8); } options.put("specificationUri", "file:" + swaggerSpecificationPath); } catch (final JsonProcessingException jsonException) { throw new IllegalStateException("Unable to parse openapi specification", jsonException); } catch (final IOException e) { throw new IllegalStateException("Unable to persist the specification to filesystem", e); } }); }
SpecificationResourceCustomizer implements ComponentProxyCustomizer { @Override public void customize(final ComponentProxyComponent component, final Map<String, Object> options) { consumeOption(options, "specification", specificationObject -> { try { final String authenticationType = ConnectorOptions.extractOption(options, "authenticationType"); final String specification = updateSecuritySpecification((String) specificationObject, authenticationType); final File tempSpecification = File.createTempFile("rest-swagger", ".json"); tempSpecification.deleteOnExit(); final String swaggerSpecificationPath = tempSpecification.getAbsolutePath(); try (OutputStream out = new FileOutputStream(swaggerSpecificationPath)) { IOUtils.write(specification, out, StandardCharsets.UTF_8); } options.put("specificationUri", "file:" + swaggerSpecificationPath); } catch (final JsonProcessingException jsonException) { throw new IllegalStateException("Unable to parse openapi specification", jsonException); } catch (final IOException e) { throw new IllegalStateException("Unable to persist the specification to filesystem", e); } }); } }
SpecificationResourceCustomizer implements ComponentProxyCustomizer { @Override public void customize(final ComponentProxyComponent component, final Map<String, Object> options) { consumeOption(options, "specification", specificationObject -> { try { final String authenticationType = ConnectorOptions.extractOption(options, "authenticationType"); final String specification = updateSecuritySpecification((String) specificationObject, authenticationType); final File tempSpecification = File.createTempFile("rest-swagger", ".json"); tempSpecification.deleteOnExit(); final String swaggerSpecificationPath = tempSpecification.getAbsolutePath(); try (OutputStream out = new FileOutputStream(swaggerSpecificationPath)) { IOUtils.write(specification, out, StandardCharsets.UTF_8); } options.put("specificationUri", "file:" + swaggerSpecificationPath); } catch (final JsonProcessingException jsonException) { throw new IllegalStateException("Unable to parse openapi specification", jsonException); } catch (final IOException e) { throw new IllegalStateException("Unable to persist the specification to filesystem", e); } }); }  }
SpecificationResourceCustomizer implements ComponentProxyCustomizer { @Override public void customize(final ComponentProxyComponent component, final Map<String, Object> options) { consumeOption(options, "specification", specificationObject -> { try { final String authenticationType = ConnectorOptions.extractOption(options, "authenticationType"); final String specification = updateSecuritySpecification((String) specificationObject, authenticationType); final File tempSpecification = File.createTempFile("rest-swagger", ".json"); tempSpecification.deleteOnExit(); final String swaggerSpecificationPath = tempSpecification.getAbsolutePath(); try (OutputStream out = new FileOutputStream(swaggerSpecificationPath)) { IOUtils.write(specification, out, StandardCharsets.UTF_8); } options.put("specificationUri", "file:" + swaggerSpecificationPath); } catch (final JsonProcessingException jsonException) { throw new IllegalStateException("Unable to parse openapi specification", jsonException); } catch (final IOException e) { throw new IllegalStateException("Unable to persist the specification to filesystem", e); } }); }  @Override void customize(final ComponentProxyComponent component, final Map<String, Object> options); }
SpecificationResourceCustomizer implements ComponentProxyCustomizer { @Override public void customize(final ComponentProxyComponent component, final Map<String, Object> options) { consumeOption(options, "specification", specificationObject -> { try { final String authenticationType = ConnectorOptions.extractOption(options, "authenticationType"); final String specification = updateSecuritySpecification((String) specificationObject, authenticationType); final File tempSpecification = File.createTempFile("rest-swagger", ".json"); tempSpecification.deleteOnExit(); final String swaggerSpecificationPath = tempSpecification.getAbsolutePath(); try (OutputStream out = new FileOutputStream(swaggerSpecificationPath)) { IOUtils.write(specification, out, StandardCharsets.UTF_8); } options.put("specificationUri", "file:" + swaggerSpecificationPath); } catch (final JsonProcessingException jsonException) { throw new IllegalStateException("Unable to parse openapi specification", jsonException); } catch (final IOException e) { throw new IllegalStateException("Unable to persist the specification to filesystem", e); } }); }  @Override void customize(final ComponentProxyComponent component, final Map<String, Object> options);  }