mirror of
https://github.com/spring-projects/spring-petclinic.git
synced 2025-07-22 15:55:49 +00:00
Added comments for clarity
This commit is contained in:
parent
23b1d2bb58
commit
8f516f8e3d
2 changed files with 20 additions and 14 deletions
|
@ -3,14 +3,13 @@ package org.springframework.samples.petclinic.visit;
|
|||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
import static org.junit.Assert.*;
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.boot.test.autoconfigure.orm.jpa.DataJpaTest;
|
||||
import org.springframework.boot.test.mock.mockito.MockBean;
|
||||
import org.springframework.context.annotation.ComponentScan;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.test.context.junit4.SpringRunner;
|
||||
|
@ -38,14 +37,14 @@ public class VisitRepositoryTest {
|
|||
@Test
|
||||
public void shouldFindSavedVisitInVisitRepository() {
|
||||
visitRepository.save(visit);
|
||||
//Get the list of visits associated to VISIT_ID
|
||||
visitList = visitRepository.findByPetId(VISIT_ID);
|
||||
|
||||
assertEquals(visitList.size(), 1);
|
||||
Visit savedVisit = visitList.get(0);
|
||||
assertEquals((int) savedVisit.getPetId(), VISIT_ID);
|
||||
assertEquals(savedVisit.getDescription(), DESCRIPTION);
|
||||
assertEquals(savedVisit.getDate(), TODAY);
|
||||
}
|
||||
|
||||
|
||||
assertThat(visitList.size()).isEqualTo(1);
|
||||
Visit savedVisit = visitList.get(0);
|
||||
|
||||
assertThat((int) savedVisit.getPetId()).isEqualTo(VISIT_ID);
|
||||
assertThat(savedVisit.getDescription()).isEqualTo(DESCRIPTION);
|
||||
assertThat(savedVisit.getDate()).isEqualTo(TODAY);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,31 +1,38 @@
|
|||
package org.springframework.samples.petclinic.visit;
|
||||
|
||||
import java.util.Date;
|
||||
import static org.junit.Assert.*;
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
|
||||
public class VisitTest {
|
||||
private Visit visit;
|
||||
|
||||
@Before
|
||||
public void setUp() {
|
||||
visit = new Visit();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGetDate() {
|
||||
Date today = new Date();
|
||||
visit.setDate(today);
|
||||
assertEquals(visit.getDate(), today);
|
||||
assertThat(visit.getDate()).isEqualTo(today);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGetDescription() {
|
||||
String description = "The greatest visit of all time";
|
||||
visit.setDescription(description);
|
||||
assertEquals(visit.getDescription(), description);
|
||||
assertThat(visit.getDescription()).isEqualTo(description);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGetPetId() {
|
||||
int petId = 1;
|
||||
visit.setPetId(petId);
|
||||
assertEquals((int) visit.getPetId(), petId);
|
||||
assertThat((int) visit.getPetId()).isEqualTo(petId);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue