Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

validator additions for testing #17

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -205,6 +205,7 @@ void createCompetencyTest() throws Exception {
void updateCompetencyTest() throws Exception {
CompetencyDto competencyDto = new CompetencyDto();
competencyDto.setCompetencyid(1L);
competencyDto.setCompetencyframeworktitle("Any");
Mockito.doReturn(Optional.of(getCompetencyList().iterator().next()))
.when(getCompetencySvc()).get(1L);
Mockito.doReturn(getCompetencyList().iterator().next())
Expand Down Expand Up @@ -295,6 +296,7 @@ private static Iterable<Competency> getCompetencyList() {
List<Competency> competencyList = new ArrayList<>();
Competency competency = new Competency();
competency.setCompetencyid(1L);
competency.setCompetencyframeworktitle("Any");
competencyList.add(competency);
Collection<Competency> collections = competencyList;
Iterable<Competency> iterable = collections;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -216,6 +216,7 @@ void updateContactInformationTest() throws Exception {
ContactInformationDto contactInformationDto =
new ContactInformationDto();
contactInformationDto.setContactinformationid(1L);
contactInformationDto.setContactinformationData("Any");
Mockito.doReturn(
Optional.of(getContactInformationList().iterator().next()))
.when(getContactInformationSvc()).get(1L);
Expand Down Expand Up @@ -247,6 +248,7 @@ void updateContactInformationErrorTest() throws Exception {
ContactInformationDto contactInformationDto =
new ContactInformationDto();
contactInformationDto.setContactinformationid(1L);
contactInformationDto.setContactinformationData("Any");

Mockito.doReturn(getContactInformationList().iterator().next())
.when(getContactInformationSvc())
Expand Down Expand Up @@ -311,6 +313,7 @@ private static Iterable<ContactInformation> getContactInformationList() {
List<ContactInformation> contactInformationList = new ArrayList<>();
ContactInformation contactInformation = new ContactInformation();
contactInformation.setContactinformationid(1L);
contactInformation.setContactinformationData("Any");
contactInformationList.add(contactInformation);
Collection<ContactInformation> collections = contactInformationList;
Iterable<ContactInformation> iterable = collections;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -240,7 +240,7 @@ void updateCourseTest() throws Exception {
void updateCourseErrorTest() throws Exception {
CourseDto courseDto = new CourseDto();
courseDto.setCourseid(1L);

courseDto.setCourseidentifier("Any");
Mockito.doReturn(getCourseList().iterator().next()).when(getCourseSvc())
.save(getCourseList().iterator().next());
MockHttpServletRequestBuilder requestBuilder = MockMvcRequestBuilders
Expand Down Expand Up @@ -303,6 +303,7 @@ private static Iterable<Course> getCourseList() {
List<Course> courseList = new ArrayList<>();
Course course = new Course();
course.setCourseid(1L);
course.setCourseidentifier("Any");
courseList.add(course);
Collection<Course> collections = courseList;
Iterable<Course> iterable = collections;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -212,6 +212,7 @@ void createEmploymentTest() throws Exception {
void updateEmploymentTest() throws Exception {
EmploymentDto employmentDto = new EmploymentDto();
employmentDto.setEmploymentid(1L);
employmentDto.setEmployerName("Any");
Mockito.doReturn(Optional.of(getEmploymentList().iterator().next()))
.when(getEmploymentSvc()).get(1L);
Mockito.doReturn(getEmploymentList().iterator().next())
Expand Down Expand Up @@ -241,7 +242,7 @@ void updateEmploymentTest() throws Exception {
void updateEmploymentErrorTest() throws Exception {
EmploymentDto employmentDto = new EmploymentDto();
employmentDto.setEmploymentid(1L);

employmentDto.setEmployerName("Any");
Mockito.doReturn(getEmploymentList().iterator().next())
.when(getEmploymentSvc())
.save(getEmploymentList().iterator().next());
Expand Down Expand Up @@ -305,6 +306,7 @@ private static Iterable<Employment> getEmploymentList() {
List<Employment> employmentList = new ArrayList<>();
Employment employment = new Employment();
employment.setEmploymentid(1L);
employment.setEmployerName("Any");
employmentList.add(employment);
Collection<Employment> collections = employmentList;
Iterable<Employment> iterable = collections;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ void getLearnerByIdTest() throws Exception {
//Mockito.doReturn(getLearnerList())
// .when(getLearnerCreatorSvc().learnerCreator("test"));
MockHttpServletRequestBuilder requestBuilder = MockMvcRequestBuilders
.get("/api/learner?param1=test")
.get("/api/learner?param1=test&param2=test")
.accept(MediaType.APPLICATION_JSON)
.contentType(MediaType.APPLICATION_JSON)
.headers(headers);
Expand All @@ -105,7 +105,7 @@ void getLearnerByIdTest() throws Exception {
void getLearnerByIdErrorTest() throws Exception {

MockHttpServletRequestBuilder requestBuilder = MockMvcRequestBuilders
.get("/api/learner?param1=test")
.get("/api/learner?param1=test&param2=test")
.accept(MediaType.APPLICATION_JSON)
.contentType(MediaType.APPLICATION_JSON)
.headers(headers);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -186,15 +186,15 @@ void getOrganizationByIdParameterTest() throws Exception {
*/
@Test
void createOrganizationTest() throws Exception {
OrganizationDto orgnizationDto = new OrganizationDto();
orgnizationDto.setOrganizationid(1L);
OrganizationDto organizationDto = new OrganizationDto();
organizationDto.setOrganizationid(1L);
Mockito.doReturn(getOrganizationList().iterator().next())
.when(getOrganizationSvc())
.save(getOrganizationList().iterator().next());

mockMvc.perform(post("/api/organization/")
.contentType(MediaType.APPLICATION_JSON)
.content(objectMapper.writeValueAsString(orgnizationDto))
.content(objectMapper.writeValueAsString(organizationDto))
.headers(headers));
//.andExpect(status().isCreated()).andDo(print());
}
Expand All @@ -204,24 +204,25 @@ void createOrganizationTest() throws Exception {
*/
@Test
void updateOrganizationTest() throws Exception {
OrganizationDto orgnizationDto = new OrganizationDto();
orgnizationDto.setOrganizationid(1L);
OrganizationDto organizationDto = new OrganizationDto();
organizationDto.setOrganizationid(1L);
organizationDto.setOrganizationname("Any");
Mockito.doReturn(Optional.of(getOrganizationList().iterator().next()))
.when(getOrganizationSvc()).get(1L);
Mockito.doReturn(getOrganizationList().iterator().next())
.when(getOrganizationSvc())
.save(getOrganizationList().iterator().next());
MockHttpServletRequestBuilder requestBuilder = MockMvcRequestBuilders
.put("/api/organization/1").accept(MediaType.APPLICATION_JSON)
.content(objectMapper.writeValueAsString(orgnizationDto))
.content(objectMapper.writeValueAsString(organizationDto))
.contentType(MediaType.APPLICATION_JSON)
.headers(headers);

MvcResult mvcResult = mockMvc.perform(requestBuilder).andReturn();
assertNotNull(mvcResult);
mockMvc.perform(put("/api/organization/1")
.contentType(MediaType.APPLICATION_JSON)
.content(objectMapper.writeValueAsString(orgnizationDto))
.content(objectMapper.writeValueAsString(organizationDto))
.headers(headers));
// .andExpect(status().isCreated()).andDo(print());

Expand All @@ -232,23 +233,24 @@ void updateOrganizationTest() throws Exception {
*/
@Test
void updateOrganizationErrorTest() throws Exception {
OrganizationDto orgnizationDto = new OrganizationDto();
orgnizationDto.setOrganizationid(1L);
OrganizationDto organizationDto = new OrganizationDto();
organizationDto.setOrganizationid(1L);
organizationDto.setOrganizationname("Any");

Mockito.doReturn(getOrganizationList().iterator().next())
.when(getOrganizationSvc())
.save(getOrganizationList().iterator().next());
MockHttpServletRequestBuilder requestBuilder = MockMvcRequestBuilders
.put("/api/organization/1").accept(MediaType.APPLICATION_JSON)
.content(objectMapper.writeValueAsString(orgnizationDto))
.content(objectMapper.writeValueAsString(organizationDto))
.contentType(MediaType.APPLICATION_JSON)
.headers(headers);

MvcResult mvcResult = mockMvc.perform(requestBuilder).andReturn();
assertNotNull(mvcResult);
mockMvc.perform(put("/api/organization/1")
.contentType(MediaType.APPLICATION_JSON)
.content(objectMapper.writeValueAsString(orgnizationDto))
.content(objectMapper.writeValueAsString(organizationDto))
.headers(headers));
// .andExpect(status().isCreated()).andDo(print());

Expand Down Expand Up @@ -293,11 +295,12 @@ void deleteOrganizationErrorTest() throws Exception {
* @return Iterable<OrganizationDto>
*/
private static Iterable<Organization> getOrganizationList() {
List<Organization> orgnizationList = new ArrayList<>();
Organization orgnization = new Organization();
orgnization.setOrganizationid(1L);
orgnizationList.add(orgnization);
Collection<Organization> collections = orgnizationList;
List<Organization> organizationList = new ArrayList<>();
Organization organization = new Organization();
organization.setOrganizationid(1L);
organization.setOrganizationname("Any");
orgnaizationList.add(organization);
Collection<Organization> collections = organizationList;
Iterable<Organization> iterable = collections;
return iterable;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -204,6 +204,9 @@ void createPersonTest() throws Exception {
void updatePersonTest() throws Exception {
PersonDto personDto = new PersonDto();
personDto.setPersonid(1L);
personDto.setName("Any");
personDto.setFirstName("Any");
personDto.setLastName("Any");
Mockito.doReturn(Optional.of(getPersonList().iterator().next()))
.when(getPersonSvc()).get(1L);
Mockito.doReturn(getPersonList().iterator().next()).when(getPersonSvc())
Expand Down Expand Up @@ -231,7 +234,9 @@ void updatePersonTest() throws Exception {
void updatePersonErrorTest() throws Exception {
PersonDto personDto = new PersonDto();
personDto.setPersonid(1L);

personDto.setName("Any");
personDto.setFirstName("Any");
personDto.setLastName("Any");
Mockito.doReturn(getPersonList().iterator().next()).when(getPersonSvc())
.save(getPersonList().iterator().next());
MockHttpServletRequestBuilder requestBuilder = MockMvcRequestBuilders
Expand Down Expand Up @@ -291,6 +296,7 @@ private static Iterable<Person> getPersonList() {
List<Person> personList = new ArrayList<>();
Person person = new Person();
person.setPersonid(1L);
person.setName("Any");
personList.add(person);
Collection<Person> collections = personList;
Iterable<Person> iterable = collections;
Expand Down