@Test public void testFindPetsByTags() throws Exception { Pet pet = createRandomPet(); pet.setName("monster"); pet.setStatus(Pet.StatusEnum.AVAILABLE); List<Tag> tags = new ArrayList<Tag>(); Tag tag1 = new Tag(); tag1.setName("friendly"); tags.add(tag1); pet.setTags(tags); api.updatePet(pet); List<Pet> pets = api.findPetsByTags(Arrays.asList(new String[] {"friendly"})); assertNotNull(pets); boolean found = false; for (Pet fetched : pets) { if (fetched.getId().equals(pet.getId())) { found = true; break; } } assertTrue(found); }
@Test public void testUpdatePet() throws Exception { Pet pet = createRandomPet(); pet.setName("programmer"); api.updatePet(pet); Pet fetched = api.getPetById(pet.getId()); assertNotNull(fetched); assertEquals(pet.getId(), fetched.getId()); assertNotNull(fetched.getCategory()); assertEquals(fetched.getCategory().getName(), pet.getCategory().getName()); }
@Test public void testFindPetsByStatus() throws Exception { Pet pet = createRandomPet(); pet.setName("programmer"); pet.setStatus(Pet.StatusEnum.AVAILABLE); api.updatePet(pet); List<Pet> pets = api.findPetsByStatus(Arrays.asList(new String[] {"available"})); assertNotNull(pets); boolean found = false; for (Pet fetched : pets) { if (fetched.getId().equals(pet.getId())) { found = true; break; } } assertTrue(found); }