Skip to content

Commit

Permalink
[SCB-2803]fix checkstyle and test fails
Browse files Browse the repository at this point in the history
  • Loading branch information
liubao68 committed Aug 23, 2023
1 parent 6ad909d commit c6eeb90
Show file tree
Hide file tree
Showing 11 changed files with 58 additions and 142 deletions.
4 changes: 4 additions & 0 deletions ci/checkstyle/checkstyle.xml
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,10 @@
<property name="message" value="Trailing whitespace"/>
<property name="severity" value="error"/>
</module>
<module name="SuppressWithPlainTextCommentFilter">
<property name="offCommentFormat" value="CHECKSTYLE.OFF"/>
<property name="onCommentFormat" value="CHECKSTYLE.ON"/>
</module>
<module name="TreeWalker">
<module name="AvoidStarImport"/>
<module name="EmptyStatement"/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
import io.swagger.v3.oas.models.media.StringSchema;
import jakarta.ws.rs.core.MediaType;

//CHECKSTYLE:OFF
@SuppressWarnings("unused")
public class TestSchemaToProtoGenerator {
@Test
Expand Down Expand Up @@ -117,8 +118,7 @@ public void test_springmvc_int_schema_correct() {
message testIntRequest {
int32 value = 1;
}
""", new ProtoToStringGenerator(proto).protoToString());
""".trim(), new ProtoToStringGenerator(proto).protoToString().trim());

protoGenerator =
new SchemaToProtoGenerator("test.int", openAPI,
Expand All @@ -134,8 +134,7 @@ public void test_springmvc_int_schema_correct() {
message testIntResponse {
int32 value = 1;
}
""", new ProtoToStringGenerator(proto).protoToString());
""".trim(), new ProtoToStringGenerator(proto).protoToString().trim());
}


Expand Down Expand Up @@ -163,8 +162,7 @@ public void test_springmvc_model_schema_correct() {
message testModelRequest {
Model value = 1;
}
""", new ProtoToStringGenerator(proto).protoToString());
""".trim(), new ProtoToStringGenerator(proto).protoToString().trim());

protoGenerator =
new SchemaToProtoGenerator("test.model", openAPI,
Expand All @@ -185,7 +183,7 @@ public void test_springmvc_model_schema_correct() {
message testIntResponse {
Model value = 1;
}
""", new ProtoToStringGenerator(proto).protoToString());
""".trim(), new ProtoToStringGenerator(proto).protoToString().trim());
}
}
//CHECKSTYLE:ON
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@

package org.apache.servicecomb.common.rest;

import static jakarta.ws.rs.core.Response.Status.NOT_ACCEPTABLE;
import static jakarta.ws.rs.core.Response.Status.NOT_FOUND;
import static org.assertj.core.api.Assertions.assertThat;
import static org.assertj.core.api.Assertions.catchThrowable;
Expand Down Expand Up @@ -50,7 +49,6 @@

import io.vertx.core.json.Json;
import io.vertx.ext.web.RoutingContext;
import jakarta.ws.rs.core.HttpHeaders;

