类javax.ws.rs.BadRequestException源码实例Demo

下面列出了怎么用javax.ws.rs.BadRequestException的API类实例代码及写法,或者点击链接到github查看源代码。

public Credential initCodeGrantFlow(Credential credential, String accountId, String userId) {
    CloudContext cloudContext = new CloudContext(credential.getId(), credential.getName(),
            credential.getCloudPlatform(), userId, accountId);
    CloudCredential cloudCredential = credentialConverter.convert(credential);
    LOGGER.debug("Requesting code grant flow cloudPlatform {} and creator {}.", credential.getCloudPlatform(), userId);
    InitCodeGrantFlowRequest request = requestProvider.getInitCodeGrantFlowRequest(cloudContext, cloudCredential);
    LOGGER.info("Triggering event: {}", request);
    eventBus.notify(request.selector(), eventFactory.createEvent(request));
    try {
        InitCodeGrantFlowResponse res = request.await();
        LOGGER.info("Result: {}", res);
        if (res.getStatus() != EventStatus.OK) {
            String message = "Authorization code grant based credential creation couldn't be initialized: ";
            LOGGER.error(message, res.getErrorDetails());
            throw new BadRequestException(message + res.getErrorDetails(), res.getErrorDetails());
        }
        Map<String, String> codeGrantFlowInitParams = res.getCodeGrantFlowInitParams();
        addCodeGrantFlowInitAttributesToCredential(credential, codeGrantFlowInitParams);
        return credential;
    } catch (InterruptedException e) {
        LOGGER.error("Error while executing initialization of authorization code grant based credential creation:", e);
        throw new OperationException(e);
    }
}
 
源代码2 项目: Web-API   文件: WorldParamConverter.java
@Override
public CachedWorld fromString(String value) {
    // If we didn't request a world don't try to find one
    if (value == null)
        return null;

    if (!Util.isValidUUID(value))
        throw new BadRequestException("Invalid world uuid");

    CacheService srv = WebAPI.getCacheService();

    Optional<CachedWorld> optWorld = srv.getWorld(UUID.fromString(value));
    if (!optWorld.isPresent())
        throw new NotFoundException("Could not find world with uuid " + value);
    return optWorld.get();
}
 
源代码3 项目: cloudbreak   文件: ClusterTemplateTest.java
@Test(dataProvider = TEST_CONTEXT_WITH_MOCK)
@Description(
        given = "there is a running cloudbreak",
        when = "a cluster template create request with null environment name is sent",
        then = "the cluster template is cannot be created"
)
public void testCreateClusterTemplateWithoutEnvironmentName(TestContext testContext) {
    String generatedKey = resourcePropertyProvider().getName();

    testContext.given(DistroXTemplateTestDto.class)
            .withEnvironmentName(null)
            .given(ClusterTemplateTestDto.class)
            .withDistroXTemplate()
            .when(clusterTemplateTestClient.createV4(), RunningParameter.key(generatedKey))
            .expect(BadRequestException.class, RunningParameter.key(generatedKey)
                    .withExpectedMessage("The environmentName cannot be null."))
            .validate();
}
 
源代码4 项目: cloudbreak   文件: ProviderParameterCalculator.java
private Mappable getMappable(ProviderParametersBase source, CloudPlatform cloudPlatform) {
    switch (cloudPlatform) {
        case AWS:
            return source.createAws();
        case GCP:
            return source.createGcp();
        case MOCK:
            return source.createMock();
        case YARN:
            return source.createYarn();
        case AZURE:
            return source.createAzure();
        case OPENSTACK:
            return source.createOpenstack();
        default:
            throw new BadRequestException(format("No mappable for cloudplatform [%s] and source [%s]", cloudPlatform, source.getClass()));
    }
}
 
源代码5 项目: cloudbreak   文件: AlertController.java
private void validateAlertForUpdate(Cluster cluster, Long alertId, AlertType alertType) {
    Optional alert;
    switch (alertType) {
        case LOAD:
            alert = cluster.getLoadAlerts().stream().map(LoadAlert::getId)
                    .filter(loadAlertId -> loadAlertId.equals(alertId))
                    .findAny();
            break;
        case TIME:
            alert = cluster.getTimeAlerts().stream().map(TimeAlert::getId)
                    .filter(timeAlertId -> timeAlertId.equals(alertId))
                    .findAny();
            break;

        default:
            //Prometheus and Metrics Alerts not supported.
            throw new BadRequestException(messagesService
                    .getMessage(MessageCode.UNSUPPORTED_AUTOSCALING_TYPE, List.of(alertType, cluster.getStackName())));
    }

    if (alert.isEmpty()) {
        throw new NotFoundException(
                messagesService.getMessage(MessageCode.AUTOSCALING_CONFIG_NOT_FOUND, List.of(alertType, alertId, cluster.getStackName())));
    }
}
 
