use of org.springframework.samples.petclinic.owner.PetType in project spring-petclinic by spring-projects.
the class PetTypeFormatterTests method makePetTypes.
/**
* Helper method to produce some sample pet types just for test purpose
*
* @return {@link Collection} of {@link PetType}
*/
private List<PetType> makePetTypes() {
List<PetType> petTypes = new ArrayList<>();
petTypes.add(new PetType() {
{
setName("Dog");
}
});
petTypes.add(new PetType() {
{
setName("Bird");
}
});
return petTypes;
}
use of org.springframework.samples.petclinic.owner.PetType in project spring-petclinic by spring-projects.
the class PetTypeFormatterTests method shouldParse.
@Test
public void shouldParse() throws ParseException {
Mockito.when(this.pets.findPetTypes()).thenReturn(makePetTypes());
PetType petType = petTypeFormatter.parse("Bird", Locale.ENGLISH);
assertEquals("Bird", petType.getName());
}
use of org.springframework.samples.petclinic.owner.PetType in project spring-petclinic by spring-projects.
the class PetControllerTests method setup.
@Before
public void setup() {
PetType cat = new PetType();
cat.setId(3);
cat.setName("hamster");
given(this.pets.findPetTypes()).willReturn(Lists.newArrayList(cat));
given(this.owners.findById(TEST_OWNER_ID)).willReturn(new Owner());
given(this.pets.findById(TEST_PET_ID)).willReturn(new Pet());
}
use of org.springframework.samples.petclinic.owner.PetType in project spring-petclinic by spring-projects.
the class PetTypeFormatterTests method testPrint.
@Test
public void testPrint() {
PetType petType = new PetType();
petType.setName("Hamster");
String petTypeName = this.petTypeFormatter.print(petType, Locale.ENGLISH);
assertEquals("Hamster", petTypeName);
}
use of org.springframework.samples.petclinic.owner.PetType in project spring-petclinic by spring-projects.
the class ClinicServiceTests method shouldFindAllPetTypes.
@Test
public void shouldFindAllPetTypes() {
Collection<PetType> petTypes = this.pets.findPetTypes();
PetType petType1 = EntityUtils.getById(petTypes, PetType.class, 1);
assertThat(petType1.getName()).isEqualTo("cat");
PetType petType4 = EntityUtils.getById(petTypes, PetType.class, 4);
assertThat(petType4.getName()).isEqualTo("snake");
}
Aggregations