Skip to content

Commit

Permalink
Tests has been added
Browse files Browse the repository at this point in the history
  • Loading branch information
viclovsky committed Jan 26, 2018
1 parent 51d7991 commit c698765
Show file tree
Hide file tree
Showing 39 changed files with 1,591 additions and 693 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -530,7 +530,7 @@ CONFIG OPTIONS
retrofit - HTTP client: OkHttp 2.4.0. JSON processing: Gson 2.3.1 (Retrofit 1.9.0)
retrofit2 - HTTP client: OkHttp 2.5.0. JSON processing: Gson 2.4 (Retrofit 2.0.0-beta2)
google-api-client - HTTP client: google-api-client 1.23.0. JSON processing: Jackson 2.8.9
rest-assured", "HTTP client: rest-assured : 3.0.6. JSON processing: JSON processing: Gson 2.6.1
rest-assured - HTTP client: rest-assured : 3.0.6. JSON processing: Gson 2.6.1. Only for Java8
```

Your config file for Java can look like
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ public JavaClientCodegen() {
supportedLibraries.put("resteasy", "HTTP client: Resteasy client 3.1.3.Final. JSON processing: Jackson 2.8.9");
supportedLibraries.put("vertx", "HTTP client: VertX client 3.2.4. JSON processing: Jackson 2.8.9");
supportedLibraries.put("google-api-client", "HTTP client: Google API client 1.23.0. JSON processing: Jackson 2.8.9");
supportedLibraries.put("rest-assured", "HTTP client: rest-assured : 3.0.6. JSON processing: JSON processing: Gson 2.6.1");
supportedLibraries.put("rest-assured", "HTTP client: rest-assured : 3.0.6. JSON processing: Gson 2.6.1. Only for Java8");

CliOption libraryOption = new CliOption(CodegenConstants.LIBRARY, "library template (sub-template) to use");
libraryOption.setEnum(supportedLibraries);
Expand Down Expand Up @@ -250,9 +250,11 @@ public void processOpts() {
additionalProperties.put("jackson", "true");

} else if (REST_ASSURED.equals(getLibrary())) {
additionalProperties.put("java8", "true");
additionalProperties.put("gson", "true");
apiTemplateFiles.put("api.mustache", ".java");
supportingFiles.add(new SupportingFile("ResponseSpecBuilders.mustache", invokerFolder, "ResponseSpecBuilders.java"));
supportingFiles.add(new SupportingFile("JSON.mustache", invokerFolder, "JSON.java"));
supportingFiles.add(new SupportingFile("GsonObjectMapper.mustache", invokerFolder, "GsonObjectMapper.java"));
} else {
LOGGER.error("Unknown library option (-l/--library): " + getLibrary());
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
{{>licenseInfo}}

package {{invokerPackage}};

import {{apiPackage}}.*;
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
{{>licenseInfo}}

package {{invokerPackage}};

import io.restassured.mapper.ObjectMapper;
import io.restassured.mapper.ObjectMapperDeserializationContext;
import io.restassured.mapper.ObjectMapperSerializationContext;

public class GsonObjectMapper implements ObjectMapper {
private GsonObjectMapper() {
}

public static GsonObjectMapper gson() {
return new GsonObjectMapper();
}

@Override
public Object deserialize(ObjectMapperDeserializationContext context) {
return new JSON().deserialize(context.getDataToDeserialize().asString(), context.getType());
}

@Override
public Object serialize(ObjectMapperSerializationContext context) {
return new JSON().serialize(context.getObjectToSerialize());
}
}
Loading

0 comments on commit c698765

Please sign in to comment.