@Test
public void testLdapCapabilities() {

    // Query the rootDSE success
    TestLdapConnectionRepresentation config = new TestLdapConnectionRepresentation(
        LDAPServerCapabilitiesManager.QUERY_SERVER_CAPABILITIES, "ldap://localhost:10389", "uid=admin,ou=system", "secret",
        "false", null, "false", LDAPConstants.AUTH_TYPE_SIMPLE);

    List<LDAPCapabilityRepresentation> ldapCapabilities = realm.ldapServerCapabilities(config);
    Assert.assertThat(ldapCapabilities, Matchers.hasItem(new LDAPCapabilityRepresentation(PasswordModifyRequest.PASSWORD_MODIFY_OID, LDAPCapabilityRepresentation.CapabilityType.EXTENSION)));

    // Query the rootDSE failure
    try {
        config = new TestLdapConnectionRepresentation(
                LDAPServerCapabilitiesManager.QUERY_SERVER_CAPABILITIES, "ldap://localhost:10389", "foo", "bar",
                "false", null, "false", LDAPConstants.AUTH_TYPE_SIMPLE);
        realm.ldapServerCapabilities(config);

        Assert.fail("It wasn't expected to successfully sent the request for query capabilities");
    } catch (BadRequestException bre) {
        // Expected
    }
}
 
源代码7 项目: keycloak   文件: ScriptBasedAuthenticatorTest.java
@Test
public void checkIfTurnedOffWithProductProfile() throws InterruptedException {
    ProfileAssume.assumePreviewDisabled();

    HashMap<String, String> params = new HashMap<>();
    params.put("newName", "Copy-of-browser");
    authMgmtResource.copy("browser", params);

    params.put("provider", "auth-script-based");
    try {
        authMgmtResource.addExecution("Copy-of-browser", params);
        Assert.fail("Adding script based authenticator should fail with product profile");
    } catch (BadRequestException ex) {
        //Expected
    }
}
 
@Test
void testEditAuthenticationIfChangedWhenHasValidationError() {
    AuthenticationDto authenticationDto = AuthenticationDto.builder().build();
    EnvironmentEditDto environmentEditDto = EnvironmentEditDto.builder().withAuthentication(authenticationDto).build();
    Environment environment = new Environment();

    ValidationResult validationResult = ValidationResult.builder().error("Error").build();

    when(environmentService.getValidatorService()).thenReturn(validatorService);
    when(validatorService.validateAuthenticationModification(environmentEditDto, environment)).thenReturn(validationResult);

    BadRequestException badRequestException = assertThrows(BadRequestException.class,
            () -> environmentModificationServiceUnderTest.editAuthenticationIfChanged(environmentEditDto, environment));

    assertEquals(badRequestException.getMessage(), "1. Error");
}
 
源代码9 项目: cloudbreak   文件: ImageCatalogTest.java
@Test(dataProvider = TEST_CONTEXT_WITH_MOCK)
@Description(
        given = "image catalog invalid URL but too long name",
        when = "calling create image catalog with that URL and name",
        then = "getting a BadRequestException")
public void testImageCatalogCreationWhenNameIsTooLong(TestContext testContext) {
    String imgCatalogName = resourcePropertyProvider().getName().concat(getLongNameGenerator().stringGenerator(100));

    testContext
            .given(imgCatalogName, ImageCatalogTestDto.class)
            .withName(imgCatalogName)
            .withUrl(IMG_CATALOG_URL)
            .when(imageCatalogTestClient.createV4(), key(imgCatalogName))
            .expect(BadRequestException.class, key(imgCatalogName)
                    .withExpectedMessage(".*The length of the credential's name has to be in range of 5 to 100"))
            .validate();
}
 
源代码10 项目: registry   文件: AvroSchemaRegistryClientTest.java
/**
 * Return true if the schema creation failed as expected
 */
