diff --git a/README.md b/README.md index 88386c8..7001517 100755 --- a/README.md +++ b/README.md @@ -36,6 +36,10 @@ python gettoken.py Na koniec w przęglądarce dostaniesz w odpowiedzi token. W samym pliku można zmienić porty aplikacji jeśli to potrzebne. +## Api docs + +Żeby zobaczyć dokumentację api trzeba wejść w przeglądarce na `http://localhost:1285/swagger-ui.html` po odpaleniu aplikacji. + ## Packaging Zeby spakowac apke do `jara` wystarcza dwie komendy zaczynajac z glownego katalogu projektu diff --git a/buisnesslogic/pom.xml b/buisnesslogic/pom.xml index 73b3b1d..2c6b9cb 100755 --- a/buisnesslogic/pom.xml +++ b/buisnesslogic/pom.xml @@ -16,8 +16,8 @@ UTF-8 - 1.14 - 1.14 + 14 + 14 diff --git a/docs/api.md b/docs/api.md deleted file mode 100755 index 6556d62..0000000 --- a/docs/api.md +++ /dev/null @@ -1,88 +0,0 @@ -# Dokumetacja API - -| Api | Zadania endpointa | -| ------------------------------------------------------------- | ---------------------------------------------------------------------------- | -| [/api/v1/configurator/config](#config) | Załadowanie konfiguracji startowej do aplikacji PlanNaPlan | -| [/api/v1/courses/getCoursesWithGroups](#getcourseswithgroups) | Zwrócenie wszytskich kursów razem z grupami | -| [/api/v1/groups/getCourseGroups](#getcoursegroups) | Zwrócenie grup dla danego kursu | -| [/api/v1/courses/getCourses](#getcourses) | Zwrócenie wszystkich kursów | -| [/token](#token) | Wymienia ticket z CAS-a na token ktorym beda autoryzowane chronione requesty | - -## config - -Source code: [link](../restservice/src/main/java/com/plannaplan/controllers/ConfigController.java) - -``` -POST /config -``` - -#### Opis - -Endpoint konfigurujacy caly system i importujacy dane do bazy. - -#### Parametry - -| Type | Name | Consumes | Opis | Type | -| ---- | ----------------------- | ------------------- | ------------------------------- | ---- | -| Body | **file**
required | multipart/form-data | Plik .xlsx z potrzebnymi danymi | file | - -## getCoursesWithGroups - -Source code: [link](../restservice/src/main/java/com/plannaplan/controllers/getCoursesWithGroups.java) - -``` -GET /api/v1/courses/getCoursesWithGroups -``` - -#### Opis - -Zwraca wszystkie dostepne kursy wraz z listą grup. - -## getCourseGroups - -Source code: [link](../restservice/src/main/java/com/plannaplan/controllers/GroupController.java) - -``` -GET /api/v1/groups/getCourseGroups -``` - -#### Opis - -Zwraca wszytskie grupy dla danego kursu. - -#### Parametry - -| Type | Name | Consumes | Opis | Type | -| ----------- | --------------------- | -------- | ----------------------------------------- | ---- | -| Query Param | **id**
required | - | id kursu dla ktorego chcemy zwrocic grupy | int | -| Query Param | **capacity**
| - | czy ma zwrocic pole pojemnosci grupy | bool | - -## getCourses - -Source code: [link](../restservice/src/main/java/com/plannaplan/controllers/CoursesController.java) - -``` -GET /api/v1/courses/getCourses -``` - -#### Opis - -Zwraca wszystkie dostepne kursy. - -## token - -Source code: [link](../restservice/src/main/java/com/plannaplan/controllers/TokenController.java) - -``` -GET /token?ticket=ST-668405-W0gfvSVDRBdMUWLweKzv-cas.amu.edu.pl -``` - -#### Opis - -Po odpytaniu tego endpointa z podanym ticketem system zrobi nma nim validate i dostanie uzytkownika dla ktorego zostal on wygenerowany. System utworzy dla niego access token i go zwroci w odpowiedzi - -#### Parametry - -| Type | Name | Consumes | Opis | Type | -| ----------- | ------------------------- | -------- | --------------------------------------- | ------ | -| Query Param | **ticket**
required | - | ticket uzyskany z logowania poprzez CAS | string | diff --git a/restservice/pom.xml b/restservice/pom.xml index 68b7c09..60714c1 100755 --- a/restservice/pom.xml +++ b/restservice/pom.xml @@ -18,9 +18,10 @@ UTF-8 - 1.14 - 1.14 + 14 + 14 com.plannaplan.App + 2.9.2 @@ -85,6 +86,22 @@ com.plannaplan 1.0-SNAPSHOT + + + + io.springfox + springfox-swagger2 + ${swagger.version} + + + + + io.springfox + springfox-swagger-ui + ${swagger.version} + + + diff --git a/restservice/src/main/java/com/plannaplan/App.java b/restservice/src/main/java/com/plannaplan/App.java index 6e91104..d5b08eb 100755 --- a/restservice/src/main/java/com/plannaplan/App.java +++ b/restservice/src/main/java/com/plannaplan/App.java @@ -8,6 +8,7 @@ import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.SpringApplication; import org.springframework.boot.autoconfigure.SpringBootApplication; import org.springframework.boot.context.event.ApplicationReadyEvent; + import org.springframework.context.event.EventListener; @SpringBootApplication @@ -53,7 +54,7 @@ public class App { mar.setEmail("marwoz16@st.amu.edu.pl"); mar.setName("Marcin"); mar.setSurname("Woźniak"); - mar.setRole(UserRoles.STUDENT); + mar.setRole(UserRoles.ADMIN); this.userService.save(mar); } diff --git a/restservice/src/main/java/com/plannaplan/Swagger2Config.java b/restservice/src/main/java/com/plannaplan/Swagger2Config.java new file mode 100755 index 0000000..5ccbe90 --- /dev/null +++ b/restservice/src/main/java/com/plannaplan/Swagger2Config.java @@ -0,0 +1,38 @@ +package com.plannaplan; + +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.Configuration; +import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry; +import org.springframework.web.servlet.config.annotation.WebMvcConfigurationSupport; +import springfox.documentation.builders.ApiInfoBuilder; +import springfox.documentation.builders.PathSelectors; +import springfox.documentation.builders.RequestHandlerSelectors; +import springfox.documentation.service.ApiInfo; +import springfox.documentation.spi.DocumentationType; +import springfox.documentation.spring.web.plugins.Docket; +import springfox.documentation.swagger2.annotations.EnableSwagger2; + +@Configuration +@EnableSwagger2 +public class Swagger2Config extends WebMvcConfigurationSupport { + + @Bean + public Docket createRestApi() { + return new Docket(DocumentationType.SWAGGER_2).apiInfo(apiInfo()).select() + .apis(RequestHandlerSelectors.basePackage("com.plannaplan.controllers")).paths(PathSelectors.any()) + .build(); + } + + @Override + public void addResourceHandlers(ResourceHandlerRegistry registry) { + registry.addResourceHandler("swagger-ui.html").addResourceLocations("classpath:/META-INF/resources/"); + registry.addResourceHandler("/webjars/**").addResourceLocations("classpath:/META-INF/resources/webjars/"); + } + + private ApiInfo apiInfo() { + return new ApiInfoBuilder().title("plannaplan").description("Aplikacja do zapisów na zajęcia UAM.") + .termsOfServiceUrl("https://plannaplan.pl/") + // .contact("") + .version("1.0").build(); + } +} \ No newline at end of file diff --git a/restservice/src/main/java/com/plannaplan/controllers/AssignmentsController.java b/restservice/src/main/java/com/plannaplan/controllers/AssignmentsController.java index 1ff8570..8f3a395 100755 --- a/restservice/src/main/java/com/plannaplan/controllers/AssignmentsController.java +++ b/restservice/src/main/java/com/plannaplan/controllers/AssignmentsController.java @@ -4,6 +4,9 @@ import org.springframework.web.bind.annotation.CrossOrigin; import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.RestController; +import io.swagger.annotations.Api; +import io.swagger.annotations.ApiOperation; + import java.util.List; import java.util.Optional; @@ -24,6 +27,8 @@ import org.springframework.web.bind.annotation.RequestMapping; @RestController @CrossOrigin @RequestMapping("/api/" + App.API_VERSION + "/assignments") +@Api(tags = { + "Assignments" }, value = "Assignments", description = "Assignment is representation of student willing to join given group (lecture or calss)") public class AssignmentsController extends TokenBasedController { @Autowired @@ -32,7 +37,8 @@ public class AssignmentsController extends TokenBasedController { @Autowired private AssignmentService assignmentService; - @GetMapping("/getCurrentAssignments") + @GetMapping("/user") + @ApiOperation(value = "Retrun user current assignemts (from newest commision). STUDENT Token needs to be provided.") public ResponseEntity> getCurrentAssignments() throws Exception { User user = this.getCurrentUser().orElseThrow(() -> new NullPointerException("User not found")); Optional com = this.commisionService.getNewestCommision(user); diff --git a/restservice/src/main/java/com/plannaplan/controllers/CommisionController.java b/restservice/src/main/java/com/plannaplan/controllers/CommisionController.java index 0c95549..ef578c0 100755 --- a/restservice/src/main/java/com/plannaplan/controllers/CommisionController.java +++ b/restservice/src/main/java/com/plannaplan/controllers/CommisionController.java @@ -2,8 +2,12 @@ package com.plannaplan.controllers; import org.springframework.web.bind.annotation.CrossOrigin; import org.springframework.web.bind.annotation.GetMapping; -import org.springframework.web.bind.annotation.PathVariable; import org.springframework.web.bind.annotation.RestController; +import org.springframework.web.bind.annotation.PathVariable; + +import io.swagger.annotations.Api; +import io.swagger.annotations.ApiOperation; +import io.swagger.annotations.ApiParam; import java.util.List; import java.util.Optional; @@ -24,15 +28,16 @@ import com.plannaplan.types.UserRoles; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.http.HttpStatus; import org.springframework.http.ResponseEntity; -import org.springframework.security.access.prepost.PreAuthorize; -import org.springframework.util.Assert; import org.springframework.web.bind.annotation.PostMapping; import org.springframework.web.bind.annotation.RequestBody; +import org.springframework.security.access.prepost.PreAuthorize; +import org.springframework.util.Assert; import org.springframework.web.bind.annotation.RequestMapping; @RestController @CrossOrigin @RequestMapping("/api/" + App.API_VERSION + "/commisions") +@Api(tags = { "Commisions" }, value = "Commisions", description = "Commision is representation of student selected assignments at time. All assignments are attached to some commision so we can see current assignments and also browse histroy of changes for given user") public class CommisionController extends TokenBasedController { @Autowired @@ -47,8 +52,10 @@ public class CommisionController extends TokenBasedController { public CommisionController() { } - @PostMapping(value = { "/add", "/add/{id}" }) - public ResponseEntity addCommision(@RequestBody List groups, + @PostMapping(value = { "/user", "/user/{id}" }) + @ApiOperation(value = "Create commision with assignents to given groups. If group doesn't exist error will be thrown") + public ResponseEntity addCommision( + @RequestBody @ApiParam(value = "List of groups ids user want to assign to. If group doesnt exisit error will be thrown") List groups, @PathVariable(name = "id", required = false) Long userId) { try { @@ -62,7 +69,7 @@ public class CommisionController extends TokenBasedController { : asker; Assert.isTrue((asker.getRole() == UserRoles.DEANERY && user.getRole() == UserRoles.STUDENT - || (asker.getId() == user.getId() && user.getRole() == UserRoles.STUDENT)), + || (asker.getId().equals(user.getId()) && user.getRole() == UserRoles.STUDENT)), "Incorrect attempt to change plan"); Optional notExistingGroup = this.groupServcicxe.findNotExistingGroup(groups); @@ -87,7 +94,8 @@ public class CommisionController extends TokenBasedController { } } - @GetMapping("/getAllCommisions") + @GetMapping("/user") + @ApiOperation("Return list of user all commisions (history of schedules)") public ResponseEntity> getAlCommisions() throws UserNotFoundException { User user = this.getCurrentUser().orElseThrow(() -> new NullPointerException()); List result = CommisionResponseMappers @@ -97,6 +105,7 @@ public class CommisionController extends TokenBasedController { @PreAuthorize("hasRole('ROLE_DEANERY')") @GetMapping("/user/{id}") + @ApiOperation("Return list of commisions for given user. To be able to access this data u need to provide DEANERY token") public ResponseEntity> getCommision(@PathVariable(name = "id") Long userId) throws UserNotFoundException { User user = this.userService.getById(userId).orElseThrow(() -> new NullPointerException()); diff --git a/restservice/src/main/java/com/plannaplan/controllers/ConfigController.java b/restservice/src/main/java/com/plannaplan/controllers/ConfigController.java index 5d5456b..58b94e1 100755 --- a/restservice/src/main/java/com/plannaplan/controllers/ConfigController.java +++ b/restservice/src/main/java/com/plannaplan/controllers/ConfigController.java @@ -19,10 +19,15 @@ import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestParam; import org.springframework.web.multipart.MultipartFile; +import io.swagger.annotations.Api; +import io.swagger.annotations.ApiOperation; +import io.swagger.annotations.ApiParam; + @RestController @CrossOrigin @RequestMapping("/api/" + App.API_VERSION + "/configurator") @EnableGlobalMethodSecurity(prePostEnabled = true) +@Api(tags = { "ConfigController" }, value = "ConfigController", description = "All endpoints to configure an app") public class ConfigController { @Autowired @@ -30,8 +35,9 @@ public class ConfigController { @PostMapping("/config") @PreAuthorize("hasRole('ROLE_ADMIN')") - - public ResponseEntity configApp(@RequestParam("file") MultipartFile file) { + @ApiOperation("Imports data to system. To call you need to provide ADMIN token") + public ResponseEntity configApp( + @RequestParam("file") @ApiParam(value = "file .xlsx that contains courses and groups with apoinnted rules") MultipartFile file) { try { final ConfigData data = new ConfigData(null, null, file.getInputStream()); this.contrl.config(data); diff --git a/restservice/src/main/java/com/plannaplan/controllers/CoursesController.java b/restservice/src/main/java/com/plannaplan/controllers/CoursesController.java index 204fbc3..f6ef2c5 100755 --- a/restservice/src/main/java/com/plannaplan/controllers/CoursesController.java +++ b/restservice/src/main/java/com/plannaplan/controllers/CoursesController.java @@ -14,30 +14,36 @@ import org.springframework.http.HttpStatus; import org.springframework.http.ResponseEntity; import org.springframework.web.bind.annotation.CrossOrigin; import org.springframework.web.bind.annotation.RestController; + +import io.swagger.annotations.Api; +import io.swagger.annotations.ApiOperation; +import io.swagger.annotations.ApiParam; + import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RequestParam; +import com.plannaplan.responses.models.abstracts.CoursesResponse; @RestController @CrossOrigin @RequestMapping("/api/" + App.API_VERSION + "/courses") +@Api(tags = { + "Course" }, value = "Course", description = "Endpoints to deal with courses. All courses can have classes, lectures or both.") public class CoursesController { @Autowired private CourseService courseService; - @GetMapping("/getCourses") - public ResponseEntity> getMethodName() { + @GetMapping("/all") + @ApiOperation(value = "Return all courses") + public ResponseEntity> getMethodName( + @RequestParam(name = "groups", defaultValue = "false") @ApiParam(value = "Boolean if you want to have resopnse with associated groups or without") Boolean groups) { List courses = this.courseService.getAllCourses(); - List response = CoursesResponseMappers.mapToGetCoursesResponse(courses); + if (groups) { + final List response = CoursesResponseMappers + .mapToGetCoursesWithGroupsResponse(courses); + return new ResponseEntity<>(response, HttpStatus.OK); + } + final List response = CoursesResponseMappers.mapToGetCoursesResponse(courses); return new ResponseEntity<>(response, HttpStatus.OK); } - - @GetMapping("/getCoursesWithGroups") - public ResponseEntity> getCoursesWithGroups() { - final List courses = this.courseService.getAllCourses(); - final List response = CoursesResponseMappers - .mapToGetCoursesWithGroupsResponse(courses); - return new ResponseEntity<>(response, HttpStatus.OK); - - } - } \ No newline at end of file diff --git a/restservice/src/main/java/com/plannaplan/controllers/GroupController.java b/restservice/src/main/java/com/plannaplan/controllers/GroupController.java index 90cbdda..811f43a 100755 --- a/restservice/src/main/java/com/plannaplan/controllers/GroupController.java +++ b/restservice/src/main/java/com/plannaplan/controllers/GroupController.java @@ -14,20 +14,30 @@ import org.springframework.http.HttpStatus; import org.springframework.http.ResponseEntity; import org.springframework.web.bind.annotation.CrossOrigin; import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.PathVariable; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestParam; import org.springframework.web.bind.annotation.RestController; +import io.swagger.annotations.Api; +import io.swagger.annotations.ApiOperation; +import io.swagger.annotations.ApiParam; + @RestController @CrossOrigin + @RequestMapping("/api/" + App.API_VERSION + "/groups") +@Api(tags = { + "Group" }, value = "Group", description = "Enpoints to deal with gorups. Group is related directly to course and can be either class and lecture") public class GroupController { @Autowired private GroupService groupService; - @GetMapping("/getCourseGroups") - public ResponseEntity> getCourses(@RequestParam("id") Long id, - @RequestParam(name = "capacity", defaultValue = "true") Boolean capacity) { + @GetMapping("/course/{id}") + @ApiOperation(value = "Return list of lectures and classes (if present) given course") + public ResponseEntity> getCourses( + @PathVariable(name = "id") Long id, + @RequestParam(name = "capacity", defaultValue = "true") @ApiParam(value = "Boolean if we want to have capacity field in response") Boolean capacity) { List groups = this.groupService.getGroupsByCourse(id); if (capacity) { return new ResponseEntity<>(GroupsMappers.mapToGetCourseGroupsWithCapacityResponse(groups), HttpStatus.OK); diff --git a/restservice/src/main/java/com/plannaplan/controllers/TokenController.java b/restservice/src/main/java/com/plannaplan/controllers/TokenController.java index 5093783..29df59d 100755 --- a/restservice/src/main/java/com/plannaplan/controllers/TokenController.java +++ b/restservice/src/main/java/com/plannaplan/controllers/TokenController.java @@ -13,8 +13,13 @@ import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.RequestParam; import org.springframework.web.bind.annotation.RestController; +import io.swagger.annotations.Api; +import io.swagger.annotations.ApiOperation; +import io.swagger.annotations.ApiParam; + @RestController @CrossOrigin +@Api(tags = { "Token" }, value = "Token", description = "Enpoints to get authorization.") public class TokenController { private final static String SERVICE_URL = "http://localhost:3000"; @@ -23,7 +28,9 @@ public class TokenController { private UserService userService; @GetMapping("/token") - public ResponseEntity getToken(@RequestParam("ticket") final String ticket) { + @ApiOperation(value = "Endpoint to access token required to call secured endpoints. In order to access token we need to provide access token comming from unviersity CAS system") + public ResponseEntity getToken( + @RequestParam("ticket") @ApiParam(value = "Ticket get from CAS system. It should look like ST-1376572-wo41gty5R0JCZFKMMie2-cas.amu.edu.pl") final String ticket) { final CasValidator validator = new CasValidator(SERVICE_URL, ticket); try { diff --git a/restservice/src/main/java/com/plannaplan/controllers/UsersController.java b/restservice/src/main/java/com/plannaplan/controllers/UsersController.java index d4a4ae1..4cbe585 100755 --- a/restservice/src/main/java/com/plannaplan/controllers/UsersController.java +++ b/restservice/src/main/java/com/plannaplan/controllers/UsersController.java @@ -15,6 +15,11 @@ import org.springframework.security.access.prepost.PreAuthorize; import org.springframework.security.config.annotation.method.configuration.EnableGlobalMethodSecurity; import org.springframework.web.bind.annotation.CrossOrigin; import org.springframework.web.bind.annotation.RestController; + +import io.swagger.annotations.Api; +import io.swagger.annotations.ApiOperation; +import io.swagger.annotations.ApiParam; + import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestParam; @@ -23,14 +28,16 @@ import org.springframework.web.bind.annotation.RequestParam; @CrossOrigin @RequestMapping("/api/" + App.API_VERSION + "/users") @EnableGlobalMethodSecurity(prePostEnabled = true) +@Api(tags = { "Users" }, value = "Users", description = "Endpoints to deal with users.") public class UsersController { @Autowired private UserService userService; - @GetMapping("/searchForStudents") + @GetMapping("/student/search") @PreAuthorize("hasRole('ROLE_DEANERY')") - - public ResponseEntity> configApp(@RequestParam("query") String query) { + @ApiOperation(value = "Serch for user by providing query. If query is empty it will return all students. You need token with DEANERY role to call this") + public ResponseEntity> configApp( + @RequestParam("query") @ApiParam(value = "Query to filter all students. If empty will match everyone") String query) { final List searches = this.userService.searchForStudents(query); final List response = UserResponseMappers.mapToDefaultResponse(searches); return new ResponseEntity<>(response, HttpStatus.OK); diff --git a/restservice/src/main/java/com/plannaplan/security/WebSecurityConfig.java b/restservice/src/main/java/com/plannaplan/security/WebSecurityConfig.java index 95b3785..d41b9f6 100755 --- a/restservice/src/main/java/com/plannaplan/security/WebSecurityConfig.java +++ b/restservice/src/main/java/com/plannaplan/security/WebSecurityConfig.java @@ -18,6 +18,7 @@ import org.springframework.security.web.authentication.HttpStatusEntryPoint; @Configuration @EnableWebSecurity + public class WebSecurityConfig extends WebSecurityConfigurerAdapter { private static final RequestMatcher PROTECTED_URLS = new OrRequestMatcher(new AntPathRequestMatcher("/api/**")); @@ -36,8 +37,9 @@ public class WebSecurityConfig extends WebSecurityConfigurerAdapter { @Override public void configure(final WebSecurity webSecurity) { - webSecurity.ignoring().antMatchers("/token**").antMatchers("/api/v1/courses/getCourses") - .antMatchers("/api/v1/groups/getCourseGroups").antMatchers("/api/v1/courses/getCoursesWithGroups"); + webSecurity.ignoring().antMatchers("/token**").antMatchers("/api/v1/courses/all") + .antMatchers("/api/v1/groups/course/{id}").antMatchers("/v2/api-docs", "/configuration/ui", + "/swagger-resources/**", "/configuration/security", "/swagger-ui.html", "/webjars/**"); } @Override diff --git a/restservice/src/test/java/com/plannaplan/controllers/AssignmentsControllerTest.java b/restservice/src/test/java/com/plannaplan/controllers/AssignmentsControllerTest.java index e80b447..e5de853 100755 --- a/restservice/src/test/java/com/plannaplan/controllers/AssignmentsControllerTest.java +++ b/restservice/src/test/java/com/plannaplan/controllers/AssignmentsControllerTest.java @@ -22,7 +22,7 @@ import static org.springframework.test.web.servlet.result.MockMvcResultMatchers. @ContextConfiguration public class AssignmentsControllerTest extends AbstractControllerTest { - private static final String ASSIGFNMENTS_ENDPOINT = "/api/v1/assignments/getCurrentAssignments"; + private static final String ASSIGFNMENTS_ENDPOINT = "/api/v1/assignments/user"; private static final String TEST_MAIL = "notexistingassignmentuser@mail.domain"; @Autowired diff --git a/restservice/src/test/java/com/plannaplan/controllers/CommisionControllerTest.java b/restservice/src/test/java/com/plannaplan/controllers/CommisionControllerTest.java index 883840b..1ee756b 100755 --- a/restservice/src/test/java/com/plannaplan/controllers/CommisionControllerTest.java +++ b/restservice/src/test/java/com/plannaplan/controllers/CommisionControllerTest.java @@ -40,8 +40,8 @@ public class CommisionControllerTest extends AbstractControllerTest { private static final String TEST_COMMISIONS_DEANERY_EMAIL = "commisions.deanery@notexisting.domain"; private static final String TEST_COMMISIONS_OTHER_DEANERY_EMAIL = "commisions.deanery2@notexisting.domain"; - private static final String ADD_COMMISION_ENDPOINT = "/api/v1/commisions/add"; - private static final String GET_COMMISIONS_ENDPOINT = "/api/v1/commisions/getAllCommisions"; + private static final String ADD_COMMISION_ENDPOINT = "/api/v1/commisions/user"; + private static final String GET_COMMISIONS_ENDPOINT = "/api/v1/commisions/user"; private static final String GET_SOMEONE_COMMISIONS_ENDPOINT = "/api/v1/commisions/user"; private static final MediaType APPLICATION_JSON_UTF8 = new MediaType(MediaType.APPLICATION_JSON.getType(), diff --git a/restservice/src/test/java/com/plannaplan/controllers/CoursesControllerTest.java b/restservice/src/test/java/com/plannaplan/controllers/CoursesControllerTest.java index a01d396..6b669b9 100755 --- a/restservice/src/test/java/com/plannaplan/controllers/CoursesControllerTest.java +++ b/restservice/src/test/java/com/plannaplan/controllers/CoursesControllerTest.java @@ -16,8 +16,8 @@ import static org.springframework.test.web.servlet.result.MockMvcResultMatchers. @ContextConfiguration public class CoursesControllerTest extends AbstractControllerTest { - private static final String COURSES_ENDPOINT = "/api/v1/courses/getCourses"; - private static final String COURSESGROUPS_ENDPOINT = "/api/v1/courses/getCoursesWithGroups"; + private static final String COURSES_ENDPOINT = "/api/v1/courses/all"; + private static final String COURSESGROUPS_ENDPOINT = "/api/v1/courses/all?groups=true"; @Test public void shouldReturnAllCoursesOk() throws Exception { diff --git a/restservice/src/test/java/com/plannaplan/controllers/GroupControllerTest.java b/restservice/src/test/java/com/plannaplan/controllers/GroupControllerTest.java index aefad82..756f046 100755 --- a/restservice/src/test/java/com/plannaplan/controllers/GroupControllerTest.java +++ b/restservice/src/test/java/com/plannaplan/controllers/GroupControllerTest.java @@ -14,18 +14,19 @@ import static org.springframework.test.web.servlet.result.MockMvcResultMatchers. @RunWith(SpringRunner.class) @SpringBootTest @ContextConfiguration + public class GroupControllerTest extends AbstractControllerTest { - private static final String GROUPS_BY_COURSE_ENDPOINT = "/api/v1/groups/getCourseGroups"; + private static final String GROUPS_BY_COURSE_ENDPOINT = "/api/v1/groups/course"; @Test public void shouldFailWithNoParaeter() throws Exception { MockMvc mockMvc = MockMvcBuilders.webAppContextSetup(webApplicationContext).build(); - mockMvc.perform(get(GROUPS_BY_COURSE_ENDPOINT)).andExpect(status().isBadRequest()); + mockMvc.perform(get(GROUPS_BY_COURSE_ENDPOINT)).andExpect(status().isNotFound()); } @Test public void shouldReturnGroupsOk() throws Exception { MockMvc mockMvc = MockMvcBuilders.webAppContextSetup(webApplicationContext).build(); - mockMvc.perform(get(GROUPS_BY_COURSE_ENDPOINT).param("id", "2")).andExpect(status().isOk()); + mockMvc.perform(get(GROUPS_BY_COURSE_ENDPOINT + "/2")).andExpect(status().isOk()); } } diff --git a/restservice/src/test/java/com/plannaplan/controllers/UsersControllerTest.java b/restservice/src/test/java/com/plannaplan/controllers/UsersControllerTest.java index f2771ba..9d4120e 100755 --- a/restservice/src/test/java/com/plannaplan/controllers/UsersControllerTest.java +++ b/restservice/src/test/java/com/plannaplan/controllers/UsersControllerTest.java @@ -20,8 +20,9 @@ import static org.springframework.test.web.servlet.result.MockMvcResultMatchers. @RunWith(SpringRunner.class) @SpringBootTest @ContextConfiguration + public class UsersControllerTest extends AbstractControllerTest { - private static final String ENDPOINT = "/api/v1/users/searchForStudents"; + private static final String ENDPOINT = "/api/v1/users/student/search"; @Autowired private UserService service;