forked from apolloconfig/apollo
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Enhancement: validates http parameters using javax.validation api (ap…
…olloconfig#1858) * enhancement: validates http parameters using javax.validation api * improve code quality according Codacity * update as requested * update according to Codacy
- Loading branch information
1 parent
601e366
commit 4dc4035
Showing
25 changed files
with
305 additions
and
119 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
31 changes: 31 additions & 0 deletions
31
...test/java/com/ctrip/framework/apollo/adminservice/controller/NamespaceControllerTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
package com.ctrip.framework.apollo.adminservice.controller; | ||
|
||
import com.ctrip.framework.apollo.common.dto.NamespaceDTO; | ||
import com.ctrip.framework.apollo.common.utils.InputValidator; | ||
import org.junit.Assert; | ||
import org.junit.Test; | ||
import org.springframework.web.client.HttpClientErrorException; | ||
import static org.hamcrest.Matchers.containsString; | ||
|
||
/** | ||
* Created by kezhenxu at 2019/1/8 16:27. | ||
* | ||
* @author kezhenxu ([email protected]) | ||
*/ | ||
public class NamespaceControllerTest extends AbstractControllerTest { | ||
@Test | ||
public void create() { | ||
try { | ||
NamespaceDTO namespaceDTO = new NamespaceDTO(); | ||
namespaceDTO.setClusterName("cluster"); | ||
namespaceDTO.setNamespaceName("invalid name"); | ||
namespaceDTO.setAppId("whatever"); | ||
restTemplate.postForEntity( | ||
url("/apps/{appId}/clusters/{clusterName}/namespaces"), | ||
namespaceDTO, NamespaceDTO.class, namespaceDTO.getAppId(), namespaceDTO.getClusterName()); | ||
Assert.fail("Should throw"); | ||
} catch (HttpClientErrorException e) { | ||
Assert.assertThat(new String(e.getResponseBodyAsByteArray()), containsString(InputValidator.INVALID_CLUSTER_NAMESPACE_MESSAGE)); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
7 changes: 7 additions & 0 deletions
7
apollo-common/src/main/java/com/ctrip/framework/apollo/common/dto/AppDTO.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
10 changes: 10 additions & 0 deletions
10
apollo-common/src/main/java/com/ctrip/framework/apollo/common/dto/ClusterDTO.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
9 changes: 8 additions & 1 deletion
9
apollo-common/src/main/java/com/ctrip/framework/apollo/common/dto/NamespaceDTO.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.