private void testCreate(SchemaRegistryClient client) {
    boolean failedAsExpected = false;
    SchemaMetadata schemaMetadata = new SchemaMetadata.Builder(name).type(type).schemaGroup(group).
            description("description").build();
    try {
        client.registerSchemaMetadata(schemaMetadata);
    } catch (BadRequestException ex) {
        Response resp = ex.getResponse();
        Assert.assertEquals(test + " - http response unexpected", expectedHttpResponse.getStatusCode(), resp.getStatus());
        CatalogResponse catalogResponse = SchemaRegistryClient.readCatalogResponse(resp.readEntity(String.class));
        Assert.assertEquals(test + " - catalog response unexpected",
                            expectedCatalogResponse.getCode(), catalogResponse.getResponseCode());
        failedAsExpected = true;
    }
    Assert.assertTrue(test + " - did not fail as expected", failedAsExpected);
}
 
源代码11 项目: cloudbreak   文件: ProxyConfigTest.java
@Test(dataProvider = TEST_CONTEXT_WITH_MOCK)
@Description(
        given = "an invalid proxy request without port",
        when = "calling create proxy",
        then = "getting back a BadRequestException")
public void testCreateProxyWithoutPort(TestContext testContext) {
    String name = resourcePropertyProvider().getName();
    String key = "noport";
    testContext
            .given(ProxyTestDto.class)
            .withName(name)
            .withDescription(PROXY_DESCRIPTION)
            .withServerHost(PROXY_HOST)
            .withServerPort(null)
            .withServerUser(PROXY_USER)
            .withPassword(PROXY_PASSWORD)
            .withProtocol(HTTP)
            .when(proxyTestClient.create(), key(key))
            .expect(BadRequestException.class,
                    expectedMessage("Server port is required")
                            .withKey(key))
            .validate();
}
 
源代码12 项目: onos   文件: VirtualNetworkWebResourceTest.java
/**
 * Tests adding of a null virtual link using POST via JSON stream.
 */
@Test
public void testPostVirtualLinkNullJsonStream() {
    NetworkId networkId = networkId3;
    replay(mockVnetAdminService);

    WebTarget wt = target();
    try {
        String reqLocation = "vnets/" + networkId.toString() + "/links";
        wt.path(reqLocation)
                .request(MediaType.APPLICATION_JSON_TYPE)
                .post(Entity.json(null), String.class);
        fail("POST of null virtual link did not throw an exception");
    } catch (BadRequestException ex) {
        assertThat(ex.getMessage(), containsString("HTTP 400 Bad Request"));
    }

    verify(mockVnetAdminService);
}
 
源代码13 项目: cxf   文件: JSONProviderTest.java
@Test(expected = BadRequestException.class)
public void testIgnoreNamespacesPackageInfo() throws Exception {
    JSONProvider<Book2> p = new JSONProvider<>();
    p.setIgnoreNamespaces(true);
    Book2 book = new Book2(123);
    book.setName("CXF");

    ByteArrayOutputStream os = new ByteArrayOutputStream();

    p.writeTo(book, Book2.class, Book2.class, Book2.class.getAnnotations(),
              MediaType.APPLICATION_JSON_TYPE, new MetadataMap<String, Object>(), os);

    String s = os.toString();
    assertEquals("{\"thebook2\":{\"id\":123,\"name\":\"CXF\"}}", s);

    p.readFrom(Book2.class, null, Book2.class.getAnnotations(),
               MediaType.APPLICATION_JSON_TYPE, null, new ByteArrayInputStream(s.getBytes()));

}
 
源代码14 项目: component-runtime   文件: VaultMock.java
@POST
@Path("decrypt/{tenant}")
public VaultService.DecryptResponse decrypt(@HeaderParam("X-Vault-Token") final String token,
        @PathParam("tenant") final String tenant, final VaultService.DecryptRequest request) {
    if (!"client-test-token".equals(token) || tenant == null || tenant.isEmpty()
            || "x-talend-tenant-id".equals(tenant)) {
        throw new ForbiddenException();
    }
    if (!"vault:v1:hcccVPODe9oZpcr/sKam8GUrbacji8VkuDRGfuDt7bg7VA=="
            .equals(request.getBatchInput().iterator().next().getCiphertext())) {
        throw new BadRequestException();
    }

    final VaultService.DecryptResult result = new VaultService.DecryptResult();
    result.setPlaintext(Base64.getEncoder().encodeToString("test".getBytes(StandardCharsets.UTF_8)));

    final VaultService.DecryptData data = new VaultService.DecryptData();
    data.setBatchResults(singletonList(result));

    final VaultService.DecryptResponse response = new VaultService.DecryptResponse();
    response.setData(data);
    return response;
}
 
