Skip to content
Permalink
Browse files

feat: Allows to define manual rules for the reviewer which will affec…

…t the API quality

fix gravitee-io/issues#2601
  • Loading branch information
aelamrani authored and brasseld committed Sep 27, 2019
1 parent e6f63c3 commit 8dffcda4d567332dc5b36d8b9c9ec9ef0c610cd4
Showing with 1,992 additions and 22 deletions.
  1. +2 −1 ...ee-management-api-model/src/main/java/io/gravitee/management/model/permissions/ApiPermission.java
  2. +2 −1 ...gement-api-model/src/main/java/io/gravitee/management/model/permissions/ManagementPermission.java
  3. +2 −0 ...e-management-api-model/src/main/java/io/gravitee/management/model/permissions/RolePermission.java
  4. +102 −0 ...management-api-model/src/main/java/io/gravitee/management/model/quality/ApiQualityRuleEntity.java
  5. +81 −0 ...agement-api-model/src/main/java/io/gravitee/management/model/quality/NewApiQualityRuleEntity.java
  6. +76 −0 ...management-api-model/src/main/java/io/gravitee/management/model/quality/NewQualityRuleEntity.java
  7. +110 −0 ...ee-management-api-model/src/main/java/io/gravitee/management/model/quality/QualityRuleEntity.java
  8. +79 −0 ...ment-api-model/src/main/java/io/gravitee/management/model/quality/UpdateApiQualityRuleEntity.java
  9. +94 −0 ...agement-api-model/src/main/java/io/gravitee/management/model/quality/UpdateQualityRuleEntity.java
  10. +72 −0 ...pository/src/main/java/io/gravitee/management/repository/proxy/ApiQualityRuleRepositoryProxy.java
  11. +58 −0 ...-repository/src/main/java/io/gravitee/management/repository/proxy/QualityRuleRepositoryProxy.java
  12. +89 −0 ...nagement-api-rest/src/main/java/io/gravitee/management/rest/resource/ApiQualityRulesResource.java
  13. +5 −0 gravitee-management-api-rest/src/main/java/io/gravitee/management/rest/resource/ApiResource.java
  14. +6 −0 ...management-api-rest/src/main/java/io/gravitee/management/rest/resource/ConfigurationResource.java
  15. +75 −0 ...ment-api-rest/src/main/java/io/gravitee/management/rest/resource/quality/QualityRuleResource.java
  16. +74 −0 ...ent-api-rest/src/main/java/io/gravitee/management/rest/resource/quality/QualityRulesResource.java
  17. +32 −0 ...ee-management-api-service/src/main/java/io/gravitee/management/service/ApiQualityRuleService.java
  18. +34 −0 gravitee-management-api-service/src/main/java/io/gravitee/management/service/QualityRuleService.java
  19. +43 −0 ...src/main/java/io/gravitee/management/service/exceptions/ApiQualityRuleAlreadyExistsException.java
  20. +36 −0 ...vice/src/main/java/io/gravitee/management/service/exceptions/ApiQualityRuleNotFoundException.java
  21. +34 −0 ...service/src/main/java/io/gravitee/management/service/exceptions/QualityRuleNotFoundException.java
  22. +147 −0 ...ment-api-service/src/main/java/io/gravitee/management/service/impl/ApiQualityRuleServiceImpl.java
  23. +5 −1 ...itee-management-api-service/src/main/java/io/gravitee/management/service/impl/ApiServiceImpl.java
  24. +35 −6 ...ment-api-service/src/main/java/io/gravitee/management/service/impl/QualityMetricsServiceImpl.java
  25. +180 −0 ...agement-api-service/src/main/java/io/gravitee/management/service/impl/QualityRuleServiceImpl.java
  26. +181 −0 ...anagement-api-service/src/test/java/io/gravitee/management/service/ApiQualityRuleServiceTest.java
  27. +7 −1 ...ee-management-api-service/src/test/java/io/gravitee/management/service/ApiService_DeleteTest.java
  28. +76 −8 ...anagement/service/{QualityMetricsService_GetApiMetricsTest.java → QualityMetricsServiceTest.java}
  29. +251 −0 ...e-management-api-service/src/test/java/io/gravitee/management/service/QualityRuleServiceTest.java
  30. +3 −3 ...rvice/src/test/java/io/gravitee/management/service/RoleService_CreateOrUpdateSystemRolesTest.java
  31. +1 −1 pom.xml
@@ -40,7 +40,8 @@
MESSAGE( "MESSAGE", 2600),
ALERT( "ALERT", 2700),
RESPONSE_TEMPLATES( "RESPONSE_TEMPLATES", 2800),
REVIEWS( "REVIEWS", 2900);
REVIEWS( "REVIEWS", 2900),
QUALITY_RULE( "QUALITY_RULE", 3000);

String name;
int mask;
@@ -35,7 +35,8 @@
DICTIONARY ("DICTIONARY", 2300),
ALERT ("ALERT", 2400),
ENTRYPOINT ("ENTRYPOINT", 2500),
SETTINGS ("SETTINGS", 2600);
SETTINGS ("SETTINGS", 2600),
QUALITY_RULE("QUALITY_RULE", 2800);

String name;
int mask;
@@ -36,6 +36,7 @@
MANAGEMENT_ALERT (RoleScope.MANAGEMENT, ManagementPermission.ALERT),
MANAGEMENT_ENTRYPOINT (RoleScope.MANAGEMENT, ManagementPermission.ENTRYPOINT),
MANAGEMENT_SETTINGS (RoleScope.MANAGEMENT, ManagementPermission.SETTINGS),
MANAGEMENT_QUALITY_RULE (RoleScope.MANAGEMENT, ManagementPermission.QUALITY_RULE),

