Skip to content

Commit 1e20e47

Browse files
author
cristiii
committed
added couple of tests
1 parent ac2bfbc commit 1e20e47

File tree

4 files changed

+117
-0
lines changed

4 files changed

+117
-0
lines changed
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
package guru.springframework.sfgpetclinic.controllers;
2+
3+
import org.junit.jupiter.api.BeforeEach;
4+
import org.junit.jupiter.api.Test;
5+
6+
import static org.junit.jupiter.api.Assertions.*;
7+
8+
class IndexControllerTest {
9+
10+
private IndexController indexController;
11+
12+
@BeforeEach
13+
void setUp() {
14+
indexController = new IndexController();
15+
}
16+
17+
@Test
18+
void index() {
19+
assertEquals("index", indexController.index());
20+
}
21+
22+
@Test
23+
void oupsHandler() {
24+
assertEquals("notimplemented", indexController.oupsHandler(), () -> "this is some expensive message to build for test");
25+
}
26+
}
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
package guru.springframework.sfgpetclinic.model;
2+
3+
import org.junit.jupiter.api.Test;
4+
5+
import static org.junit.jupiter.api.Assertions.*;
6+
7+
class OwnerTest {
8+
9+
@Test
10+
void dependentAssertions() {
11+
Owner owner = new Owner(1l, "Joe", "Buck");
12+
owner.setCity("City");
13+
owner.setTelephone("123123");
14+
15+
assertAll("Properties test",
16+
() -> assertAll("Person properties",
17+
() -> assertEquals("Joe", owner.getFirstName()),
18+
() -> assertEquals("Buck", owner.getLastName())),
19+
() -> assertAll("Owner Properties",
20+
() -> assertEquals("City", owner.getCity()),
21+
() -> assertEquals("123123", owner.getTelephone())));
22+
}
23+
24+
}
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
package guru.springframework.sfgpetclinic.model;
2+
3+
import org.junit.jupiter.api.Test;
4+
5+
import static org.junit.jupiter.api.Assertions.*;
6+
7+
class PersonTest {
8+
9+
@Test
10+
void groupedAssertions() {
11+
Person person = new Person(1l, "Joe", "Buck");
12+
13+
assertAll("Test props set",
14+
() -> assertEquals("Joe", person.getFirstName()),
15+
() -> assertEquals("Buck", person.getLastName()));
16+
}
17+
18+
}
Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
package guru.springframework.sfgpetclinic.services.springdatajpa;
2+
3+
import guru.springframework.sfgpetclinic.model.Owner;
4+
import org.junit.jupiter.api.BeforeEach;
5+
import org.junit.jupiter.api.Disabled;
6+
import org.junit.jupiter.api.Test;
7+
8+
import static org.junit.jupiter.api.Assertions.*;
9+
10+
@Disabled(value = "Disabled until we see Mocking")
11+
class OwnerSDJpaServiceTest {
12+
13+
private OwnerSDJpaService ownerSDJpaService;
14+
15+
@BeforeEach
16+
void setUp() {
17+
ownerSDJpaService = new OwnerSDJpaService(null, null, null);
18+
}
19+
20+
@Test
21+
@Disabled
22+
void findByLastName() {
23+
Owner owner = ownerSDJpaService.findByLastName("Buck");
24+
}
25+
26+
@Test
27+
void findAllByLastNameLike() {
28+
}
29+
30+
@Test
31+
void findAll() {
32+
}
33+
34+
@Test
35+
void findById() {
36+
}
37+
38+
@Test
39+
void save() {
40+
}
41+
42+
@Test
43+
void delete() {
44+
}
45+
46+
@Test
47+
void deleteById() {
48+
}
49+
}

0 commit comments

Comments
 (0)