源代码15 项目: oxd   文件: RsProtectTest.java
@Parameters({"host", "redirectUrls", "opHost", "rsProtect"})
@Test
public void overwriteFalse(String host, String redirectUrls, String opHost, String rsProtect) throws IOException {
    ClientInterface client = Tester.newClient(host);

    final RegisterSiteResponse site = RegisterSiteTest.registerSite(client, opHost, redirectUrls);

    List<RsResource> resources = UmaFullTest.resourceList(rsProtect).getResources();
    protectResources(client, site, resources);

    final RsProtectParams2 params = new RsProtectParams2();
    params.setOxdId(site.getOxdId());
    params.setResources(Jackson2.createJsonMapper().readTree(Jackson2.asJsonSilently(resources)));

    try {
        client.umaRsProtect(Tester.getAuthorization(site), null, params);
    } catch (BadRequestException e) {
        assertEquals("uma_protection_exists", TestUtils.asError(e).getError());
        return;
    }

    throw new AssertionError("Expected 400 (bad request) but got successful result.");
}
 
源代码16 项目: dremio-oss   文件: CatalogResource.java
@GET
@Path("/by-path/{segment:.*}")
public CatalogEntity getCatalogItemByPath(@PathParam("segment") List<PathSegment> segments) throws NamespaceException, BadRequestException {
  List<String> pathList = new ArrayList<>();

  for (PathSegment segment : segments) {
    pathList.add(segment.getPath());
  }

  Optional<CatalogEntity> entity = catalogServiceHelper.getCatalogEntityByPath(pathList);

  if (!entity.isPresent()) {
    throw new NotFoundException(String.format("Could not find entity with path [%s]", pathList));
  }

  return entity.get();
}
 
源代码17 项目: cloudbreak   文件: ProxyConfigTest.java
@Test(dataProvider = TEST_CONTEXT_WITH_MOCK)
@Description(
        given = "an invalid proxy request with too short name",
        when = "calling create proxy",
        then = "getting back a BadRequestException")
public void testCreateProxyWithShortName(TestContext testContext) {
    String name = resourcePropertyProvider().getName();
    testContext
            .given(ProxyTestDto.class)
            .withName(SHORT_PROXY_NAME)
            .withDescription(PROXY_DESCRIPTION)
            .withServerHost(PROXY_HOST)
            .withServerPort(PROXY_PORT)
            .withServerUser(PROXY_USER)
            .withPassword(PROXY_PASSWORD)
            .withProtocol(HTTP)
            .when(proxyTestClient.create(), key(name))
            .expect(BadRequestException.class,
                    expectedMessage("The length of the name has to be in range of 4 to 100").withKey(name))
            .validate();
}
 
源代码18 项目: snowizard   文件: IdResourceTest.java
@Test
public void testGetIdAsJSONInvalidAgent() throws Exception {
    when(worker.getId(AGENT)).thenThrow(new InvalidUserAgentError());

    try {
        resources.client().target("/").request(MediaType.APPLICATION_JSON)
        .header(HttpHeaders.USER_AGENT, AGENT)
        .get(ClientResponse.class);
        failBecauseExceptionWasNotThrown(BadRequestException.class);
    } catch (final BadRequestException e) {
        final ObjectMapper mapper = resources.getObjectMapper();
        final String expected = mapper.writeValueAsString(AGENT_ERROR);

        final Response response = e.getResponse();
        assertThat(response.getStatus()).isEqualTo(400);
        assertThat(response.readEntity(String.class)).isEqualTo(expected);
    }

    verify(worker).getId(AGENT);
}
 
