From c9956e85a75ae04577303f46ca3f219359573829 Mon Sep 17 00:00:00 2001 From: smednick Date: Mon, 13 Nov 2023 21:05:56 -0800 Subject: [PATCH] validator additions for testing --- .../controller/CompetencyControllerTest.java | 2 ++ .../ContactInformationControllerTest.java | 3 ++ .../elrr/controller/CourseControllerTest.java | 3 +- .../controller/EmploymentControllerTest.java | 4 ++- .../elrr/controller/HomeControllerTests.java | 4 +-- .../OrganizationControllerTest.java | 35 ++++++++++--------- .../elrr/controller/PersonControllerTest.java | 8 ++++- 7 files changed, 38 insertions(+), 21 deletions(-) diff --git a/src/test/java/com/deloitte/elrr/controller/CompetencyControllerTest.java b/src/test/java/com/deloitte/elrr/controller/CompetencyControllerTest.java index c24ab68..b1b952a 100644 --- a/src/test/java/com/deloitte/elrr/controller/CompetencyControllerTest.java +++ b/src/test/java/com/deloitte/elrr/controller/CompetencyControllerTest.java @@ -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()) @@ -295,6 +296,7 @@ private static Iterable getCompetencyList() { List competencyList = new ArrayList<>(); Competency competency = new Competency(); competency.setCompetencyid(1L); + competency.setCompetencyframeworktitle("Any"); competencyList.add(competency); Collection collections = competencyList; Iterable iterable = collections; diff --git a/src/test/java/com/deloitte/elrr/controller/ContactInformationControllerTest.java b/src/test/java/com/deloitte/elrr/controller/ContactInformationControllerTest.java index 9b4c9d9..2491890 100644 --- a/src/test/java/com/deloitte/elrr/controller/ContactInformationControllerTest.java +++ b/src/test/java/com/deloitte/elrr/controller/ContactInformationControllerTest.java @@ -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); @@ -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()) @@ -311,6 +313,7 @@ private static Iterable getContactInformationList() { List contactInformationList = new ArrayList<>(); ContactInformation contactInformation = new ContactInformation(); contactInformation.setContactinformationid(1L); + contactInformation.setContactinformationData("Any"); contactInformationList.add(contactInformation); Collection collections = contactInformationList; Iterable iterable = collections; diff --git a/src/test/java/com/deloitte/elrr/controller/CourseControllerTest.java b/src/test/java/com/deloitte/elrr/controller/CourseControllerTest.java index abcbb7d..3fdeff4 100644 --- a/src/test/java/com/deloitte/elrr/controller/CourseControllerTest.java +++ b/src/test/java/com/deloitte/elrr/controller/CourseControllerTest.java @@ -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 @@ -303,6 +303,7 @@ private static Iterable getCourseList() { List courseList = new ArrayList<>(); Course course = new Course(); course.setCourseid(1L); + course.setCourseidentifier("Any"); courseList.add(course); Collection collections = courseList; Iterable iterable = collections; diff --git a/src/test/java/com/deloitte/elrr/controller/EmploymentControllerTest.java b/src/test/java/com/deloitte/elrr/controller/EmploymentControllerTest.java index 714191b..ee3fea7 100644 --- a/src/test/java/com/deloitte/elrr/controller/EmploymentControllerTest.java +++ b/src/test/java/com/deloitte/elrr/controller/EmploymentControllerTest.java @@ -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()) @@ -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()); @@ -305,6 +306,7 @@ private static Iterable getEmploymentList() { List employmentList = new ArrayList<>(); Employment employment = new Employment(); employment.setEmploymentid(1L); + employment.setEmployerName("Any"); employmentList.add(employment); Collection collections = employmentList; Iterable iterable = collections; diff --git a/src/test/java/com/deloitte/elrr/controller/HomeControllerTests.java b/src/test/java/com/deloitte/elrr/controller/HomeControllerTests.java index 623186a..430b506 100644 --- a/src/test/java/com/deloitte/elrr/controller/HomeControllerTests.java +++ b/src/test/java/com/deloitte/elrr/controller/HomeControllerTests.java @@ -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¶m2=test") .accept(MediaType.APPLICATION_JSON) .contentType(MediaType.APPLICATION_JSON) .headers(headers); @@ -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¶m2=test") .accept(MediaType.APPLICATION_JSON) .contentType(MediaType.APPLICATION_JSON) .headers(headers); diff --git a/src/test/java/com/deloitte/elrr/controller/OrganizationControllerTest.java b/src/test/java/com/deloitte/elrr/controller/OrganizationControllerTest.java index 8c1535a..afb2beb 100644 --- a/src/test/java/com/deloitte/elrr/controller/OrganizationControllerTest.java +++ b/src/test/java/com/deloitte/elrr/controller/OrganizationControllerTest.java @@ -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()); } @@ -204,8 +204,9 @@ 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()) @@ -213,7 +214,7 @@ void updateOrganizationTest() throws Exception { .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); @@ -221,7 +222,7 @@ void updateOrganizationTest() throws Exception { 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()); @@ -232,15 +233,16 @@ 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); @@ -248,7 +250,7 @@ void updateOrganizationErrorTest() throws Exception { 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()); @@ -293,11 +295,12 @@ void deleteOrganizationErrorTest() throws Exception { * @return Iterable */ private static Iterable getOrganizationList() { - List orgnizationList = new ArrayList<>(); - Organization orgnization = new Organization(); - orgnization.setOrganizationid(1L); - orgnizationList.add(orgnization); - Collection collections = orgnizationList; + List organizationList = new ArrayList<>(); + Organization organization = new Organization(); + organization.setOrganizationid(1L); + organization.setOrganizationname("Any"); + orgnaizationList.add(organization); + Collection collections = organizationList; Iterable iterable = collections; return iterable; } diff --git a/src/test/java/com/deloitte/elrr/controller/PersonControllerTest.java b/src/test/java/com/deloitte/elrr/controller/PersonControllerTest.java index 34a76e2..e85dbb2 100644 --- a/src/test/java/com/deloitte/elrr/controller/PersonControllerTest.java +++ b/src/test/java/com/deloitte/elrr/controller/PersonControllerTest.java @@ -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()) @@ -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 @@ -291,6 +296,7 @@ private static Iterable getPersonList() { List personList = new ArrayList<>(); Person person = new Person(); person.setPersonid(1L); + person.setName("Any"); personList.add(person); Collection collections = personList; Iterable iterable = collections;