diff --git a/bin/java-petstore-jersey2-java7.json b/bin/java-petstore-jersey2-java7.json deleted file mode 100644 index a5e2254fdb3..00000000000 --- a/bin/java-petstore-jersey2-java7.json +++ /dev/null @@ -1,5 +0,0 @@ -{ - "library": "jersey2", - "java8": false, - "artifactId": "petstore-jersey2-java7" -} diff --git a/samples/client/petstore/java/jersey2-java8/src/test/java/org/openapitools/client/api/PetApiTest.java b/samples/client/petstore/java/jersey2-java8/src/test/java/org/openapitools/client/api/PetApiTest.java index 1ab8611db47..11dcafbcc11 100644 --- a/samples/client/petstore/java/jersey2-java8/src/test/java/org/openapitools/client/api/PetApiTest.java +++ b/samples/client/petstore/java/jersey2-java8/src/test/java/org/openapitools/client/api/PetApiTest.java @@ -3,7 +3,7 @@ * This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ * * The version of the OpenAPI document: 1.0.0 - * + * * * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). * https://openapi-generator.tech @@ -13,97 +13,142 @@ package org.openapitools.client.api; -import org.openapitools.client.*; -import org.openapitools.client.auth.*; -import java.io.File; -import org.openapitools.client.model.ModelApiResponse; -import org.openapitools.client.model.Pet; +import org.junit.Assert; import org.junit.Test; -import org.junit.Ignore; +import org.openapitools.client.ApiClient; +import org.openapitools.client.ApiException; +import org.openapitools.client.Configuration; +import org.openapitools.client.auth.ApiKeyAuth; +import org.openapitools.client.model.Category; +import org.openapitools.client.model.Pet; +import org.openapitools.client.model.Tag; -import java.util.ArrayList; -import java.util.HashMap; +import java.io.File; +import java.util.Arrays; +import java.util.HashSet; import java.util.List; -import java.util.Map; import java.util.Set; /** * API tests for PetApi */ -@Ignore public class PetApiTest { private final PetApi api = new PetApi(); + private final long petId = 5638l; /** * Add a new pet to the store * - * - * - * @throws ApiException - * if the Api call fails + * @throws ApiException if the Api call fails */ @Test public void addPetTest() throws ApiException { - Pet body = null; + // add pet + Pet body = new Pet(); + body.setId(petId); + body.setName("jersey2 java8 pet"); + Category category = new Category(); + category.setId(petId); + category.setName("jersey2 java8 category"); + body.setCategory(category); + body.setStatus(Pet.StatusEnum.AVAILABLE); + body.setPhotoUrls(new HashSet<>(Arrays.asList("A", "B", "C"))); + Tag tag = new Tag(); + tag.setId(petId); + tag.setName("jersey2 java8 tag"); + body.setTags(Arrays.asList(tag)); + api.addPet(body); - // TODO: test validations + + //get pet by ID + Pet result = api.getPetById(petId); + Assert.assertEquals(result.getId(), body.getId()); + Assert.assertEquals(result.getCategory(), category); + Assert.assertEquals(result.getName(), body.getName()); + Assert.assertEquals(result.getPhotoUrls(), body.getPhotoUrls()); + Assert.assertEquals(result.getStatus(), body.getStatus()); + Assert.assertEquals(result.getTags(), body.getTags()); + + // update pet + api.updatePetWithForm(petId, "jersey2 java8 pet 2", "sold"); + + //get pet by ID + Pet result2 = api.getPetById(petId); + Assert.assertEquals(result2.getId(), body.getId()); + Assert.assertEquals(result2.getCategory(), category); + Assert.assertEquals(result2.getName(), "jersey2 java8 pet 2"); + Assert.assertEquals(result2.getPhotoUrls(), body.getPhotoUrls()); + Assert.assertEquals(result2.getStatus(), Pet.StatusEnum.SOLD); + Assert.assertEquals(result2.getTags(), body.getTags()); + + // delete pet + api.deletePet(petId, "empty api key"); + + try { + Pet result3 = api.getPetById(petId); + Assert.assertEquals(false, true); + } catch (ApiException e) { +// System.err.println("Exception when calling PetApi#getPetById"); +// System.err.println("Status code: " + e.getCode()); +// System.err.println("Reason: " + e.getResponseBody()); +// System.err.println("Response headers: " + e.getResponseHeaders()); + + Assert.assertEquals(e.getCode(), 404); + Assert.assertEquals(e.getResponseBody(), "{\"code\":1,\"type\":\"error\",\"message\":\"Pet not found\"}"); + + } + } /** * Deletes a pet * - * - * - * @throws ApiException - * if the Api call fails + * @throws ApiException if the Api call fails */ @Test public void deletePetTest() throws ApiException { Long petId = null; String apiKey = null; - api.deletePet(petId, apiKey); // TODO: test validations + //api.deletePet(petId, apiKey); } /** * Finds Pets by status - * + *
* Multiple status values can be provided with comma separated strings
*
- * @throws ApiException
- * if the Api call fails
+ * @throws ApiException if the Api call fails
*/
@Test
public void findPetsByStatusTest() throws ApiException {
List
* Multiple tags can be provided with comma separated strings. Use tag1, tag2, tag3 for testing.
*
- * @throws ApiException
- * if the Api call fails
+ * @throws ApiException if the Api call fails
*/
@Test
public void findPetsByTagsTest() throws ApiException {
Set
* Returns a single pet
*
- * @throws ApiException
- * if the Api call fails
+ * @throws ApiException if the Api call fails
*/
@Test
public void getPetByIdTest() throws ApiException {
@@ -126,7 +171,6 @@ public class PetApiTest {
System.err.println("Status code: " + e.getCode());
System.err.println("Reason: " + e.getResponseBody());
System.err.println("Response headers: " + e.getResponseHeaders());
- e.printStackTrace();
}
}
@@ -134,66 +178,54 @@ public class PetApiTest {
/**
* Update an existing pet
*
- *
- *
- * @throws ApiException
- * if the Api call fails
+ * @throws ApiException if the Api call fails
*/
@Test
public void updatePetTest() throws ApiException {
Pet body = null;
- api.updatePet(body);
+ //api.updatePet(body);
// TODO: test validations
}
/**
* Updates a pet in the store with form data
*
- *
- *
- * @throws ApiException
- * if the Api call fails
+ * @throws ApiException if the Api call fails
*/
@Test
public void updatePetWithFormTest() throws ApiException {
Long petId = null;
String name = null;
String status = null;
- api.updatePetWithForm(petId, name, status);
+ //api.updatePetWithForm(petId, name, status);
// TODO: test validations
}
/**
* uploads an image
*
- *
- *
- * @throws ApiException
- * if the Api call fails
+ * @throws ApiException if the Api call fails
*/
@Test
public void uploadFileTest() throws ApiException {
Long petId = null;
String additionalMetadata = null;
File file = null;
- ModelApiResponse response = api.uploadFile(petId, additionalMetadata, file);
+ //ModelApiResponse response = api.uploadFile(petId, additionalMetadata, file);
// TODO: test validations
}
/**
* uploads an image (required)
*
- *
- *
- * @throws ApiException
- * if the Api call fails
+ * @throws ApiException if the Api call fails
*/
@Test
public void uploadFileWithRequiredFileTest() throws ApiException {
Long petId = null;
File requiredFile = null;
String additionalMetadata = null;
- ModelApiResponse response = api.uploadFileWithRequiredFile(petId, requiredFile, additionalMetadata);
+ //ModelApiResponse response = api.uploadFileWithRequiredFile(petId, requiredFile, additionalMetadata);
// TODO: test validations
}