@Test
void editByNameSecurityAccessChangeHasSecurityAccessError() {
    ValidationResult validationResultError = ValidationResult.builder().error("sec access error").build();
    SecurityAccessDto securityAccessDto = SecurityAccessDto.builder().withCidr("test").build();
    EnvironmentEditDto environmentDto = EnvironmentEditDto.builder()
            .withAccountId(ACCOUNT_ID)
            .withSecurityAccess(securityAccessDto)
            .build();
    Environment value = new Environment();
    when(environmentService
            .findByNameAndAccountIdAndArchivedIsFalse(eq(ENVIRONMENT_NAME), eq(ACCOUNT_ID))).thenReturn(Optional.of(value));
    when(environmentService.getValidatorService()).thenReturn(validatorService);
    when(validatorService.validateSecurityAccessModification(any(), any())).thenReturn(validationResultError);

    BadRequestException actual = assertThrows(BadRequestException.class,
            () -> environmentModificationServiceUnderTest.editByName(ENVIRONMENT_NAME, environmentDto));

    assertEquals("1. sec access error", actual.getMessage());
    verify(environmentService, times(0)).editSecurityAccess(eq(value), eq(securityAccessDto));
}
 
源代码20 项目: trellis   文件: PatchHandlerTest.java
@Test
void testNoLdpRsSupport() {
    when(mockTrellisRequest.getContentType()).thenReturn(APPLICATION_SPARQL_UPDATE);
    when(mockResourceService.supportedInteractionModels()).thenReturn(emptySet());

    final PatchHandler patchHandler = new PatchHandler(mockTrellisRequest, insert, mockBundler, extensions,
            false, null, null);
    try (final Response res = assertThrows(BadRequestException.class, () ->
            patchHandler.initialize(mockParent, mockResource),
            "No exception for an unsupported IXN model!").getResponse()) {
        assertEquals(BAD_REQUEST, res.getStatusInfo(), ERR_RESPONSE_CODE);
        assertTrue(res.getLinks().stream().anyMatch(link ->
                link.getUri().toString().equals(UnsupportedInteractionModel.getIRIString()) &&
                link.getRel().equals(LDP.constrainedBy.getIRIString())), "Missing Link header with constraint!");
    }
}
 
源代码21 项目: cloudbreak   文件: AzureNetworkConnectorTest.java
@Test
public void testGetNetworWhenAzureNetworkNull() {
    String networkId = "vnet-1";
    String resourceGroupName = "resourceGroupName";

    Network network = new Network(null, Map.of(AzureUtils.NETWORK_ID, networkId));
    CloudCredential credential = new CloudCredential();

    when(azureClientService.getClient(credential)).thenReturn(azureClient);
    when(azureUtils.getCustomResourceGroupName(network)).thenReturn(resourceGroupName);
    when(azureUtils.getCustomNetworkId(network)).thenReturn(networkId);
    when(azureClient.getNetworkByResourceGroup(resourceGroupName, networkId)).thenReturn(null);

    thrown.expect(BadRequestException.class);
    thrown.expectMessage(String.format("Network could not be fetch from Azure with resource group name: %s and network id: %s",
            resourceGroupName, networkId));
    underTest.getNetworkCidr(network, credential);
}
 
源代码22 项目: fenixedu-cms   文件: TestSitePageResource.java
@Test
public void createNoNamePage() {
    // prepare
    User user = CmsTestUtils.createAuthenticatedUser("createNoNamePage");

    Site site = CmsTestUtils.createSite(user, "createNoNamePage");

    PageBean pageBean = new PageBean();

    DateTime creationDate = new DateTime();

    // execute

    try {
        String response =
            getSitePagesTarget(site).request().post(Entity.entity(pageBean.toJson(), MediaType.APPLICATION_JSON),
                String.class);
        fail();
    } catch (BadRequestException ex) {
        LOGGER.debug(ex.getMessage());
    }
}
 
@Override
public int deleteSchemaVersion(
        String subject,
        String version) throws Exception {

    try {
        return facade.deleteSchema(subject, version);
    } catch (IllegalArgumentException ex) {
        throw new BadRequestException(ex); // TODO
    }
}
 
源代码24 项目: cloudbreak   文件: LdapConfigTest.java
@Test(dataProvider = TEST_CONTEXT_WITH_MOCK)
@Description(
        given = "a valid ldap request",
        when = "calling create ldap and create again with the same environment",
        then = "getting BadRequestException because only one ldap can exist with same environment in an account at the same time")
public void testCreateLdapWithSameEnvironment(TestContext testContext) {
    String name = resourcePropertyProvider().getName();
    testContext
            .given(name, LdapTestDto.class)
            .valid()
            .withEnvironmentCrn(name)
            .when(ldapTestClient.createV1(), RunningParameter.key(name))
            .then((tc, entity, cc) -> {
                assertNotNull(entity);
                assertNotNull(entity.getResponse());
                return entity;
            }, RunningParameter.key(name))

            .given(name, LdapTestDto.class)
            .valid()
            .withEnvironmentCrn(name)
            .when(ldapTestClient.createV1(), RunningParameter.key(name))
            .expect(BadRequestException.class,
                    RunningParameter.expectedMessage("environment is already exists")
                            .withKey(name))
            .validate();
}
 
