From d8c597ec5967ba17fb0ebf7cbfa59372133fc547 Mon Sep 17 00:00:00 2001 From: brasseld Date: Wed, 14 Nov 2018 09:36:30 +0100 Subject: [PATCH] feat(plan): API Publisher can ask for a mandatory comment while consumer is subscribing to the plan Closes gravitee-io/issues#1660 --- pom.xml | 2 +- .../io/gravitee/repository/PlanRepositoryTest.java | 3 +++ .../config/MockTestRepositoryConfiguration.java | 3 +++ src/test/resources/data/plan-tests/plans.json | 12 ++++++++---- 4 files changed, 15 insertions(+), 5 deletions(-) diff --git a/pom.xml b/pom.xml index ef20da8b..3b4c1499 100644 --- a/pom.xml +++ b/pom.xml @@ -32,7 +32,7 @@ Gravitee.io APIM - Repository - Test - 1.20.0 + 1.21.0-SNAPSHOT 1.3.2 1.9.13 1 diff --git a/src/test/java/io/gravitee/repository/PlanRepositoryTest.java b/src/test/java/io/gravitee/repository/PlanRepositoryTest.java index 7004b574..062403e7 100644 --- a/src/test/java/io/gravitee/repository/PlanRepositoryTest.java +++ b/src/test/java/io/gravitee/repository/PlanRepositoryTest.java @@ -59,6 +59,7 @@ public void shouldFindById() throws Exception { assertEquals(new Date(1507611600000L), plan.get().getClosedAt()); assertEquals(Arrays.asList("charac 1", "charac 2"), plan.get().getCharacteristics()); assertEquals("grp1", plan.get().getExcludedGroups().get(0)); + assertTrue(plan.get().isCommentRequired()); } @Test @@ -158,6 +159,7 @@ public void shouldCreateOAuth2Plan() throws Exception { plan.setClosedAt(parse("14/02/2016")); plan.setSecurity(Plan.PlanSecurityType.OAUTH2); plan.setSecurityDefinition("{\"extractPayload\":false,\"checkRequiredScopes\":false,\"requiredScopes\":[],\"oauthResource\":\"OAuth\"}"); + plan.setCommentRequired(true); planRepository.create(plan); @@ -177,6 +179,7 @@ public void shouldCreateOAuth2Plan() throws Exception { Assert.assertEquals("Invalid oauth2 plan closed date.", plan.getClosedAt(), createdPlan.getClosedAt()); Assert.assertEquals("Invalid oauth2 plan security.", plan.getSecurity(), createdPlan.getSecurity()); Assert.assertEquals("Invalid oauth2 plan security definition.", plan.getSecurityDefinition(), createdPlan.getSecurityDefinition()); + Assert.assertEquals("Invalid oauth2 plan comment required.", plan.isCommentRequired(), createdPlan.isCommentRequired()); } @Test diff --git a/src/test/java/io/gravitee/repository/config/MockTestRepositoryConfiguration.java b/src/test/java/io/gravitee/repository/config/MockTestRepositoryConfiguration.java index b22a46a9..1c5cc1e6 100644 --- a/src/test/java/io/gravitee/repository/config/MockTestRepositoryConfiguration.java +++ b/src/test/java/io/gravitee/repository/config/MockTestRepositoryConfiguration.java @@ -792,6 +792,7 @@ public PlanRepository planRepository() throws Exception { when(plan2.getClosedAt()).thenReturn(new Date(1507611600000L)); when(plan2.getCharacteristics()).thenReturn(asList("charac 1", "charac 2")); when(plan2.getExcludedGroups()).thenReturn(singletonList("grp1")); + when(plan2.isCommentRequired()).thenReturn(true); final Plan planOAuth2 = mock(Plan.class); when(planOAuth2.getName()).thenReturn("Plan oauth2 name"); @@ -806,6 +807,7 @@ public PlanRepository planRepository() throws Exception { when(planOAuth2.getStatus()).thenReturn(Plan.Status.STAGING); when(planOAuth2.getSecurity()).thenReturn(Plan.PlanSecurityType.OAUTH2); when(planOAuth2.getSecurityDefinition()).thenReturn("{\"extractPayload\":false,\"checkRequiredScopes\":false,\"requiredScopes\":[],\"oauthResource\":\"OAuth\"}"); + when(planOAuth2.isCommentRequired()).thenReturn(true); final Plan createdPlanOAuth2 = mock(Plan.class); when(createdPlanOAuth2.getId()).thenReturn("plan-oauth2"); @@ -818,6 +820,7 @@ public PlanRepository planRepository() throws Exception { when(createdPlanOAuth2.getUpdatedAt()).thenReturn(parse("12/02/2016")); when(createdPlanOAuth2.getStatus()).thenReturn(Plan.Status.STAGING); when(createdPlanOAuth2.getOrder()).thenReturn(0); + when(createdPlanOAuth2.isCommentRequired()).thenReturn(true); when(createdPlanOAuth2.getExcludedGroups()).thenReturn(singletonList("7c546c6b-2f2f-4487-946c-6b2f2f648784")); when(createdPlanOAuth2.getSecurity()).thenReturn(Plan.PlanSecurityType.OAUTH2); when(createdPlanOAuth2.getSecurityDefinition()).thenReturn("{\"extractPayload\":false,\"checkRequiredScopes\":false,\"requiredScopes\":[],\"oauthResource\":\"OAuth\"}"); diff --git a/src/test/resources/data/plan-tests/plans.json b/src/test/resources/data/plan-tests/plans.json index 661ef436..dfab677b 100644 --- a/src/test/resources/data/plan-tests/plans.json +++ b/src/test/resources/data/plan-tests/plans.json @@ -17,18 +17,21 @@ "charac 1", "charac 2" ], - "excludedGroups": [ "grp1" ] + "excludedGroups": [ "grp1" ], + "commentRequired": true }, { "id":"updated-plan", "name":"old plan", - "apis": ["api3"] + "apis": ["api3"], + "commentRequired": true }, { "id":"products", "name":"Products", "description": "Description for products view", - "apis": ["api1"] + "apis": ["api1"], + "commentRequired": false }, { "id":"stores", @@ -55,6 +58,7 @@ "updatedAt": 1455235200000, "excludedGroups": [ "7c546c6b-2f2f-4487-946c-6b2f2f648784" - ] + ], + "commentRequired": false } ]