Skip to content

Commit

Permalink
restdocs: adds spring-rest-docs
Browse files Browse the repository at this point in the history
This commit introduces the spring-rest-docs support.
All EventController endpoinds are documented and generated snippets are pushed to a "doc-snippets" branch that can be used in the reactivity-doc project.
Currently unit tests are mixing MockMvc with webflux module, which works even if a more adapted support for webflux tests has to be considered.
  • Loading branch information
gdrouet committed Mar 7, 2017
1 parent bcb6c0f commit 7e92d0a
Show file tree
Hide file tree
Showing 7 changed files with 416 additions and 12 deletions.
4 changes: 3 additions & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ env:
- MODULE=core/broadcaster
global:
- NODEJS_VERSION: 6.10.0
- ENCRYPTION_LABEL: "094e2d6354aa"
- COMMIT_AUTHOR_EMAIL: "[email protected]"
- secure: jyieF62Bdxn8KzePW73qAWOsV6n83gIGDpKGpgbpbCDG+R5AcMqFSXf32A7So148YczZIjlhWUx85Vrol9NURpimxcFfZU9nKCPjZt7QpGuzXInbxy8Qrze1I/PN40nMVGxNEam7pwXIMZwbOFPv/PG+fDw7BCDSfsoTwTMbk1FvjhpBngo6DBtbyld30HEhIVSSLhROgcQ7zzcfHYdu9IxvnDFnuNict1m1+HGJf0jDAbFRzGteMq7/tu+rM9HHd5UyCSI2sGWo4P3tAcXw/l3VV/MxhG6cRofvQQEY7H+2JpJ5U6CDprrN7sOUrc777cmOzXzB1sYLaNNniQiScQtZJTYcJbhPF/rOYn8FjrFDMxC0EB7oQQ58Z4dUViKNAdR54zxFwm/OqDssAV43fAOFfkiZGfdKjR+CQQMWRD7UdaCfsy3w/xFw5KiNObyUtvbBJABVYWjsIIF0yU20Qu8Cr5DCfUjUTyNiWz/LjN3cQjtv6HB7A3UWc/ohjhU/GZoWvvJ5WySKLMuL8msH5/R3UE+u8TZYTi9pSG/k6BSoVO4DRAmvG/7FdepwHJYnW1Ol1Bd2u0OdqiwhByu0yDH9jolJ/VYBq8A880nU+dW5SVhwTNSvLgo3jclr4IwkCydZvZ6YjiqpKSqW69TRWyPLOFVLtn943yFX89OXhwY=
- secure: Y0Ck+5ZLdbv2qC5uySGZZmuU1++fBvLOtUquAiFn4IPXzaMTbURqr0jY6+R/ibiJdnTgKk4H65Gl4S2d2UPSVTeIUoxnzSSiUHhoxp1FUrGuK8wxuk0ZMffRIMWODRxLJsuFKXTt7NpwGmDx53Kzzp0cbMo9ilkVFJu+6PBxmTC2lRZwIeHFo4U56DjNwWaHA3dXwfiv1S6tsfem3kxGHb9SsfN4UGyXTRqKZBK+DwEs07Uwwq6FkCqsSzcV42uTx2t9qRrVbs3elIPdNKIitEE/V+juQTg94c3BHspXHZhgExByAm/2SSOZaE2syyrFGPSPRf1XKbzwkiGCJiCWzT8naOZB8CC6V4QxDwbrh6nU9lH2BQdcDZj9/pcT6HPc8nhoBKwl4Rzpnsva4b70cZE57KaRwiDQ4lUvFPJ3YepPiz0QKNnEPYHAbLFIMBvsVcMGGkKg4aMSiBfCXu62PTAAqUNQJKRVEIpYAs6AHE3IUUsh+gZ24yWddEHRE3mUvi3vIYnNUjlt0e9fTqfitl1wMV68CZb5llm19jLYFZ0uX54d0xkCtdmNWBvZBip4lVpuR/qQYgLp2LOiEqgzFNLg4x6DxRabUAZ0tP/daIQ2WBBTXKIkxCk2Am/xwFCyz9Bzb97DTSUjvdtI++bGd1nn6LN8AZ01RhO4I5Rff/0=
before_install:
Expand All @@ -22,7 +24,7 @@ before_install:
- 'if [ "$MODULE" = "core/broadcaster" ]; then ./script/install-couchbase.sh; fi'
script:
- mvn -f $MODULE/pom.xml clean deploy
- 'if [ "$MODULE" = "core/broadcaster" ]; then ./script/front-end.sh; fi'
- 'if [ "$MODULE" = "core/broadcaster" ]; then ./script/publish-doc-snippets.sh; ./script/front-end.sh; fi'
after_script:
- 'if [ "$MODULE" = "core/broadcaster" ]; then ./script/stop-app.sh; fi'
deploy:
Expand Down
9 changes: 8 additions & 1 deletion core/broadcaster/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
<spring-boot-dependencies.version>2.0.0.BUILD-SNAPSHOT</spring-boot-dependencies.version>
<spring-web-reactive.version>0.1.0.BUILD-SNAPSHOT</spring-web-reactive.version>
<reactive-streams-common.version>0.6.0.BUILD-SNAPSHOT</reactive-streams-common.version>
<maven-resources-plugin.version>2.7</maven-resources-plugin.version>
</properties>

