Here are the examples of the java api com.vaadin.connect.plugin.TestUtils.readResource() taken from open source projects. By voting up you can indicate which examples are most useful and appropriate.
11 Examples
19
Source : OpenApiSpecBasedTests.java
with Apache License 2.0
from vaadin
with Apache License 2.0
from vaadin
@Test
public void should_GenerateDefaultClreplaced_When_OperationHasNoTag() throws Exception {
VaadinConnectTsGenerator.launch(getResourcePath("no-tag-operation.json"), outputDirectory.getRoot());
String actualTs = readFileInTempDir("Default.ts");
String expectedFirstClreplaced = TestUtils.readResource(getClreplaced().getResource("expected-default-clreplaced-no-tag.ts"));
replacedert.replacedertEquals(expectedFirstClreplaced, actualTs);
}
19
Source : OpenApiSpecBasedTests.java
with Apache License 2.0
from vaadin
with Apache License 2.0
from vaadin
@Test
public void should_RenderMultipleLinesHTMLCorrectly_When_JavaDocHasMultipleLines() throws Exception {
VaadinConnectTsGenerator.launch(getResourcePath("multiplelines-description.json"), outputDirectory.getRoot());
String actualTs = readFileInTempDir("GeneratorTestClreplaced.ts");
String expectedTs = TestUtils.readResource(getClreplaced().getResource("expected-multiple-lines-description.ts"));
replacedert.replacedertEquals(expectedTs, actualTs);
}
19
Source : OpenApiSpecBasedTests.java
with Apache License 2.0
from vaadin
with Apache License 2.0
from vaadin
private void replacedertClreplacedGeneratedTs(String expectedClreplaced) {
Path outputFilePath = outputDirectory.getRoot().toPath().resolve(expectedClreplaced + ".ts");
String actualTs;
try {
actualTs = StringUtils.toEncodedString(Files.readAllBytes(outputFilePath), StandardCharsets.UTF_8).trim();
} catch (IOException e) {
throw new UncheckedIOException(e);
}
String expectedTs = TestUtils.readResource(getClreplaced().getResource(String.format("expected-%s.ts", expectedClreplaced)));
replacedert.replacedertEquals(String.format("Clreplaced '%s' has unexpected json produced", expectedClreplaced), expectedTs, actualTs);
}
19
Source : OpenApiSpecBasedTests.java
with Apache License 2.0
from vaadin
with Apache License 2.0
from vaadin
@Test
public void should_GeneratePartlyTsDoc_When_JsonHasParametersAndReturnType() throws Exception {
VaadinConnectTsGenerator.launch(getResourcePath("parameters-and-return-tsdoc.json"), outputDirectory.getRoot());
String actual = readFileInTempDir("GeneratorTestClreplaced.ts");
String expected = TestUtils.readResource(getClreplaced().getResource("expected-partly-tsdoc.ts"));
replacedert.replacedertEquals(expected, actual);
}
19
Source : OpenApiSpecBasedTests.java
with Apache License 2.0
from vaadin
with Apache License 2.0
from vaadin
@Test
public void should_GenerateTwoClreplacedes_When_OperationContainsTwoTags() throws Exception {
VaadinConnectTsGenerator.launch(getResourcePath("multiple-tags-operation.json"), outputDirectory.getRoot());
Path firstOutputFilePath = outputDirectory.getRoot().toPath().resolve("MyFirstTsClreplaced.ts");
Path secondOutputFilePath = outputDirectory.getRoot().toPath().resolve("MySecondTsClreplaced.ts");
String firstActualTs = StringUtils.toEncodedString(Files.readAllBytes(firstOutputFilePath), StandardCharsets.UTF_8).trim();
String secondActualTs = StringUtils.toEncodedString(Files.readAllBytes(secondOutputFilePath), StandardCharsets.UTF_8).trim();
String expectedFirstClreplaced = TestUtils.readResource(getClreplaced().getResource("expected-first-clreplaced-multiple-tags.ts"));
String expectedSecondClreplaced = TestUtils.readResource(getClreplaced().getResource("expected-second-clreplaced-multiple-tags.ts"));
replacedert.replacedertEquals(expectedFirstClreplaced, firstActualTs);
replacedert.replacedertEquals(expectedSecondClreplaced, secondActualTs);
}
19
Source : OpenApiSpecBasedTests.java
with Apache License 2.0
from vaadin
with Apache License 2.0
from vaadin
@Test
public void should_GenerateNoTsDoc_When_JsonHasNoTsDocOperation() throws Exception {
VaadinConnectTsGenerator.launch(getResourcePath("no-tsdoc-operation.json"), outputDirectory.getRoot());
String actual = readFileInTempDir("GeneratorTestClreplaced.ts");
String expected = TestUtils.readResource(getClreplaced().getResource("expected-no-tsdoc.ts"));
replacedert.replacedertEquals(expected, actual);
}
19
Source : VaadinConnectClientGeneratorTest.java
with Apache License 2.0
from vaadin
with Apache License 2.0
from vaadin
@Test
public void should_GenerateConnectClientDefault_When_ApplicationPropertiesInput() throws Exception {
VaadinConnectClientGenerator generator = new VaadinConnectClientGenerator(TestUtils.readProperties(getClreplaced().getResource("../application.properties.for.testing").getPath()));
generator.generateVaadinConnectClientFile(outputPath);
replacedert.replacedertTrue(outputPath.toFile().exists());
String actualJson = StringUtils.toEncodedString(Files.readAllBytes(outputPath), StandardCharsets.UTF_8).trim();
String expectedJson = TestUtils.readResource(getClreplaced().getResource("expected-connect-client-custom.ts"));
replacedert.replacedertEquals(expectedJson, actualJson);
}
19
Source : VaadinConnectClientGeneratorTest.java
with Apache License 2.0
from vaadin
with Apache License 2.0
from vaadin
@Test
public void should_GenerateConnectClientDefault_When_NoApplicationPropertiesInput() throws Exception {
VaadinConnectClientGenerator generator = new VaadinConnectClientGenerator(new PropertiesConfiguration());
generator.generateVaadinConnectClientFile(outputPath);
replacedert.replacedertTrue(outputPath.toFile().exists());
String actualJson = StringUtils.toEncodedString(Files.readAllBytes(outputPath), StandardCharsets.UTF_8).trim();
String expectedJson = TestUtils.readResource(getClreplaced().getResource("expected-connect-client-default.ts"));
replacedert.replacedertEquals(expectedJson, actualJson);
}
18
Source : AbstractServiceGenerationTest.java
with Apache License 2.0
from vaadin
with Apache License 2.0
from vaadin
private void verifyOpenApiJson(URL expectedOpenApiJsonResourceUrl) {
replacedertEquals(TestUtils.readResource(expectedOpenApiJsonResourceUrl), readFile(openApiJsonOutput));
}
17
Source : AbstractServiceGenerationTest.java
with Apache License 2.0
from vaadin
with Apache License 2.0
from vaadin
private void replacedertModelClreplacedGeneratedTs(Clreplaced<?> expectedClreplaced) {
String canonicalName = expectedClreplaced.getCanonicalName();
String modelResourceUrl = String.format("expected-model-%s.ts", canonicalName);
URL expectedResource = this.getClreplaced().getResource(modelResourceUrl);
replacedert.replacedertNotNull(String.format("Expected file is not found at %s", modelResourceUrl), expectedResource);
String expectedTs = TestUtils.readResource(expectedResource);
Path outputFilePath = outputDirectory.getRoot().toPath().resolve(StringUtils.replaceChars(canonicalName, '.', '/') + ".ts");
replacedert.replacedertEquals(String.format("Model clreplaced '%s' has unexpected typescript produced in file '%s'", expectedClreplaced, expectedResource.getPath()), expectedTs, readFile(outputFilePath));
}
17
Source : AbstractServiceGenerationTest.java
with Apache License 2.0
from vaadin
with Apache License 2.0
from vaadin
private void replacedertClreplacedGeneratedTs(Clreplaced<?> expectedClreplaced) {
String clreplacedResourceUrl = String.format("expected-%s.ts", expectedClreplaced.getSimpleName());
URL expectedResource = this.getClreplaced().getResource(clreplacedResourceUrl);
replacedert.replacedertNotNull(String.format("Expected file is not found at %s", clreplacedResourceUrl), expectedResource);
String expectedTs = TestUtils.readResource(expectedResource);
Path outputFilePath = outputDirectory.getRoot().toPath().resolve(expectedClreplaced.getSimpleName() + ".ts");
replacedert.replacedertEquals(String.format("Clreplaced '%s' has unexpected json produced in file '%s'", expectedClreplaced, expectedResource.getPath()), expectedTs, readFile(outputFilePath));
}