Skip to content

added tests files for springboot generated code #11728

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Feb 25, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
83 changes: 83 additions & 0 deletions samples/custom-tests/spring/v3/springboot/PetApiTest.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
package io.swagger.api;

import io.swagger.model.ModelApiResponse;
import io.swagger.model.Pet;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.test.context.junit4.SpringRunner;

import java.util.Arrays;
import java.util.List;

import static org.junit.Assert.assertEquals;

@RunWith(SpringRunner.class)
@SpringBootTest
public class PetApiTest {

@Autowired
private PetApi api;

@Test
public void addPetTest() throws Exception {
Pet body = new Pet()
.id(789L)
.name("doggie")
.status(Pet.StatusEnum.AVAILABLE);
ResponseEntity<Pet> responseEntity = api.addPet(body);
assertEquals(HttpStatus.NOT_IMPLEMENTED, responseEntity.getStatusCode());
}

@Test
public void deletePetTest() throws Exception {
Long petId = 789L;
String apiKey = "apiKey_example";
ResponseEntity<Void> responseEntity = api.deletePet(petId, apiKey);
assertEquals(HttpStatus.NOT_IMPLEMENTED, responseEntity.getStatusCode());
}

@Test
public void findPetsByStatusTest() throws Exception {
String status = "available";
ResponseEntity<List<Pet>> responseEntity = api.findPetsByStatus(status);
assertEquals(HttpStatus.NOT_IMPLEMENTED, responseEntity.getStatusCode());
}

@Test
public void findPetsByTagsTest() throws Exception {
List<String> tags = Arrays.asList("tags_example");
ResponseEntity<List<Pet>> responseEntity = api.findPetsByTags(tags);
assertEquals(HttpStatus.NOT_IMPLEMENTED, responseEntity.getStatusCode());
}

@Test
public void getPetByIdTest() throws Exception {
Long petId = 789L;
ResponseEntity<Pet> responseEntity = api.getPetById(petId);
assertEquals(HttpStatus.NOT_IMPLEMENTED, responseEntity.getStatusCode());
}

@Test
public void updatePetTest() throws Exception {
Pet body = new Pet()
.id(789L)
.name("doggie")
.status(Pet.StatusEnum.AVAILABLE);
ResponseEntity<Pet> responseEntity = api.updatePet(body);
assertEquals(HttpStatus.NOT_IMPLEMENTED, responseEntity.getStatusCode());
}

@Test
public void uploadFileTest() throws Exception {
Long petId = 789L;
String additionalMetadata = "additionalMetadata_example";
org.springframework.web.multipart.MultipartFile body = null;
ResponseEntity<ModelApiResponse> responseEntity = api.uploadFile(petId, additionalMetadata, body);
assertEquals(HttpStatus.NOT_IMPLEMENTED, responseEntity.getStatusCode());
}

}
50 changes: 50 additions & 0 deletions samples/custom-tests/spring/v3/springboot/StoreApiTest.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
package io.swagger.api;

import io.swagger.model.Order;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.test.context.junit4.SpringRunner;

import java.util.Map;

import static org.junit.Assert.assertEquals;

@RunWith(SpringRunner.class)
@SpringBootTest
public class StoreApiTest {

@Autowired
private StoreApi api;

@Test
public void deleteOrderTest() throws Exception {
Long orderId = 789L;
ResponseEntity<Void> responseEntity = api.deleteOrder(orderId);
assertEquals(HttpStatus.NOT_IMPLEMENTED, responseEntity.getStatusCode());
}

@Test
public void getInventoryTest() throws Exception {
ResponseEntity<Map<String, Integer>> responseEntity = api.getInventory();
assertEquals(HttpStatus.NOT_IMPLEMENTED, responseEntity.getStatusCode());
}

@Test
public void getOrderByIdTest() throws Exception {
Long orderId = 789L;
ResponseEntity<Order> responseEntity = api.getOrderById(orderId);
assertEquals(HttpStatus.NOT_IMPLEMENTED, responseEntity.getStatusCode());
}

@Test
public void placeOrderTest() throws Exception {
Order body = new Order();
ResponseEntity<Order> responseEntity = api.placeOrder(body);
assertEquals(HttpStatus.NOT_IMPLEMENTED, responseEntity.getStatusCode());
}

}
73 changes: 73 additions & 0 deletions samples/custom-tests/spring/v3/springboot/UserApiTest.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
package io.swagger.api;

import io.swagger.model.User;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.test.context.junit4.SpringRunner;

import java.util.Arrays;
import java.util.List;

import static org.junit.Assert.assertEquals;

@RunWith(SpringRunner.class)
@SpringBootTest
public class UserApiTest {

@Autowired
private UserApi api;

@Test
public void createUserTest() throws Exception {
User body = new User();
ResponseEntity<User> responseEntity = api.createUser(body);
assertEquals(HttpStatus.NOT_IMPLEMENTED, responseEntity.getStatusCode());
}

@Test
public void createUsersWithListInputTest() throws Exception {
List<User> body = Arrays.asList(new User());
ResponseEntity<User> responseEntity = api.createUsersWithListInput(body);
assertEquals(HttpStatus.NOT_IMPLEMENTED, responseEntity.getStatusCode());
}

@Test
public void deleteUserTest() throws Exception {
String username = "username_example";
ResponseEntity<Void> responseEntity = api.deleteUser(username);
assertEquals(HttpStatus.NOT_IMPLEMENTED, responseEntity.getStatusCode());
}

@Test
public void getUserByNameTest() throws Exception {
String username = "username_example";
ResponseEntity<User> responseEntity = api.getUserByName(username);
assertEquals(HttpStatus.NOT_IMPLEMENTED, responseEntity.getStatusCode());
}

@Test
public void loginUserTest() throws Exception {
String username = "username_example";
String password = "password_example";
ResponseEntity<String> responseEntity = api.loginUser(username, password);
assertEquals(HttpStatus.NOT_IMPLEMENTED, responseEntity.getStatusCode());
}

@Test
public void logoutUserTest() throws Exception {
ResponseEntity<Void> responseEntity = api.logoutUser();
assertEquals(HttpStatus.NOT_IMPLEMENTED, responseEntity.getStatusCode());
}

@Test
public void updateUserTest() throws Exception {
String username = "username_example";
User body = new User();
ResponseEntity<Void> responseEntity = api.updateUser(username, body);
assertEquals(HttpStatus.NOT_IMPLEMENTED, responseEntity.getStatusCode());
}
}