Search in sources :

Example 1 with NamespaceReleaseDTO

use of com.ctrip.framework.apollo.openapi.dto.NamespaceReleaseDTO in project apollo by ctripcorp.

the class ReleaseOpenApiServiceTest method testPublishNamespace.

@Test
public void testPublishNamespace() throws Exception {
    String someReleaseTitle = "someReleaseTitle";
    String someReleasedBy = "someReleasedBy";
    NamespaceReleaseDTO namespaceReleaseDTO = new NamespaceReleaseDTO();
    namespaceReleaseDTO.setReleaseTitle(someReleaseTitle);
    namespaceReleaseDTO.setReleasedBy(someReleasedBy);
    final ArgumentCaptor<HttpPost> request = ArgumentCaptor.forClass(HttpPost.class);
    releaseOpenApiService.publishNamespace(someAppId, someEnv, someCluster, someNamespace, namespaceReleaseDTO);
    verify(httpClient, times(1)).execute(request.capture());
    HttpPost post = request.getValue();
    assertEquals(String.format("%s/envs/%s/apps/%s/clusters/%s/namespaces/%s/releases", someBaseUrl, someEnv, someAppId, someCluster, someNamespace), post.getURI().toString());
}
Also used : HttpPost(org.apache.http.client.methods.HttpPost) NamespaceReleaseDTO(com.ctrip.framework.apollo.openapi.dto.NamespaceReleaseDTO) Test(org.junit.Test)

Example 2 with NamespaceReleaseDTO

use of com.ctrip.framework.apollo.openapi.dto.NamespaceReleaseDTO in project apollo by ctripcorp.

the class ReleaseController method merge.

@PreAuthorize(value = "@consumerPermissionValidator.hasReleaseNamespacePermission(#request, #appId, #namespaceName, #env)")
@PostMapping(value = "/apps/{appId}/clusters/{clusterName}/namespaces/{namespaceName}/branches/{branchName}/merge")
public OpenReleaseDTO merge(@PathVariable String appId, @PathVariable String env, @PathVariable String clusterName, @PathVariable String namespaceName, @PathVariable String branchName, @RequestParam(value = "deleteBranch", defaultValue = "true") boolean deleteBranch, @RequestBody NamespaceReleaseDTO model, HttpServletRequest request) {
    RequestPrecondition.checkArguments(!StringUtils.isContainEmpty(model.getReleasedBy(), model.getReleaseTitle()), "Params(releaseTitle and releasedBy) can not be empty");
    if (userService.findByUserId(model.getReleasedBy()) == null) {
        throw new BadRequestException("user(releaseBy) not exists");
    }
    ReleaseDTO mergedRelease = namespaceBranchService.merge(appId, Env.valueOf(env.toUpperCase()), clusterName, namespaceName, branchName, model.getReleaseTitle(), model.getReleaseComment(), model.isEmergencyPublish(), deleteBranch, model.getReleasedBy());
    return OpenApiBeanUtils.transformFromReleaseDTO(mergedRelease);
}
Also used : BadRequestException(com.ctrip.framework.apollo.common.exception.BadRequestException) ReleaseDTO(com.ctrip.framework.apollo.common.dto.ReleaseDTO) OpenReleaseDTO(com.ctrip.framework.apollo.openapi.dto.OpenReleaseDTO) NamespaceGrayDelReleaseDTO(com.ctrip.framework.apollo.openapi.dto.NamespaceGrayDelReleaseDTO) NamespaceReleaseDTO(com.ctrip.framework.apollo.openapi.dto.NamespaceReleaseDTO) PostMapping(org.springframework.web.bind.annotation.PostMapping) PreAuthorize(org.springframework.security.access.prepost.PreAuthorize)

Example 3 with NamespaceReleaseDTO

use of com.ctrip.framework.apollo.openapi.dto.NamespaceReleaseDTO in project apollo by ctripcorp.

the class ReleaseOpenApiServiceTest method testPublishNamespaceWithError.

@Test(expected = RuntimeException.class)
public void testPublishNamespaceWithError() throws Exception {
    String someReleaseTitle = "someReleaseTitle";
    String someReleasedBy = "someReleasedBy";
    NamespaceReleaseDTO namespaceReleaseDTO = new NamespaceReleaseDTO();
    namespaceReleaseDTO.setReleaseTitle(someReleaseTitle);
    namespaceReleaseDTO.setReleasedBy(someReleasedBy);
    when(statusLine.getStatusCode()).thenReturn(400);
    releaseOpenApiService.publishNamespace(someAppId, someEnv, someCluster, someNamespace, namespaceReleaseDTO);
}
Also used : NamespaceReleaseDTO(com.ctrip.framework.apollo.openapi.dto.NamespaceReleaseDTO) Test(org.junit.Test)

Aggregations

NamespaceReleaseDTO (com.ctrip.framework.apollo.openapi.dto.NamespaceReleaseDTO)3 Test (org.junit.Test)2 ReleaseDTO (com.ctrip.framework.apollo.common.dto.ReleaseDTO)1 BadRequestException (com.ctrip.framework.apollo.common.exception.BadRequestException)1 NamespaceGrayDelReleaseDTO (com.ctrip.framework.apollo.openapi.dto.NamespaceGrayDelReleaseDTO)1 OpenReleaseDTO (com.ctrip.framework.apollo.openapi.dto.OpenReleaseDTO)1 HttpPost (org.apache.http.client.methods.HttpPost)1 PreAuthorize (org.springframework.security.access.prepost.PreAuthorize)1 PostMapping (org.springframework.web.bind.annotation.PostMapping)1