diff --git a/.baseline/checkstyle/checkstyle.xml b/.baseline/checkstyle/checkstyle.xml
index cd19cae45..5d8bc6ef7 100644
--- a/.baseline/checkstyle/checkstyle.xml
+++ b/.baseline/checkstyle/checkstyle.xml
@@ -201,10 +201,6 @@
-
-
-
-
diff --git a/build.gradle b/build.gradle
index 50d5467cb..e0b7fc0e4 100644
--- a/build.gradle
+++ b/build.gradle
@@ -26,6 +26,7 @@ buildscript {
}
dependencies {
+ classpath 'com.palantir.javaformat:gradle-palantir-java-format:0.3.28'
classpath 'com.netflix.nebula:gradle-info-plugin:5.2.0'
classpath 'com.netflix.nebula:nebula-publishing-plugin:14.1.1'
classpath 'com.jfrog.bintray.gradle:gradle-bintray-plugin:1.8.4'
@@ -40,6 +41,7 @@ apply plugin: 'com.palantir.baseline'
apply from: 'gradle/publish-rust-dist.gradle'
allprojects {
+ apply plugin: 'com.palantir.java-format'
version gitVersion()
group 'com.palantir.conjure.verification'
diff --git a/test-cases-internal/src/main/java/com/palantir/conjure/verification/EndpointNameConjureTypeVisitor.java b/test-cases-internal/src/main/java/com/palantir/conjure/verification/EndpointNameConjureTypeVisitor.java
index 364891c21..7271d303f 100644
--- a/test-cases-internal/src/main/java/com/palantir/conjure/verification/EndpointNameConjureTypeVisitor.java
+++ b/test-cases-internal/src/main/java/com/palantir/conjure/verification/EndpointNameConjureTypeVisitor.java
@@ -46,8 +46,8 @@ public String visitList(ListType type) {
@Override
public String visitMap(MapType type) {
- return "mapOf" + StringUtils.capitalize(type.keyType().visit(this))
- + "To" + StringUtils.capitalize(type.valueType().visit(this));
+ return "mapOf" + StringUtils.capitalize(type.keyType().visit(this)) + "To"
+ + StringUtils.capitalize(type.valueType().visit(this));
}
@Override
diff --git a/test-cases-internal/src/main/java/com/palantir/conjure/verification/GenerateClientServices.java b/test-cases-internal/src/main/java/com/palantir/conjure/verification/GenerateClientServices.java
index f16a1f0fd..bcb2ab893 100644
--- a/test-cases-internal/src/main/java/com/palantir/conjure/verification/GenerateClientServices.java
+++ b/test-cases-internal/src/main/java/com/palantir/conjure/verification/GenerateClientServices.java
@@ -35,17 +35,21 @@ public static void main(String... args) throws IOException {
generateAutoDeserializeService(testCases.getBody()));
}
- private static void writeServiceDefinition(
- File fileName, String serviceName, Map service) throws IOException {
- TestCasesUtils.YAML_MAPPER.writeValue(fileName,
- createConjureYmlBuilder().put("services", ImmutableMap.of(serviceName, service)).build());
+ private static void writeServiceDefinition(File fileName, String serviceName, Map service)
+ throws IOException {
+ TestCasesUtils.YAML_MAPPER.writeValue(
+ fileName,
+ createConjureYmlBuilder()
+ .put("services", ImmutableMap.of(serviceName, service))
+ .build());
}
private static ImmutableMap.Builder createConjureYmlBuilder() {
ImmutableMap.Builder builder = ImmutableMap.builder();
builder.put(
"types",
- ImmutableMap.of("conjure-imports",
+ ImmutableMap.of(
+ "conjure-imports",
ImmutableMap.of(
"examples", "../example-types.conjure.yml",
"testCases", "../test-cases.conjure.yml")));
@@ -55,14 +59,22 @@ private static ImmutableMap.Builder createConjureYmlBuilder() {
private static Map generateAutoDeserializeService(List bodyTests) {
ImmutableMap.Builder endpoints = ImmutableMap.builder();
- bodyTests.stream().map(BodyTests::getType).map(TestCasesUtils::parseConjureType).forEach(conjureType -> {
- String endpointName = TestCasesUtils.typeToEndpointName("get", conjureType);
- String typeName = conjureType.visit(new ResolveLocalReferencesConjureTypeVisitor());
- endpoints.put(endpointName, ImmutableMap.of(
- "http", "POST /" + endpointName,
- "returns", typeName,
- "args", ImmutableMap.of("body", typeName)));
- });
+ bodyTests.stream()
+ .map(BodyTests::getType)
+ .map(TestCasesUtils::parseConjureType)
+ .forEach(conjureType -> {
+ String endpointName = TestCasesUtils.typeToEndpointName("get", conjureType);
+ String typeName = conjureType.visit(new ResolveLocalReferencesConjureTypeVisitor());
+ endpoints.put(
+ endpointName,
+ ImmutableMap.of(
+ "http",
+ "POST /" + endpointName,
+ "returns",
+ typeName,
+ "args",
+ ImmutableMap.of("body", typeName)));
+ });
return ImmutableMap.of(
"name", "Auto Deserialize Service",
diff --git a/test-cases-internal/src/main/java/com/palantir/conjure/verification/GenerateServerServices.java b/test-cases-internal/src/main/java/com/palantir/conjure/verification/GenerateServerServices.java
index 68d2125be..a55e8116a 100644
--- a/test-cases-internal/src/main/java/com/palantir/conjure/verification/GenerateServerServices.java
+++ b/test-cases-internal/src/main/java/com/palantir/conjure/verification/GenerateServerServices.java
@@ -29,44 +29,61 @@ public static void main(String... args) throws IOException {
Files.createDirectories(outputDir.toPath());
MoreFiles.deleteDirectoryContents(outputDir.toPath(), RecursiveDeleteOption.ALLOW_INSECURE);
- writeServiceDefinition(new File(outputDir, "auto-deserialize-service.conjure.yml"),
+ writeServiceDefinition(
+ new File(outputDir, "auto-deserialize-service.conjure.yml"),
"AutoDeserializeService",
generateAutoDeserializeService(testCases.getBody()));
writeServiceDefinition(
new File(outputDir, "auto-deserialize-confirm-service.conjure.yml"),
"AutoDeserializeConfirmService",
generateAutoDeserializeConfirmService(testCases.getBody()));
- writeServiceDefinition(new File(outputDir, "single-header-service.conjure.yml"),
+ writeServiceDefinition(
+ new File(outputDir, "single-header-service.conjure.yml"),
"SingleHeaderService",
generateSingleHeaderService(testCases.getSingleHeaderParam()));
- writeServiceDefinition(new File(outputDir, "single-path-param-service.conjure.yml"),
+ writeServiceDefinition(
+ new File(outputDir, "single-path-param-service.conjure.yml"),
"SinglePathParamService",
generateSinglePathParamService(testCases.getSinglePathParam()));
- writeServiceDefinition(new File(outputDir, "single-query-param-service.conjure.yml"),
+ writeServiceDefinition(
+ new File(outputDir, "single-query-param-service.conjure.yml"),
"SingleQueryParamService",
generateSingleQueryParamService(testCases.getSingleQueryParam()));
}
private static Map generateAutoDeserializeConfirmService(List body) {
ImmutableMap.Builder endpoints = ImmutableMap.builder();
- endpoints.put("confirm", ImmutableMap.builder()
- .put("http", "POST /{endpoint}/{index}")
- .put("docs", "Send the response received for positive test cases here to verify that it has been "
- + "serialized and deserialized properly.")
- .put("args", ImmutableMap.builder()
- .put("endpoint", "testCases.EndpointName")
- .put("index", "integer")
- .put("body", "any")
- .build())
- .build());
-
- body.stream().map(BodyTests::getType).map(TestCasesUtils::parseConjureType).forEach(conjureType -> {
- String endpointName = TestCasesUtils.typeToEndpointName("receive", conjureType);
- String typeName = conjureType.visit(new ResolveLocalReferencesConjureTypeVisitor());
- endpoints.put(endpointName, ImmutableMap.of(
- "http", "POST /" + endpointName + "/{index}",
- "args", ImmutableMap.of("index", "integer", "body", typeName)));
- });
+ endpoints.put(
+ "confirm",
+ ImmutableMap.builder()
+ .put("http", "POST /{endpoint}/{index}")
+ .put(
+ "docs",
+ "Send the response received for positive test cases here to verify that it has been "
+ + "serialized and deserialized properly.")
+ .put(
+ "args",
+ ImmutableMap.builder()
+ .put("endpoint", "testCases.EndpointName")
+ .put("index", "integer")
+ .put("body", "any")
+ .build())
+ .build());
+
+ body.stream()
+ .map(BodyTests::getType)
+ .map(TestCasesUtils::parseConjureType)
+ .forEach(conjureType -> {
+ String endpointName = TestCasesUtils.typeToEndpointName("receive", conjureType);
+ String typeName = conjureType.visit(new ResolveLocalReferencesConjureTypeVisitor());
+ endpoints.put(
+ endpointName,
+ ImmutableMap.of(
+ "http",
+ "POST /" + endpointName + "/{index}",
+ "args",
+ ImmutableMap.of("index", "integer", "body", typeName)));
+ });
return ImmutableMap.of(
"name", "Auto Deserialize Confirm Service",
@@ -76,17 +93,21 @@ private static Map generateAutoDeserializeConfirmService(List service) throws IOException {
- TestCasesUtils.YAML_MAPPER.writeValue(fileName,
- createConjureYmlBuilder().put("services", ImmutableMap.of(serviceName, service)).build());
+ private static void writeServiceDefinition(File fileName, String serviceName, Map service)
+ throws IOException {
+ TestCasesUtils.YAML_MAPPER.writeValue(
+ fileName,
+ createConjureYmlBuilder()
+ .put("services", ImmutableMap.of(serviceName, service))
+ .build());
}
private static ImmutableMap.Builder createConjureYmlBuilder() {
ImmutableMap.Builder builder = ImmutableMap.builder();
builder.put(
"types",
- ImmutableMap.of("conjure-imports",
+ ImmutableMap.of(
+ "conjure-imports",
ImmutableMap.of(
"examples", "../example-types.conjure.yml",
"testCases", "../test-cases.conjure.yml")));
@@ -96,14 +117,22 @@ private static ImmutableMap.Builder createConjureYmlBuilder() {
private static Map generateAutoDeserializeService(List bodyTests) {
ImmutableMap.Builder endpoints = ImmutableMap.builder();
- bodyTests.stream().map(BodyTests::getType).map(TestCasesUtils::parseConjureType).forEach(conjureType -> {
- String endpointName = TestCasesUtils.typeToEndpointName("receive", conjureType);
- String typeName = conjureType.visit(new ResolveLocalReferencesConjureTypeVisitor());
- endpoints.put(endpointName, ImmutableMap.of(
- "http", "GET /" + endpointName + "/{index}",
- "returns", typeName,
- "args", ImmutableMap.of("index", "integer")));
- });
+ bodyTests.stream()
+ .map(BodyTests::getType)
+ .map(TestCasesUtils::parseConjureType)
+ .forEach(conjureType -> {
+ String endpointName = TestCasesUtils.typeToEndpointName("receive", conjureType);
+ String typeName = conjureType.visit(new ResolveLocalReferencesConjureTypeVisitor());
+ endpoints.put(
+ endpointName,
+ ImmutableMap.of(
+ "http",
+ "GET /" + endpointName + "/{index}",
+ "returns",
+ typeName,
+ "args",
+ ImmutableMap.of("index", "integer")));
+ });
return ImmutableMap.of(
"name", "Auto Deserialize Service",
@@ -116,21 +145,26 @@ private static Map generateAutoDeserializeService(List generateSingleHeaderService(List testCases) {
ImmutableMap.Builder endpoints = ImmutableMap.builder();
- testCases
- .stream()
+ testCases.stream()
.map(SingleHeaderParamTests::getType)
.map(TestCasesUtils::parseConjureType)
.forEach(conjureType -> {
String endpointName = TestCasesUtils.typeToEndpointName("header", conjureType);
String typeName = conjureType.visit(new ResolveLocalReferencesConjureTypeVisitor());
- endpoints.put(endpointName, ImmutableMap.of(
- "http", "POST /" + endpointName + "/{index}",
- "args", ImmutableMap.of(
- "index", "integer",
- "header", ImmutableMap.of(
- "type", typeName,
- "param-type", "header",
- "param-id", "Some-Header"))));
+ endpoints.put(
+ endpointName,
+ ImmutableMap.of(
+ "http",
+ "POST /" + endpointName + "/{index}",
+ "args",
+ ImmutableMap.of(
+ "index",
+ "integer",
+ "header",
+ ImmutableMap.of(
+ "type", typeName,
+ "param-type", "header",
+ "param-id", "Some-Header"))));
});
return ImmutableMap.of(
@@ -144,18 +178,19 @@ private static Map generateSingleHeaderService(List generateSinglePathParamService(List testCases) {
ImmutableMap.Builder endpoints = ImmutableMap.builder();
- testCases
- .stream()
+ testCases.stream()
.map(SinglePathParamTests::getType)
.map(TestCasesUtils::parseConjureType)
.forEach(conjureType -> {
String endpointName = TestCasesUtils.typeToEndpointName("pathParam", conjureType);
String typeName = conjureType.visit(new ResolveLocalReferencesConjureTypeVisitor());
- endpoints.put(endpointName, ImmutableMap.of(
- "http", "POST /" + endpointName + "/{index}/{param}",
- "args", ImmutableMap.of(
- "index", "integer",
- "param", typeName)));
+ endpoints.put(
+ endpointName,
+ ImmutableMap.of(
+ "http",
+ "POST /" + endpointName + "/{index}/{param}",
+ "args",
+ ImmutableMap.of("index", "integer", "param", typeName)));
});
return ImmutableMap.of(
@@ -175,14 +210,20 @@ private static Map generateSingleQueryParamService(List {
String endpointName = TestCasesUtils.typeToEndpointName("queryParam", conjureType);
String typeName = conjureType.visit(new ResolveLocalReferencesConjureTypeVisitor());
- endpoints.put(endpointName, ImmutableMap.of(
- "http", "POST /" + endpointName + "/{index}",
- "args", ImmutableMap.of(
- "index", "integer",
- "someQuery", ImmutableMap.of(
- "type", typeName,
- "param-type", "query",
- "param-id", "foo"))));
+ endpoints.put(
+ endpointName,
+ ImmutableMap.of(
+ "http",
+ "POST /" + endpointName + "/{index}",
+ "args",
+ ImmutableMap.of(
+ "index",
+ "integer",
+ "someQuery",
+ ImmutableMap.of(
+ "type", typeName,
+ "param-type", "query",
+ "param-id", "foo"))));
});
return ImmutableMap.of(
@@ -192,5 +233,4 @@ private static Map generateSingleQueryParamService(List files = Streams
- .stream(MoreFiles.fileTraverser().breadthFirst(Paths.get("src/main/conjure")))
+ List files = Streams.stream(MoreFiles.fileTraverser().breadthFirst(Paths.get("src/main/conjure")))
.filter(MoreFiles.isDirectory().negate())
.filter(path -> path.getFileName().toString().endsWith(".yml"))
.map(Path::toFile)
@@ -78,8 +77,8 @@ public static void main(String... args) throws IOException {
ConjureDefinition ir = Conjure.parse(files);
checkEndpointNamesMatchPaths(ir);
- checkNoLeftovers(outputFile, serverTestCases.getAutoDeserialize().keySet(),
- serviceByName(ir, "AutoDeserializeService"));
+ checkNoLeftovers(
+ outputFile, serverTestCases.getAutoDeserialize().keySet(), serviceByName(ir, "AutoDeserializeService"));
}
private static long countPositiveAndNegative(Map tests) {
@@ -93,21 +92,19 @@ private static void checkEndpointNamesMatchPaths(ConjureDefinition ir) {
String name = service.getServiceName().getName();
service.getEndpoints().forEach(endpoint -> {
- if (!endpoint.getHttpPath().get().contains(endpoint.getEndpointName().get())) {
+ if (!endpoint.getHttpPath()
+ .get()
+ .contains(endpoint.getEndpointName().get())) {
throw new RuntimeException(String.format(
"%s#%s has an inconsistent path: %s",
- name,
- endpoint.getEndpointName(),
- endpoint.getHttpPath()));
+ name, endpoint.getEndpointName(), endpoint.getHttpPath()));
}
});
});
}
private static void checkNoLeftovers(
- File outputFile,
- Set testCases,
- ServiceDefinition serviceDefinition) {
+ File outputFile, Set testCases, ServiceDefinition serviceDefinition) {
Set fromTestCasesYml = testCases.stream().map(EndpointName::get).collect(toSet());
@@ -129,28 +126,27 @@ private static void checkNoLeftovers(
}
private static ServiceDefinition serviceByName(ConjureDefinition ir, String name) {
- return ir.getServices().stream().filter(s -> s.getServiceName().getName().equals(name)).findFirst().get();
+ return ir.getServices().stream()
+ .filter(s -> s.getServiceName().getName().equals(name))
+ .findFirst()
+ .get();
}
private static Map generateBodyTestCases(List bodyTests) {
ImmutableMap.Builder builder = ImmutableMap.builder();
- bodyTests.forEach(t ->
- builder.put(endpointName("get", t.getType()),
- PositiveAndNegativeTestCases
- .builder()
- .positive(t.getPositive().stream().map(TestCase::get).collect(Collectors.toList()))
- .negative(t.getNegative().stream().map(TestCase::get).collect(Collectors.toList()))
- .addAllNegative(t
- .getClientPositiveServerFail()
- .stream()
- .map(TestCase::get)
- .collect(Collectors.toList()))
- .build()));
+ bodyTests.forEach(t -> builder.put(
+ endpointName("get", t.getType()),
+ PositiveAndNegativeTestCases.builder()
+ .positive(t.getPositive().stream().map(TestCase::get).collect(Collectors.toList()))
+ .negative(t.getNegative().stream().map(TestCase::get).collect(Collectors.toList()))
+ .addAllNegative(t.getClientPositiveServerFail().stream()
+ .map(TestCase::get)
+ .collect(Collectors.toList()))
+ .build()));
return builder.build();
}
private static EndpointName endpointName(String prefix, ConjureTypeString type) {
- return EndpointName.of(
- TestCasesUtils.typeToEndpointName(prefix, TestCasesUtils.parseConjureType(type)));
+ return EndpointName.of(TestCasesUtils.typeToEndpointName(prefix, TestCasesUtils.parseConjureType(type)));
}
}
diff --git a/verification-server-api/src/main/java/com/palantir/conjure/verification/server/CompileVerificationServerTestCasesJson.java b/verification-server-api/src/main/java/com/palantir/conjure/verification/server/CompileVerificationServerTestCasesJson.java
index d2b4f639c..e72689bc2 100644
--- a/verification-server-api/src/main/java/com/palantir/conjure/verification/server/CompileVerificationServerTestCasesJson.java
+++ b/verification-server-api/src/main/java/com/palantir/conjure/verification/server/CompileVerificationServerTestCasesJson.java
@@ -66,8 +66,7 @@ public static void main(String... args) throws IOException {
System.out.println("Total test cases: " + total);
jsonMapper.writerWithDefaultPrettyPrinter().writeValue(outputFile, testCases);
- List files = Streams
- .stream(MoreFiles.fileTraverser().breadthFirst(Paths.get("src/main/conjure")))
+ List files = Streams.stream(MoreFiles.fileTraverser().breadthFirst(Paths.get("src/main/conjure")))
.filter(MoreFiles.isDirectory().negate())
.filter(path -> path.getFileName().toString().endsWith(".yml"))
.map(Path::toFile)
@@ -75,20 +74,24 @@ public static void main(String... args) throws IOException {
ConjureDefinition ir = Conjure.parse(files);
checkEndpointNamesMatchPaths(ir);
- checkNoLeftovers(outputFile, clientTestCases.getAutoDeserialize().keySet(),
- serviceByName(ir, "AutoDeserializeService"));
- checkNoLeftovers(outputFile, clientTestCases.getSingleHeaderService().keySet(),
+ checkNoLeftovers(
+ outputFile, clientTestCases.getAutoDeserialize().keySet(), serviceByName(ir, "AutoDeserializeService"));
+ checkNoLeftovers(
+ outputFile,
+ clientTestCases.getSingleHeaderService().keySet(),
serviceByName(ir, "SingleHeaderService"));
- checkNoLeftovers(outputFile, clientTestCases.getSinglePathParamService().keySet(),
+ checkNoLeftovers(
+ outputFile,
+ clientTestCases.getSinglePathParamService().keySet(),
serviceByName(ir, "SinglePathParamService"));
- checkNoLeftovers(outputFile, clientTestCases.getSingleQueryParamService().keySet(),
+ checkNoLeftovers(
+ outputFile,
+ clientTestCases.getSingleQueryParamService().keySet(),
serviceByName(ir, "SingleQueryParamService"));
}
private static long countTestCases(Map> tests) {
- return tests.entrySet().stream()
- .flatMap(e -> e.getValue().stream())
- .count();
+ return tests.entrySet().stream().flatMap(e -> e.getValue().stream()).count();
}
private static long countPositiveAndNegative(Map tests) {
@@ -102,12 +105,12 @@ private static void checkEndpointNamesMatchPaths(ConjureDefinition ir) {
String name = service.getServiceName().getName();
service.getEndpoints().forEach(endpoint -> {
- if (!endpoint.getHttpPath().get().contains(endpoint.getEndpointName().get())) {
+ if (!endpoint.getHttpPath()
+ .get()
+ .contains(endpoint.getEndpointName().get())) {
throw new RuntimeException(String.format(
"%s#%s has an inconsistent path: %s",
- name,
- endpoint.getEndpointName(),
- endpoint.getHttpPath()));
+ name, endpoint.getEndpointName(), endpoint.getHttpPath()));
}
});
});
@@ -136,23 +139,23 @@ private static void checkNoLeftovers(
}
private static ServiceDefinition serviceByName(ConjureDefinition ir, String name) {
- return ir.getServices().stream().filter(s -> s.getServiceName().getName().equals(name)).findFirst().get();
+ return ir.getServices().stream()
+ .filter(s -> s.getServiceName().getName().equals(name))
+ .findFirst()
+ .get();
}
private static Map generateBodyTestCases(List bodyTests) {
ImmutableMap.Builder builder = ImmutableMap.builder();
- bodyTests.forEach(t ->
- builder.put(endpointName("receive", t.getType()),
- PositiveAndNegativeTestCases
- .builder()
- .positive(t.getPositive().stream().map(TestCase::get).collect(Collectors.toList()))
- .negative(t.getNegative().stream().map(TestCase::get).collect(Collectors.toList()))
- .addAllPositive(t
- .getClientPositiveServerFail()
- .stream()
- .map(TestCase::get)
- .collect(Collectors.toList()))
- .build()));
+ bodyTests.forEach(t -> builder.put(
+ endpointName("receive", t.getType()),
+ PositiveAndNegativeTestCases.builder()
+ .positive(t.getPositive().stream().map(TestCase::get).collect(Collectors.toList()))
+ .negative(t.getNegative().stream().map(TestCase::get).collect(Collectors.toList()))
+ .addAllPositive(t.getClientPositiveServerFail().stream()
+ .map(TestCase::get)
+ .collect(Collectors.toList()))
+ .build()));
return builder.build();
}