public class RestProducerInvocationCreatorTest {

Expand Down
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@
<werror.properties></werror.properties>
<!-- plugin version start -->
<!-- sort by alpha -->
<checkstyle-maven-plugin.version>3.2.2</checkstyle-maven-plugin.version>
<checkstyle-maven-plugin.version>3.3.0</checkstyle-maven-plugin.version>
<coveralls-maven-plugin.version>4.3.0</coveralls-maven-plugin.version>
<dependency-check-maven-plugin.version>8.3.1</dependency-check-maven-plugin.version>
<docker-maven-plugin.version>0.43.3</docker-maven-plugin.version>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -300,8 +300,8 @@ public static boolean propertiesEquals(Map<String, Schema> properties1, Map<Stri
return false;
}
boolean result = true;
for (String key : properties1.keySet()) {
if (!schemaEquals(properties1.get(key), properties2.get(key))) {
for (Entry<String, Schema> item : properties1.entrySet()) {
if (!schemaEquals(item.getValue(), properties2.get(item.getKey()))) {
result = false;
break;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -80,28 +80,27 @@ public void part(@RequestPart MultipartFile part) {

}

// TODO: this should fail. RequestMapping not parse consumes and produces.
@RequestMapping("partArray")
@RequestMapping(value = "partArray", consumes = MediaType.MULTIPART_FORM_DATA)
public void partArray(@RequestPart MultipartFile[] part) {

}

@RequestMapping("partList")
@RequestMapping(value = "partList", consumes = MediaType.MULTIPART_FORM_DATA)
public void partList(@RequestPart List<MultipartFile> part) {

}

@RequestMapping("partAnnotation")
@RequestMapping(value = "partAnnotation", consumes = MediaType.MULTIPART_FORM_DATA)
public void partAnnotation(@RequestPart MultipartFile part) {

}

@RequestMapping("partArrayAnnotation")
@RequestMapping(value = "partArrayAnnotation", consumes = MediaType.MULTIPART_FORM_DATA)
public void partArrayAnnotation(@RequestPart MultipartFile[] part) {

}

@RequestMapping("partListAnnotation")
@RequestMapping(value = "partListAnnotation", consumes = MediaType.MULTIPART_FORM_DATA)
public void partListAnnotation(@RequestPart List<MultipartFile> part) {

}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,53 +54,53 @@ public class MethodMixupAnnotations {
@RequestMapping(
path = "usingRequestMapping/{targetName}",
method = {RequestMethod.POST},
consumes = {"text/plain", "application/*"},
produces = {"text/plain", "application/*"})
consumes = {"text/plain", "application/json"},
produces = {"text/plain", "application/json"})
public String usingRequestMapping(@RequestBody User srcUser, @RequestHeader String header,
@PathVariable String targetName, @RequestParam(name = "word") String word) {
return String.format("%s %s %s %s", srcUser.name, header, targetName, word);
}

@GetMapping(
path = "usingGetMapping/{targetName}",
consumes = {"text/plain", "application/*"},
produces = {"text/plain", "application/*"})
consumes = {"text/plain", "application/json"},
produces = {"text/plain", "application/json"})
public String usingGetMapping(@RequestBody User srcUser, @RequestHeader String header,
@PathVariable String targetName, @RequestParam(name = "word") String word) {
return String.format("%s %s %s %s", srcUser.name, header, targetName, word);
}

@PutMapping(
path = "usingPutMapping/{targetName}",
consumes = {"text/plain", "application/*"},
produces = {"text/plain", "application/*"})
consumes = {"text/plain", "application/json"},
produces = {"text/plain", "application/json"})
public String usingPutMapping(@RequestBody User srcUser, @RequestHeader String header,
@PathVariable String targetName, @RequestParam(name = "word") String word) {
return String.format("%s %s %s %s", srcUser.name, header, targetName, word);
}

@PostMapping(
path = "usingPostMapping/{targetName}",
consumes = {"text/plain", "application/*"},
produces = {"text/plain", "application/*"})
consumes = {"text/plain", "application/json"},
produces = {"text/plain", "application/json"})
public String usingPostMapping(@RequestBody User srcUser, @RequestHeader String header,
@PathVariable String targetName, @RequestParam(name = "word") String word) {
return String.format("%s %s %s %s", srcUser.name, header, targetName, word);
}

@PatchMapping(
path = "usingPatchMapping/{targetName}",
consumes = {"text/plain", "application/*"},
produces = {"text/plain", "application/*"})
consumes = {"text/plain", "application/json"},
produces = {"text/plain", "application/json"})
public String usingPatchMapping(@RequestBody User srcUser, @RequestHeader String header,
@PathVariable String targetName, @RequestParam(name = "word") String word) {
return String.format("%s %s %s %s", srcUser.name, header, targetName, word);
}

@DeleteMapping(
path = "usingDeleteMapping/{targetName}",
consumes = {"text/plain", "application/*"},
produces = {"text/plain", "application/*"})
consumes = {"text/plain", "application/json"},
produces = {"text/plain", "application/json"})
public String usingDeleteMapping(@RequestBody User srcUser, @RequestHeader String header,
@PathVariable String targetName, @RequestParam(name = "word") String word) {
return String.format("%s %s %s %s", srcUser.name, header, targetName, word);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ public String testUnsupportedParamType(int i, List<TestParam> integerList, Map<S
return null;
}

@RequestMapping(path = "testSingleMediaType", method = RequestMethod.POST, consumes = MediaType.APPLICATION_XML, produces = MediaType.APPLICATION_XML)
@RequestMapping(path = "testSingleMediaType", method = RequestMethod.POST, consumes = MediaType.APPLICATION_JSON, produces = MediaType.APPLICATION_JSON)
public String testSingleMediaType(String input) {
return input;
}
Expand All @@ -55,7 +55,7 @@ public String testMultipleMediaType(String input) {
return input;
}

@RequestMapping(path = "testBlankMediaType", method = RequestMethod.POST, consumes = "", produces = "")
@RequestMapping(path = "testBlankMediaType", method = RequestMethod.POST)
public String testBlankMediaType(String input) {
return input;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,13 +56,10 @@ paths:
"200":
description: response of 200
content:
application/json:
schema:
type: string
application/protobuf:
text/plain:
schema:
type: string
text/plain:
application/json:
schema:
type: string
/testObjectParam:
Expand Down Expand Up @@ -127,12 +124,6 @@ paths:
application/json:
schema:
type: string
application/protobuf:
schema:
type: string
text/plain:
schema:
type: string
/testUnsupportedParamType:
get:
operationId: testUnsupportedParamType
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,11 +35,6 @@ paths:
type: array
items:
type: string
application/protobuf:
schema:
type: array
items:
type: string
text/plain:
schema:
type: array
Expand Down Expand Up @@ -76,13 +71,6 @@ paths:
- RED
- YELLOW
- BLUE
application/protobuf:
schema:
type: string
enum:
- RED
- YELLOW
- BLUE
text/plain:
schema:
type: string
Expand Down Expand Up @@ -119,13 +107,6 @@ paths:
type: array
items:
type: string
application/protobuf:
schema:
type: array
items:
type: array
items:
type: string
text/plain:
schema:
type: array
Expand All @@ -146,13 +127,6 @@ paths:
type: array
items:
type: string
application/protobuf:
schema:
type: array
items:
type: array
items:
type: string
text/plain:
schema:
type: array
Expand Down Expand Up @@ -285,9 +259,6 @@ paths:
application/json:
schema:
type: string
application/protobuf:
schema:
type: string
text/plain:
schema:
type: string
Expand All @@ -301,9 +272,6 @@ paths:
application/json:
schema:
type: string
application/protobuf:
schema:
type: string
text/plain:
schema:
type: string
Expand Down
Loading

0 comments on commit c6eeb90

Please sign in to comment.