Skip to content

Commit d83a084

Browse files
added docs and CONTRIBUTING.md
1 parent 57c698e commit d83a084

File tree

7 files changed

+166
-19
lines changed

7 files changed

+166
-19
lines changed

docs/CONTRIBUTING.md

Lines changed: 92 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,92 @@
1+
# Contributing
2+
3+
When contributing to this repository, please first discuss the change you wish to make via issue,
4+
email, or any other method with the owners of this repository before making a change.
5+
6+
Please note we have a code of conduct, please follow it in all your interactions with the project.
7+
8+
## Pull Request Process
9+
10+
1. Ensure any install or build dependencies are removed before the end of the layer when doing a
11+
build.
12+
2. Update the README.md with details of changes to the interface, this includes new environment
13+
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
17+
do not have permission to do that, you may request the second reviewer to merge it for you.
18+
19+
## Code of Conduct
20+
21+
### Our Pledge
22+
23+
In the interest of fostering an open and welcoming environment, we as
24+
contributors and maintainers pledge to making participation in our project and
25+
our community a harassment-free experience for everyone, regardless of age, body
26+
size, disability, ethnicity, gender identity and expression, level of experience,
27+
nationality, personal appearance, race, religion, or sexual identity and
28+
orientation.
29+
30+
### Our Standards
31+
32+
Examples of behavior that contributes to creating a positive environment
33+
include:
34+
35+
* Using welcoming and inclusive language
36+
* Being respectful of differing viewpoints and experiences
37+
* Gracefully accepting constructive criticism
38+
* Focusing on what is best for the community
39+
* Showing empathy towards other community members
40+
41+
Examples of unacceptable behavior by participants include:
42+
43+
* The use of sexualized language or imagery and unwelcome sexual attention or
44+
advances
45+
* Trolling, insulting/derogatory comments, and personal or political attacks
46+
* Public or private harassment
47+
* Publishing others' private information, such as a physical or electronic
48+
address, without explicit permission
49+
* Other conduct which could reasonably be considered inappropriate in a
50+
professional setting
51+
52+
### Our Responsibilities
53+
54+
Project maintainers are responsible for clarifying the standards of acceptable
55+
behavior and are expected to take appropriate and fair corrective action in
56+
response to any instances of unacceptable behavior.
57+
58+
Project maintainers have the right and responsibility to remove, edit, or
59+
reject comments, commits, code, wiki edits, issues, and other contributions
60+
that are not aligned to this Code of Conduct, or to ban temporarily or
61+
permanently any contributor for other behaviors that they deem inappropriate,
62+
threatening, offensive, or harmful.
63+
64+
### Scope
65+
66+
This Code of Conduct applies both within project spaces and in public spaces
67+
when an individual is representing the project or its community. Examples of
68+
representing a project or community include using an official project e-mail
69+
address, posting via an official social media account, or acting as an appointed
70+
representative at an online or offline event. Representation of a project may be
71+
further defined and clarified by project maintainers.
72+
73+
### Enforcement
74+
75+
Instances of abusive, harassing, or otherwise unacceptable behavior may be
76+
reported by contacting the project team at [INSERT EMAIL ADDRESS]. All
77+
complaints will be reviewed and investigated and will result in a response that
78+
is deemed necessary and appropriate to the circumstances. The project team is
79+
obligated to maintain confidentiality with regard to the reporter of an incident.
80+
Further details of specific enforcement policies may be posted separately.
81+
82+
Project maintainers who do not follow or enforce the Code of Conduct in good
83+
faith may face temporary or permanent repercussions as determined by other
84+
members of the project's leadership.
85+
86+
### Attribution
87+
88+
This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4,
89+
available at [http://contributor-covenant.org/version/1/4][version]
90+
91+
[homepage]: http://contributor-covenant.org
92+
[version]: http://contributor-covenant.org/version/1/4/

docs/createPet.png

182 KB
Loading

docs/deletePet.png

114 KB
Loading

docs/getAllPets.png

229 KB
Loading

docs/getPetById.png

164 KB
Loading

docs/modifyPetById.png

156 KB
Loading
Lines changed: 74 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,75 @@
1-
//package com.gourav.restApi.controllers;
1+
package com.gourav.restapi.controllers;
2+
3+
import org.bson.types.ObjectId;
4+
import org.junit.Test;
5+
import org.junit.runner.RunWith;
6+
import org.springframework.beans.factory.annotation.Autowired;
7+
import org.springframework.boot.test.autoconfigure.web.servlet.WebMvcTest;
8+
import org.springframework.boot.test.mock.mockito.MockBean;
9+
import org.springframework.test.context.junit4.SpringRunner;
10+
import org.springframework.test.web.servlet.MockMvc;
11+
12+
import static java.util.Collections.singletonList;
13+
import static org.mockito.BDDMockito.given;
14+
import java.util.List;
15+
import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.get;
16+
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.jsonPath;
17+
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status;
18+
import com.gourav.restapi.models.Pets;
19+
20+
@RunWith(SpringRunner.class)
21+
@WebMvcTest(value = PetsController.class)
22+
public class PetsControllerTest {
23+
24+
@Autowired
25+
private MockMvc mvc;
26+
27+
@MockBean
28+
private PetsController petsController;
29+
30+
@Test
31+
public void getAllPets() throws Exception {
32+
ObjectId id = ObjectId.get();
33+
Pets pets = new Pets(id, "Liam", "cat", "tabby");
34+
35+
List<Pets> allPets = singletonList(pets);
36+
37+
given(petsController.getAllPets()).willReturn(allPets);
38+
39+
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();
44+
}
45+
46+
@Test
47+
public void getPetById() throws Exception {
48+
ObjectId id = ObjectId.get();
49+
Pets pets = new Pets(id, "Liam", "cat", "tabby");
50+
51+
given(petsController.getPetById(id)).willReturn(pets);
52+
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();
58+
}
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);
268
//
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-
//}
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+
// }
75+
}

0 commit comments

Comments
 (0)