Skip to content
This repository has been archived by the owner on Jul 29, 2021. It is now read-only.

Commit

Permalink
feat(plan): API Publisher can ask for a mandatory comment while consu…
Browse files Browse the repository at this point in the history
…mer is subscribing to the plan

Closes gravitee-io/issues#1660
  • Loading branch information
brasseld authored and NicolasGeraud committed Nov 21, 2018
1 parent fa6fce1 commit d8c597e
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 5 deletions.
2 changes: 1 addition & 1 deletion pom.xml
Expand Up @@ -32,7 +32,7 @@
<name>Gravitee.io APIM - Repository - Test</name>

<properties>
<gravitee-repository.version>1.20.0</gravitee-repository.version>
<gravitee-repository.version>1.21.0-SNAPSHOT</gravitee-repository.version>
<commons-io.version>1.3.2</commons-io.version>
<jackson-mapper-asl.version>1.9.13</jackson-mapper-asl.version>
<javax.inject.version>1</javax.inject.version>
Expand Down
3 changes: 3 additions & 0 deletions src/test/java/io/gravitee/repository/PlanRepositoryTest.java
Expand Up @@ -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
Expand Down Expand Up @@ -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);

Expand All @@ -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
Expand Down
Expand Up @@ -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");
Expand All @@ -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");
Expand All @@ -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\"}");
Expand Down
12 changes: 8 additions & 4 deletions src/test/resources/data/plan-tests/plans.json
Expand Up @@ -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",
Expand All @@ -55,6 +58,7 @@
"updatedAt": 1455235200000,
"excludedGroups": [
"7c546c6b-2f2f-4487-946c-6b2f2f648784"
]
],
"commentRequired": false
}
]

0 comments on commit d8c597e

Please sign in to comment.