源代码25 项目: robozonky   文件: ZonkyApiTokenSupplier.java
private static RuntimeException createException(final Throwable throwable) {
    if (throwable instanceof NotAuthorizedException || throwable instanceof BadRequestException) {
        return (RuntimeException) throwable;
    } else { // we have a problem, but that problem is not HTTP 40x, indicating auth failure
        return new IllegalStateException("Recoverable authentication failure.", throwable);
    }
}
 
@Test
public void testHasRightOfUserWithInvalidAction() {
    thrown.expect(BadRequestException.class);
    thrown.expectMessage("Action cannot be found by request!");

    ThreadBasedUserCrnProvider.doAs(USER_CRN, () -> underTest.hasRightOfUser(USER_CRN, "invalid"));

    verifyZeroInteractions(umsClient);
}
 
protected DataResponse createDataResponse(List dataList, PaginationParam paginationParam,
        Map<String, Map<String, Object>> metadata, boolean withPagination) {
    Map<String, Object> dataMetadata = new HashMap<>();
    Map<String, Object> paginationMetadata = new HashMap<>();

    int totalItems = dataList.size();

    List paginatedList;
    if (withPagination && totalItems > 0 && paginationParam.getSize() > 0) {
        paginatedList = this.paginateResultList(dataList, totalItems, paginationParam.getPage(),
                paginationParam.getSize(), paginationMetadata);
    } else {
        if (paginationParam.getSize() < -1) {
            throw new BadRequestException("Pagination size is not valid");
        }
        paginatedList = dataList;
    }

    if (metadata != null && metadata.containsKey(METADATA_DATA_KEY)) {
        dataMetadata.put(METADATA_DATA_TOTAL_KEY, metadata.get(METADATA_DATA_KEY).get(METADATA_DATA_TOTAL_KEY));
    } else {
        dataMetadata.put(METADATA_DATA_TOTAL_KEY, paginatedList.size());
    }

    if (withPagination && paginationParam.getSize() == 0) {
        paginatedList = new ArrayList();
    }

    return new DataResponse().data(paginatedList)
            .metadata(this.computeMetadata(metadata, dataMetadata, paginationMetadata))
            .links(this.computePaginatedLinks(paginationParam.getPage(), paginationParam.getSize(), totalItems));
}
 
源代码28 项目: cloudbreak   文件: FlowServiceTest.java
@Test
public void testGetLastFlowByIdException() {
    when(flowLogDBService.getLastFlowLog(anyString())).thenReturn(Optional.empty());

    thrown.expect(BadRequestException.class);
    thrown.expectMessage("Not found flow for this flow id!");

    underTest.getLastFlowById(FLOW_ID);

    verify(flowLogDBService).getLastFlowLog(anyString());
    verifyZeroInteractions(conversionService);
}
 
源代码29 项目: rx-jersey   文件: FlowableResourceTest.java
@Test(expected = BadRequestException.class)
public void shouldHandleError() {
    ObservableResource resource = target(ObservableResource.class);
    String message = resource.error().blockingFirst();

    assertEquals("", message);
}
 
源代码30 项目: cloudbreak   文件: EnvironmentChildTest.java
@Test(dataProvider = TEST_CONTEXT_WITH_MOCK)
@Description(
        given = "there is a running cloudbreak",
        when = "child create request is sent but parent is not created yet",
        then = "a BadRequestException should be returned")
public void testCreateChildWithoutParentEnvironment(TestContext testContext) {
    String forbiddenKey = resourcePropertyProvider().getName();
    testContext
            .given(PARENT_ENVIRONMENT, EnvironmentTestDto.class)
            .given(CHILD_ENVIRONMENT, EnvironmentTestDto.class)
                .withParentEnvironment(RunningParameter.key(PARENT_ENVIRONMENT))
            .when(environmentTestClient.create(), RunningParameter.key(forbiddenKey))
            .expect(BadRequestException.class, RunningParameter.key(forbiddenKey))
            .validate();
}
 
 类所在包
 类方法
 同包方法