PORTAL_METADATA (RoleScope.PORTAL, PortalPermission.METADATA),
PORTAL_DOCUMENTATION (RoleScope.PORTAL, PortalPermission.DOCUMENTATION),
@@ -66,6 +67,7 @@
API_ALERT (RoleScope.API, ApiPermission.ALERT),
API_RESPONSE_TEMPLATES (RoleScope.API, ApiPermission.RESPONSE_TEMPLATES),
API_REVIEWS (RoleScope.API, ApiPermission.REVIEWS),
API_QUALITY_RULE (RoleScope.API, ApiPermission.QUALITY_RULE),

APPLICATION_DEFINITION (RoleScope.APPLICATION, ApplicationPermission.DEFINITION),
APPLICATION_MEMBER (RoleScope.APPLICATION, ApplicationPermission.MEMBER),
@@ -0,0 +1,102 @@
/**
* Copyright (C) 2015 The Gravitee team (http://gravitee.io)
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package io.gravitee.management.model.quality;

import com.fasterxml.jackson.annotation.JsonProperty;

import java.util.Date;
import java.util.Objects;

/**
* @author Azize ELAMRANI (azize.elamrani at graviteesource.com)
* @author GraviteeSource Team
*/
public class ApiQualityRuleEntity {

private String api;
@JsonProperty("quality_rule")
private String qualityRule;
private boolean checked;
@JsonProperty("created_at")
private Date createdAt;
@JsonProperty("updated_at")
private Date updatedAt;

public String getApi() {
return api;
}

public void setApi(String api) {
this.api = api;
}

public String getQualityRule() {
return qualityRule;
}

public void setQualityRule(String qualityRule) {
this.qualityRule = qualityRule;
}

public boolean isChecked() {
return checked;
}

public void setChecked(boolean checked) {
this.checked = checked;
}

public Date getCreatedAt() {
return createdAt;
}

public void setCreatedAt(Date createdAt) {
this.createdAt = createdAt;
}

public Date getUpdatedAt() {
return updatedAt;
}

public void setUpdatedAt(Date updatedAt) {
this.updatedAt = updatedAt;
}

@Override
public boolean equals(Object o) {
if (this == o) return true;
if (o == null || getClass() != o.getClass()) return false;
ApiQualityRuleEntity that = (ApiQualityRuleEntity) o;
return Objects.equals(api, that.api) &&
Objects.equals(qualityRule, that.qualityRule);
}

@Override
public int hashCode() {
return Objects.hash(api, qualityRule);
}

@Override
public String toString() {
return "ApiQualityRuleEntity{" +
"api='" + api + '\'' +
", qualityRule='" + qualityRule + '\'' +
", checked=" + checked +
", createdAt=" + createdAt +
", updatedAt=" + updatedAt +
'}';
}
}
@@ -0,0 +1,81 @@
/**
* Copyright (C) 2015 The Gravitee team (http://gravitee.io)
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package io.gravitee.management.model.quality;

import com.fasterxml.jackson.annotation.JsonProperty;

import javax.validation.constraints.Max;
import javax.validation.constraints.Min;
import java.util.Objects;

/**
* @author Azize ELAMRANI (azize.elamrani at graviteesource.com)
* @author GraviteeSource Team
*/
public class NewApiQualityRuleEntity {

private String api;
@JsonProperty("quality_rule")
private String qualityRule;
private boolean checked;

public String getApi() {
return api;
}

public void setApi(String api) {
this.api = api;
}

public String getQualityRule() {
return qualityRule;
}

public void setQualityRule(String qualityRule) {
this.qualityRule = qualityRule;
}

public boolean isChecked() {
return checked;
}

public void setChecked(boolean checked) {
this.checked = checked;
}

@Override
public boolean equals(Object o) {
if (this == o) return true;
if (o == null || getClass() != o.getClass()) return false;
NewApiQualityRuleEntity that = (NewApiQualityRuleEntity) o;
return Objects.equals(api, that.api) &&
Objects.equals(qualityRule, that.qualityRule);
}

@Override
public int hashCode() {
return Objects.hash(api, qualityRule);
}

@Override
public String toString() {
return "NewApiQualityRuleEntity{" +
"api='" + api + '\'' +
", qualityRule='" + qualityRule + '\'' +
", checked=" + checked +
'}';
}
}
@@ -0,0 +1,76 @@
/**
* Copyright (C) 2015 The Gravitee team (http://gravitee.io)
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package io.gravitee.management.model.quality;

import javax.validation.constraints.Max;
import javax.validation.constraints.Min;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Size;
import java.util.Objects;

/**
* @author Azize ELAMRANI (azize.elamrani at graviteesource.com)
* @author GraviteeSource Team
*/
public class NewQualityRuleEntity {

@NotNull
@Size(max = 64)
private String name;
@NotNull
@Size(max = 256)
private String description;
@Min(0)
@Max(99999)
private int weight;

public String getName() {
return name;
}

public void setName(String name) {
this.name = name;
}

public String getDescription() {
return description;
}

public void setDescription(String description) {
this.description = description;
}

public int getWeight() {
return weight;
}

public void setWeight(int weight) {
this.weight = weight;
}

@Override
public boolean equals(Object o) {
if (this == o) return true;
if (o == null || getClass() != o.getClass()) return false;
NewQualityRuleEntity that = (NewQualityRuleEntity) o;
return Objects.equals(name, that.name);
}

@Override
public int hashCode() {
return Objects.hash(name);
}
}

0 comments on commit 8dffcda

Please sign in to comment.
You can’t perform that action at this time.