<dependencyManagement>
Expand Down Expand Up @@ -105,13 +106,19 @@
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>

<dependency>
<groupId>org.springframework.restdocs</groupId>
<artifactId>spring-restdocs-mockmvc</artifactId>
<scope>test</scope>
</dependency>

<dependency>
<groupId>org.springframework.security</groupId>
<artifactId>spring-security-core</artifactId>
</dependency>

<dependency>
<groupId>org.springframework.session</groupId>
<artifactId>spring-session</artifactId>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* The MIT License (MIT) Copyright (c) 2017 The reactivity authors
* The MIT License (MIT) Copyright (c) 2016 The reactivity authors
*
* Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated
* documentation files (the "Software"), to deal in the Software without restriction, including without limitation the
Expand All @@ -20,16 +20,13 @@

import io.reactivity.core.broadcaster.service.EventService;
import io.reactivity.core.broadcaster.session.ReactivitySessionScope;
import io.reactivity.core.lib.event.Event;
import io.reactivity.core.lib.event.Organization;
import io.reactivity.core.lib.ReactivityEntity;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Scope;
import org.springframework.security.core.Authentication;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RestController;
import reactor.core.publisher.Flux;

/**
* <p>
Expand Down Expand Up @@ -59,7 +56,7 @@ public class EventController {
* </p>
*
* @param eventService the event service
* @param authentication the current authentication
* @param authentication the authentication
*/
@Autowired
public EventController(final EventService eventService, final Authentication authentication) {
Expand All @@ -78,7 +75,7 @@ public EventController(final EventService eventService, final Authentication aut
* @return the event flux
*/
@GetMapping("/load/artifacts/{viewId}/limit/{limit}/maxage/{maxAge}")
Flux<Event<ReactivityEntity>> loadArtifactsLteMaxAge(
public Object loadArtifactsLteMaxAge(
@PathVariable(name = "viewId") final String viewId,
@PathVariable(name = "limit") final int limit,
@PathVariable(name = "maxAge") final long maxAge) {
Expand All @@ -96,7 +93,7 @@ Flux<Event<ReactivityEntity>> loadArtifactsLteMaxAge(
* @return the event flux
*/
@GetMapping("/load/artifacts/{viewId}/limit/{limit}/minage/{minAge}")
Flux<Event<ReactivityEntity>> loadArtifactsGteMinAge(
public Object loadArtifactsGteMinAge(
@PathVariable(name = "viewId") final String viewId,
@PathVariable(name = "limit") final int limit,
@PathVariable(name = "minAge") final long minAge) {
Expand All @@ -111,7 +108,7 @@ Flux<Event<ReactivityEntity>> loadArtifactsGteMinAge(
* @return the organization event flux
*/
@GetMapping("/load/organizations")
public Flux<Event<ReactivityEntity>> loadOrganizations() {
public Object loadOrganizations() {
// Retrieve the organizations: member ID can be an arbitrary value as it is currently mocked
return eventService.loadOrganizations(authentication.getName());
}
Expand All @@ -125,7 +122,7 @@ public Flux<Event<ReactivityEntity>> loadOrganizations() {
* @return the event flux
*/
@GetMapping("/subscribe/{organizationId}")
Flux<Event<ReactivityEntity>> subscribe(@PathVariable(name = "organizationId") final String organizationId) {
public Object subscribe(@PathVariable(name = "organizationId") final String organizationId) {
return eventService.subscribe(organizationId);
}
}
Loading

0 comments on commit 7e92d0a

Please sign in to comment.