forked from loafle/openapi-generator-original
Java: Add basic junit test templates for api clients
This commit is contained in:
@@ -0,0 +1,51 @@
|
||||
package io.swagger.client.api;
|
||||
|
||||
import io.swagger.client.ApiClient;
|
||||
import java.math.BigDecimal;
|
||||
import java.util.Date;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* API tests for FakeApi
|
||||
*/
|
||||
public class FakeApiTest {
|
||||
|
||||
private FakeApi api;
|
||||
|
||||
@Before
|
||||
public void setup() {
|
||||
api = new ApiClient().buildClient(FakeApi.class);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Fake endpoint for testing various parameters 假端點 偽のエンドポイント 가짜 엔드 포인트
|
||||
*
|
||||
* Fake endpoint for testing various parameters 假端點 偽のエンドポイント 가짜 엔드 포인트
|
||||
*/
|
||||
@Test
|
||||
public void testEndpointParametersTest() {
|
||||
BigDecimal number = null;
|
||||
Double _double = null;
|
||||
String string = null;
|
||||
byte[] _byte = null;
|
||||
Integer integer = null;
|
||||
Integer int32 = null;
|
||||
Long int64 = null;
|
||||
Float _float = null;
|
||||
byte[] binary = null;
|
||||
Date date = null;
|
||||
Date dateTime = null;
|
||||
String password = null;
|
||||
// api.testEndpointParameters(number, _double, string, _byte, integer, int32, int64, _float, binary, date, dateTime, password);
|
||||
|
||||
// TODO: test validations
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,137 @@
|
||||
package io.swagger.client.api;
|
||||
|
||||
import io.swagger.client.ApiClient;
|
||||
import io.swagger.client.model.Pet;
|
||||
import io.swagger.client.model.ModelApiResponse;
|
||||
import java.io.File;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* API tests for PetApi
|
||||
*/
|
||||
public class PetApiTest {
|
||||
|
||||
private PetApi api;
|
||||
|
||||
@Before
|
||||
public void setup() {
|
||||
api = new ApiClient().buildClient(PetApi.class);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Add a new pet to the store
|
||||
*
|
||||
*
|
||||
*/
|
||||
@Test
|
||||
public void addPetTest() {
|
||||
Pet body = null;
|
||||
// api.addPet(body);
|
||||
|
||||
// TODO: test validations
|
||||
}
|
||||
|
||||
/**
|
||||
* Deletes a pet
|
||||
*
|
||||
*
|
||||
*/
|
||||
@Test
|
||||
public void deletePetTest() {
|
||||
Long petId = null;
|
||||
String apiKey = null;
|
||||
// api.deletePet(petId, apiKey);
|
||||
|
||||
// TODO: test validations
|
||||
}
|
||||
|
||||
/**
|
||||
* Finds Pets by status
|
||||
*
|
||||
* Multiple status values can be provided with comma separated strings
|
||||
*/
|
||||
@Test
|
||||
public void findPetsByStatusTest() {
|
||||
List<String> status = null;
|
||||
// List<Pet> response = api.findPetsByStatus(status);
|
||||
|
||||
// TODO: test validations
|
||||
}
|
||||
|
||||
/**
|
||||
* Finds Pets by tags
|
||||
*
|
||||
* Multiple tags can be provided with comma separated strings. Use tag1, tag2, tag3 for testing.
|
||||
*/
|
||||
@Test
|
||||
public void findPetsByTagsTest() {
|
||||
List<String> tags = null;
|
||||
// List<Pet> response = api.findPetsByTags(tags);
|
||||
|
||||
// TODO: test validations
|
||||
}
|
||||
|
||||
/**
|
||||
* Find pet by ID
|
||||
*
|
||||
* Returns a single pet
|
||||
*/
|
||||
@Test
|
||||
public void getPetByIdTest() {
|
||||
Long petId = null;
|
||||
// Pet response = api.getPetById(petId);
|
||||
|
||||
// TODO: test validations
|
||||
}
|
||||
|
||||
/**
|
||||
* Update an existing pet
|
||||
*
|
||||
*
|
||||
*/
|
||||
@Test
|
||||
public void updatePetTest() {
|
||||
Pet body = null;
|
||||
// api.updatePet(body);
|
||||
|
||||
// TODO: test validations
|
||||
}
|
||||
|
||||
/**
|
||||
* Updates a pet in the store with form data
|
||||
*
|
||||
*
|
||||
*/
|
||||
@Test
|
||||
public void updatePetWithFormTest() {
|
||||
Long petId = null;
|
||||
String name = null;
|
||||
String status = null;
|
||||
// api.updatePetWithForm(petId, name, status);
|
||||
|
||||
// TODO: test validations
|
||||
}
|
||||
|
||||
/**
|
||||
* uploads an image
|
||||
*
|
||||
*
|
||||
*/
|
||||
@Test
|
||||
public void uploadFileTest() {
|
||||
Long petId = null;
|
||||
String additionalMetadata = null;
|
||||
File file = null;
|
||||
// ModelApiResponse response = api.uploadFile(petId, additionalMetadata, file);
|
||||
|
||||
// TODO: test validations
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,77 @@
|
||||
package io.swagger.client.api;
|
||||
|
||||
import io.swagger.client.ApiClient;
|
||||
import io.swagger.client.model.Order;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* API tests for StoreApi
|
||||
*/
|
||||
public class StoreApiTest {
|
||||
|
||||
private StoreApi api;
|
||||
|
||||
@Before
|
||||
public void setup() {
|
||||
api = new ApiClient().buildClient(StoreApi.class);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Delete purchase order by ID
|
||||
*
|
||||
* For valid response try integer IDs with value < 1000. Anything above 1000 or nonintegers will generate API errors
|
||||
*/
|
||||
@Test
|
||||
public void deleteOrderTest() {
|
||||
String orderId = null;
|
||||
// api.deleteOrder(orderId);
|
||||
|
||||
// TODO: test validations
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns pet inventories by status
|
||||
*
|
||||
* Returns a map of status codes to quantities
|
||||
*/
|
||||
@Test
|
||||
public void getInventoryTest() {
|
||||
// Map<String, Integer> response = api.getInventory();
|
||||
|
||||
// TODO: test validations
|
||||
}
|
||||
|
||||
/**
|
||||
* Find purchase order by ID
|
||||
*
|
||||
* For valid response try integer IDs with value <= 5 or > 10. Other values will generated exceptions
|
||||
*/
|
||||
@Test
|
||||
public void getOrderByIdTest() {
|
||||
Long orderId = null;
|
||||
// Order response = api.getOrderById(orderId);
|
||||
|
||||
// TODO: test validations
|
||||
}
|
||||
|
||||
/**
|
||||
* Place an order for a pet
|
||||
*
|
||||
*
|
||||
*/
|
||||
@Test
|
||||
public void placeOrderTest() {
|
||||
Order body = null;
|
||||
// Order response = api.placeOrder(body);
|
||||
|
||||
// TODO: test validations
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,131 @@
|
||||
package io.swagger.client.api;
|
||||
|
||||
import io.swagger.client.ApiClient;
|
||||
import io.swagger.client.model.User;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* API tests for UserApi
|
||||
*/
|
||||
public class UserApiTest {
|
||||
|
||||
private UserApi api;
|
||||
|
||||
@Before
|
||||
public void setup() {
|
||||
api = new ApiClient().buildClient(UserApi.class);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Create user
|
||||
*
|
||||
* This can only be done by the logged in user.
|
||||
*/
|
||||
@Test
|
||||
public void createUserTest() {
|
||||
User body = null;
|
||||
// api.createUser(body);
|
||||
|
||||
// TODO: test validations
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates list of users with given input array
|
||||
*
|
||||
*
|
||||
*/
|
||||
@Test
|
||||
public void createUsersWithArrayInputTest() {
|
||||
List<User> body = null;
|
||||
// api.createUsersWithArrayInput(body);
|
||||
|
||||
// TODO: test validations
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates list of users with given input array
|
||||
*
|
||||
*
|
||||
*/
|
||||
@Test
|
||||
public void createUsersWithListInputTest() {
|
||||
List<User> body = null;
|
||||
// api.createUsersWithListInput(body);
|
||||
|
||||
// TODO: test validations
|
||||
}
|
||||
|
||||
/**
|
||||
* Delete user
|
||||
*
|
||||
* This can only be done by the logged in user.
|
||||
*/
|
||||
@Test
|
||||
public void deleteUserTest() {
|
||||
String username = null;
|
||||
// api.deleteUser(username);
|
||||
|
||||
// TODO: test validations
|
||||
}
|
||||
|
||||
/**
|
||||
* Get user by user name
|
||||
*
|
||||
*
|
||||
*/
|
||||
@Test
|
||||
public void getUserByNameTest() {
|
||||
String username = null;
|
||||
// User response = api.getUserByName(username);
|
||||
|
||||
// TODO: test validations
|
||||
}
|
||||
|
||||
/**
|
||||
* Logs user into the system
|
||||
*
|
||||
*
|
||||
*/
|
||||
@Test
|
||||
public void loginUserTest() {
|
||||
String username = null;
|
||||
String password = null;
|
||||
// String response = api.loginUser(username, password);
|
||||
|
||||
// TODO: test validations
|
||||
}
|
||||
|
||||
/**
|
||||
* Logs out current logged in user session
|
||||
*
|
||||
*
|
||||
*/
|
||||
@Test
|
||||
public void logoutUserTest() {
|
||||
// api.logoutUser();
|
||||
|
||||
// TODO: test validations
|
||||
}
|
||||
|
||||
/**
|
||||
* Updated user
|
||||
*
|
||||
* This can only be done by the logged in user.
|
||||
*/
|
||||
@Test
|
||||
public void updateUserTest() {
|
||||
String username = null;
|
||||
User body = null;
|
||||
// api.updateUser(username, body);
|
||||
|
||||
// TODO: test validations
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user