File tree Expand file tree Collapse file tree 2 files changed +55
-0
lines changed
src/test/java/com/gourav/restApi Expand file tree Collapse file tree 2 files changed +55
-0
lines changed Original file line number Diff line number Diff line change 1+ package com .gourav .restApi .controllers ;
2+
3+ import org .junit .runner .RunWith ;
4+ import org .springframework .beans .factory .annotation .Autowired ;
5+ import org .springframework .boot .test .autoconfigure .web .servlet .WebMvcTest ;
6+ import org .springframework .boot .test .mock .mockito .MockBean ;
7+ import org .springframework .test .context .junit4 .SpringRunner ;
8+ import org .springframework .test .web .servlet .MockMvc ;
9+
10+ @ RunWith (SpringRunner .class )
11+ @ WebMvcTest (value = PetsController .class )
12+ public class PetsControllerTest {
13+
14+ @ Autowired
15+ private MockMvc mvc ;
16+
17+ @ MockBean
18+ private PetsController petsController ;
19+
20+ }
Original file line number Diff line number Diff line change 1+ package com .gourav .restApi .models ;
2+
3+ import static org .junit .Assert .*;
4+ import org .bson .types .ObjectId ;
5+ import org .junit .Test ;
6+
7+ public class PetsTest {
8+
9+ ObjectId _id = ObjectId .get ();
10+ Pets pets = new Pets ();
11+
12+ @ Test
13+ public void testSet_id (){
14+ pets .set_id (_id );
15+ assertTrue (pets .get_id ().equals (_id .toHexString ()));
16+ }
17+
18+ @ Test
19+ public void testSetName (){
20+ pets .setName ("Liam" );
21+ assertTrue (pets .getName ().equals ("Liam" ));
22+ }
23+
24+ @ Test
25+ public void testSetSpecies (){
26+ pets .setSpecies ("cat" );
27+ assertTrue (pets .getSpecies ().equals ("cat" ));
28+ }
29+
30+ @ Test
31+ public void testSetBreed (){
32+ pets .setBreed ("tabby" );
33+ assertTrue (pets .getBreed ().equals ("tabby" ));
34+ }
35+ }
You can’t perform that action at this time.
0 commit comments