Skip to content

Commit

Permalink
fix java unit test issues
Browse files Browse the repository at this point in the history
  • Loading branch information
sebastien-rosset committed Mar 24, 2020
1 parent 665e883 commit e850841
Showing 1 changed file with 5 additions and 15 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.concurrent.ThreadLocalRandom;
import java.util.Random;
import java.io.BufferedWriter;
import java.io.File;
import java.io.FileWriter;
Expand Down Expand Up @@ -92,7 +92,6 @@ public void testCreateAndGetPet() throws Exception {

Pet fetched = api.getPetById(pet.getId());
assertPetMatches(pet, fetched);
api.deletePet(pet.getId(), null);
}

@Test
Expand All @@ -106,7 +105,6 @@ public void testCreateAndGetPetWithHttpInfo() throws Exception {
Pet fetched = resp.getData();

assertPetMatches(pet, fetched);
api.deletePet(pet.getId(), null);
}

@Test
Expand Down Expand Up @@ -153,7 +151,6 @@ public void onDownloadProgress(long bytesRead, long contentLength, boolean done)
}
} while (result.isEmpty());
assertPetMatches(pet, fetched);
api.deletePet(pet.getId(), null);
}

@Test
Expand Down Expand Up @@ -207,7 +204,6 @@ public void onDownloadProgress(long bytesRead, long contentLength, boolean done)
assertEquals(404, exception.getCode());
assertEquals("Not Found", exception.getMessage());
assertEquals("application/json", exception.getResponseHeaders().get("Content-Type").get(0));
api.deletePet(pet.getId(), null);
}

@Test
Expand Down Expand Up @@ -266,31 +262,27 @@ public void testCreateAndGetMultiplePetsAsync() throws Exception {
final ApiException exception = getCallback3.getException();
assertNotNull(exception);
assertEquals(404, exception.getCode());
api.deletePet(pet1.getId(), null);
api.deletePet(pet2.getId(), null);
}


@Test
public void testUpdatePet() throws Exception {
Pet pet = createPet();
api.addPet(pet);
pet.setName("programmer");

api.updatePet(pet);

Pet fetched = api.getPetById(pet.getId());
assertPetMatches(pet, fetched);
api.deletePet(pet.getId(), null);
}

@Test
public void testFindPetsByStatus() throws Exception {
assertEquals(basePath, api.getApiClient().getBasePath());
Pet pet = createPet();
api.addPet(pet);
pet.setName("programmer");
pet.setStatus(Pet.StatusEnum.PENDING);

assertEquals(basePath, api.getApiClient().getBasePath());
api.updatePet(pet);

List<Pet> pets = api.findPetsByStatus(Arrays.asList("pending"));
Expand Down Expand Up @@ -351,7 +343,6 @@ public void testUpdatePetWithForm() throws Exception {
Pet updated = api.getPetById(fetched.getId());

assertEquals(updated.getName(), "furt");
api.deletePet(pet.getId(), null);
}

@Test
Expand All @@ -360,7 +351,7 @@ public void testDeletePet() throws Exception {
api.addPet(pet);

Pet fetched = api.getPetById(pet.getId());
api.deletePet(pet.getId(), null);
api.deletePet(fetched.getId(), null);

try {
fetched = api.getPetById(fetched.getId());
Expand All @@ -382,7 +373,6 @@ public void testUploadFile() throws Exception {
writer.close();

api.uploadFile(pet.getId(), "a test file", new File(file.getAbsolutePath()));
api.deletePet(pet.getId(), null);
}

@Test
Expand Down Expand Up @@ -415,7 +405,7 @@ public void testEqualsAndHashCode() {

private Pet createPet() {
Pet pet = new Pet();
pet.setId(ThreadLocalRandom.current().nextLong(Long.MAX_VALUE));
pet.setId(new Random().nextLong());
pet.setName("gorilla");

Category category = new Category();
Expand Down

0 comments on commit e850841

Please sign in to comment.