mirror of
https://github.com/spring-projects/spring-petclinic.git
synced 2025-07-23 00:05:50 +00:00
Added tests for Vet class
This commit is contained in:
parent
a9f9a826d7
commit
7a44f46c84
1 changed files with 38 additions and 0 deletions
|
@ -17,9 +17,14 @@ package org.springframework.samples.petclinic.vet;
|
||||||
|
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
|
|
||||||
|
import org.springframework.beans.support.MutableSortDefinition;
|
||||||
|
import org.springframework.beans.support.PropertyComparator;
|
||||||
import org.springframework.util.SerializationUtils;
|
import org.springframework.util.SerializationUtils;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
import static org.assertj.core.api.Assertions.assertThat;
|
import static org.assertj.core.api.Assertions.assertThat;
|
||||||
|
import static org.junit.Assert.assertTrue;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author Dave Syer
|
* @author Dave Syer
|
||||||
|
@ -40,4 +45,37 @@ public class VetTests {
|
||||||
assertThat(other.getId()).isEqualTo(vet.getId());
|
assertThat(other.getId()).isEqualTo(vet.getId());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testGetSpecialties(){
|
||||||
|
Vet vet = new Vet();
|
||||||
|
vet.setFirstName("Zaphod");
|
||||||
|
vet.setLastName("Beeblebrox");
|
||||||
|
vet.setId(123);
|
||||||
|
Specialty radiology = new Specialty();
|
||||||
|
Specialty urinalysis = new Specialty();
|
||||||
|
Specialty kinesiology = new Specialty();
|
||||||
|
vet.addSpecialty(radiology);
|
||||||
|
vet.addSpecialty(urinalysis);
|
||||||
|
//vet.addSpecialty(kinesiology);
|
||||||
|
|
||||||
|
List<Specialty> testList = vet.getSpecialties();
|
||||||
|
assertThat(testList).isEqualTo(vet.getSpecialties());
|
||||||
|
testList.getClass().getSimpleName().equals("UnmodifiableCollection");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testAddGetNrSpecialty(){
|
||||||
|
Vet vet = new Vet();
|
||||||
|
vet.setFirstName("Zaphod");
|
||||||
|
vet.setLastName("Beeblebrox");
|
||||||
|
vet.setId(123);
|
||||||
|
|
||||||
|
int preAddedNumber = vet.getNrOfSpecialties();
|
||||||
|
Specialty radiology = new Specialty();
|
||||||
|
//radiology.setName("radiology");
|
||||||
|
vet.addSpecialty(radiology);
|
||||||
|
assertThat(vet.getNrOfSpecialties()).isEqualTo(++preAddedNumber);
|
||||||
|
assertThat((vet.getSpecialtiesInternal()).contains(radiology));
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue