VaadinConnectClientGenerator { public void generateVaadinConnectClientFile(Path outputFilePath) { String generatedDefaultClientTs = getDefaultClientTsTemplate() .replace("{{PREFIX}}", endpointPrefix); try { log.info("writing file {}", outputFilePath); FileUtils.writeStringToFile(outputFilePath.toFile(), generatedDefaultClientTs, StandardCharsets.UTF_8); } catch (IOException e) { String errorMessage = String.format( "Error writing file at %s", outputFilePath.toString()); log.error(errorMessage, outputFilePath, e); } } VaadinConnectClientGenerator(
            Properties applicationProperties); void generateVaadinConnectClientFile(Path outputFilePath); static final String CONNECT_CLIENT_NAME; static final String CUSTOM_CONNECT_CLIENT_NAME; static final String CONNECT_CLIENT_IMPORT_PATH; }
@Test public void should_GenerateConnectClientDefault_When_NoApplicationPropertiesInput() throws Exception { VaadinConnectClientGenerator generator = new VaadinConnectClientGenerator( new Properties()); generator.generateVaadinConnectClientFile(outputPath); Assert.assertTrue(outputPath.toFile().exists()); String actualJson = StringUtils.toEncodedString( Files.readAllBytes(outputPath), StandardCharsets.UTF_8).trim(); String expectedJson = TestUtils.readResource( getClass().getResource("expected-connect-client-default.ts")); Assert.assertEquals(expectedJson, actualJson); }
@Test public void should_GenerateConnectClientDefault_When_ApplicationPropertiesInput() throws Exception { VaadinConnectClientGenerator generator = new VaadinConnectClientGenerator( TestUtils.readProperties(getClass() .getResource("application.properties.for.testing") .getPath())); generator.generateVaadinConnectClientFile(outputPath); Assert.assertTrue(outputPath.toFile().exists()); String actualJson = StringUtils.toEncodedString( Files.readAllBytes(outputPath), StandardCharsets.UTF_8).trim(); String expectedJson = TestUtils.readResource( getClass().getResource("expected-connect-client-custom.ts")); Assert.assertEquals(expectedJson, actualJson); }