Skip to content

Commit bf7bf29

Browse files
latest changes
1 parent 8ed61c5 commit bf7bf29

File tree

4 files changed

+30
-33
lines changed

4 files changed

+30
-33
lines changed

build.gradle

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,4 +33,8 @@ jacocoTestReport {
3333
}
3434
}
3535

36-
check.dependsOn jacocoTestReport
36+
check.dependsOn jacocoTestReport
37+
38+
sonarqube {
39+
androidVariant 'fullDebug'
40+
}

docs/CONTRIBUTING.md

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,7 @@ Please note we have a code of conduct, please follow it in all your interactions
1111
build.
1212
2. Update the README.md with details of changes to the interface, this includes new environment
1313
variables, exposed ports, useful file locations and container parameters.
14-
3. Increase the version numbers in any examples files and the README.md to the new version that this
15-
Pull Request would represent. The versioning scheme we use is [SemVer](http://semver.org/).
16-
4. You may merge the Pull Request in once you have the sign-off of two other developers, or if you
14+
3. You may merge the Pull Request in once you have the sign-off of two other developers, or if you
1715
do not have permission to do that, you may request the second reviewer to merge it for you.
1816

1917
## Code of Conduct

src/test/java/com/gourav/restapi/RestApiApplicationTest.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,12 @@
22

33
import org.junit.Test;
44
import org.junit.runner.RunWith;
5+
import org.springframework.boot.ApplicationArguments;
56
import org.springframework.boot.test.context.SpringBootTest;
67
import org.springframework.test.context.junit4.SpringRunner;
78

89
@RunWith(SpringRunner.class)
9-
@SpringBootTest
10+
@SpringBootTest(classes = ApplicationArguments.class)
1011
public class RestApiApplicationTest {
1112
@Test
1213
public void contextLoads() {

src/test/java/com/gourav/restapi/controllers/PetsControllerTest.java

Lines changed: 22 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
import static org.mockito.BDDMockito.given;
1414
import java.util.List;
1515
import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.get;
16+
import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.post;
1617
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.jsonPath;
1718
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status;
1819
import com.gourav.restapi.models.Pets;
@@ -23,7 +24,7 @@ public class PetsControllerTest {
2324

2425
@Autowired
2526
private MockMvc mvc;
26-
27+
2728
@MockBean
2829
private PetsController petsController;
2930

@@ -33,43 +34,36 @@ public void getAllPets() throws Exception {
3334
Pets pets = new Pets(id, "Liam", "cat", "tabby");
3435

3536
List<Pets> allPets = singletonList(pets);
36-
37+
3738
given(petsController.getAllPets()).willReturn(allPets);
3839

3940
mvc.perform(get("/pets/").contentType("application/json;charset=UTF-8")).andExpect(status().isOk())
40-
.andExpect(jsonPath("$[0].name").value("Liam"))
41-
.andExpect(jsonPath("$[0].breed").value("tabby"))
42-
.andExpect(jsonPath("$[0].species").value("cat"))
43-
.andReturn();
41+
.andExpect(jsonPath("$[0].name").value("Liam")).andExpect(jsonPath("$[0].breed").value("tabby"))
42+
.andExpect(jsonPath("$[0].species").value("cat")).andReturn();
4443
}
45-
44+
4645
@Test
4746
public void getPetById() throws Exception {
4847
ObjectId id = ObjectId.get();
4948
Pets pets = new Pets(id, "Liam", "cat", "tabby");
5049

5150
given(petsController.getPetById(id)).willReturn(pets);
5251

53-
mvc.perform(get("/pets/"+id+"/").contentType("application/json;charset=UTF-8")).andExpect(status().isOk())
54-
.andExpect(jsonPath("$.name").value("Liam"))
55-
.andExpect(jsonPath("$.breed").value("tabby"))
56-
.andExpect(jsonPath("$.species").value("cat"))
57-
.andReturn();
52+
mvc.perform(get("/pets/" + id + "/").contentType("application/json;charset=UTF-8")).andExpect(status().isOk())
53+
.andExpect(jsonPath("$.name").value("Liam")).andExpect(jsonPath("$.breed").value("tabby"))
54+
.andExpect(jsonPath("$.species").value("cat")).andReturn();
55+
}
56+
57+
@Test
58+
public void createPet() throws Exception {
59+
Pets pets = new Pets();
60+
61+
pets.setName("Liam");
62+
pets.setBreed("tabby");
63+
pets.setSpecies("cat");
64+
65+
given(petsController.createPet(pets)).willReturn(pets);
66+
67+
mvc.perform(post("/pets/").contentType("application/json;charset=UTF-8")).andExpect(status().isOk());
5868
}
59-
60-
// @Test
61-
// public void modifyPetById() throws Exception {
62-
// ObjectId id = ObjectId.get();
63-
// Pets pets = new Pets();
64-
//
65-
// pets.setId(id);
66-
//
67-
// //given(petsController.modifyPetById(id, pets)).willReturn(pets);
68-
//
69-
// mvc.perform(get("/pets/"+id+"/").contentType("application/json;charset=UTF-8")).andExpect(status().isOk())
70-
// .andExpect(jsonPath("$.name").value("Liam"))
71-
// .andExpect(jsonPath("$.breed").value("tabby"))
72-
// .andExpect(jsonPath("$.species").value("cat"))
73-
// .andReturn();
74-
// }
7569
}

0 commit comments

Comments
 (0)