当前位置: 首页>>代码示例>>Java>>正文


Java ServiceInstanceBindingExistsException类代码示例

本文整理汇总了Java中org.springframework.cloud.servicebroker.exception.ServiceInstanceBindingExistsException的典型用法代码示例。如果您正苦于以下问题:Java ServiceInstanceBindingExistsException类的具体用法?Java ServiceInstanceBindingExistsException怎么用?Java ServiceInstanceBindingExistsException使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


ServiceInstanceBindingExistsException类属于org.springframework.cloud.servicebroker.exception包,在下文中一共展示了ServiceInstanceBindingExistsException类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: createServiceInstanceBinding

import org.springframework.cloud.servicebroker.exception.ServiceInstanceBindingExistsException; //导入依赖的package包/类
@Override
public CreateServiceInstanceBindingResponse createServiceInstanceBinding(
        CreateServiceInstanceBindingRequest request)
        throws ServiceInstanceBindingExistsException,
        ServiceBrokerException {
    try {
        BindingWorkflow workflow = getWorkflow(request);

        LOG.info("creating binding");
        workflow.checkIfUserExists();
        String secretKey = workflow.createBindingUser();

        LOG.info("building binding response");
        Map<String, Object> credentials = workflow.getCredentials(secretKey,
                request.getParameters());
        ServiceInstanceBinding binding = workflow.getBinding(credentials);

        LOG.info("saving binding...");
        repository.save(binding);
        LOG.info("binding saved.");

        return workflow.getResponse(credentials);
    } catch (IOException | JAXBException | EcsManagementClientException e) {
        throw new ServiceBrokerException(e);
    }
}
 
开发者ID:codedellemc,项目名称:ecs-cf-service-broker,代码行数:27,代码来源:EcsServiceInstanceBindingService.java

示例2: newServiceInstanceBindingCreatedSuccessfully

import org.springframework.cloud.servicebroker.exception.ServiceInstanceBindingExistsException; //导入依赖的package包/类
@Test
public void newServiceInstanceBindingCreatedSuccessfully()
        throws ServiceBrokerException, ServiceInstanceBindingExistsException {

   when(admin.getCredentialsFromSensors(anyString(), anyString(), any(Predicate.class), any(Predicate.class), any(Predicate.class), any(Predicate.class))).thenReturn(new AsyncResult<>(Collections.<String, Object>emptyMap()));
   when(admin.hasEffector(anyString(), anyString(), anyString())).thenReturn(new AsyncResult<>(false));
   when(instanceRepository.findOne(anyString(), anyBoolean())).thenReturn(serviceInstance);
   when(serviceDefinition.getMetadata()).thenReturn(ImmutableMap.of());
   when(brooklynCatalogService.getServiceDefinition(anyString())).thenReturn(serviceDefinition);
   when(serviceInstance.getEntityId()).thenReturn("entityId");
   CreateServiceInstanceBindingRequest request = new CreateServiceInstanceBindingRequest(serviceInstance.getServiceDefinitionId(), "planId", "appGuid", null);
   CreateServiceInstanceBindingResponse binding = bindingService.createServiceInstanceBinding(request.withBindingId(SVC_INST_BIND_ID));

   assertNotNull(binding);
   // TODO assert binding was completed successfully
   //assertEquals(SVC_INST_BIND_ID, binding.getServiceBindingId());
}
 
开发者ID:cloudfoundry-incubator,项目名称:apache-brooklyn-service-broker,代码行数:18,代码来源:BrooklynServiceInstanceBindingServiceTest.java

示例3: createServiceInstanceBinding

import org.springframework.cloud.servicebroker.exception.ServiceInstanceBindingExistsException; //导入依赖的package包/类
@Override
public CreateServiceInstanceBindingResponse createServiceInstanceBinding(final CreateServiceInstanceBindingRequest request) {
    final String bindingId = request.getBindingId();
    final String serviceInstanceId = request.getServiceInstanceId();

    ServiceInstanceBinding binding = bindingRepository.findOne(bindingId);
    if (binding != null) {
        throw new ServiceInstanceBindingExistsException(serviceInstanceId, bindingId);
    }

    ServiceInstance instance = instanceRepository.findOne(serviceInstanceId);
    if (instance == null) {
        throw new CloudKarafkaServiceException("Instance don't exist :" + serviceInstanceId);
    }

    final Map<String, Object> credentials = new HashMap<String, Object>(){
        {
            put("brokers", instance.getCloudKarafkaBrokers());
            put("ca", instance.getCloudKarafkaCa());
            put("cert", instance.getCloudKarafkaCert());
            put("id", instance.getCloudKarafkaId());
            put("private_key", instance.getCloudKarafkaPrivateKey());
            put("topic_prefix", instance.getCloudKarafkaTopicPrefix());
            put("brokers",instance.getCloudKarafkaBrokers());
            put("message",instance.getCloudKarafkaMessage());
        }};

    binding = new ServiceInstanceBinding(bindingId, serviceInstanceId, credentials, null, request.getBoundAppGuid());
    bindingRepository.save(binding);

    return new CreateServiceInstanceAppBindingResponse().withCredentials(credentials);
}
 
开发者ID:ipolyzos,项目名称:cloudkarafka-broker,代码行数:33,代码来源:CloudKarafkaServiceInstanceBindingService.java

示例4: createServiceInstanceBinding

import org.springframework.cloud.servicebroker.exception.ServiceInstanceBindingExistsException; //导入依赖的package包/类
@Override
public CreateServiceInstanceBindingResponse createServiceInstanceBinding(CreateServiceInstanceBindingRequest request) {

    String bindingId = request.getBindingId();
    String serviceInstanceId = request.getServiceInstanceId();

    ServiceInstanceBinding binding = bindingRepository.findOne(bindingId);
    if (binding != null) {
        throw new ServiceInstanceBindingExistsException(serviceInstanceId, bindingId);
    }

    String database = serviceInstanceId;
    String username = bindingId;
    // TODO Password Generator
    String password = "password";

    // TODO check if user already exists in the DB

    mongo.createUser(database, username, password);

    Map<String, Object> credentials =
            Collections.singletonMap("uri", (Object) mongo.getConnectionString(database, username, password));

    binding = new ServiceInstanceBinding(bindingId, serviceInstanceId, credentials, null, request.getBoundAppGuid());
    bindingRepository.save(binding);

    return new CreateServiceInstanceAppBindingResponse().withCredentials(credentials);
}
 
开发者ID:cf-platform-eng,项目名称:mongodb-broker,代码行数:29,代码来源:MongoServiceInstanceBindingService.java

示例5: serviceInstanceCreationFailsWithExistingInstance

import org.springframework.cloud.servicebroker.exception.ServiceInstanceBindingExistsException; //导入依赖的package包/类
@Test(expected = ServiceInstanceBindingExistsException.class)
public void serviceInstanceCreationFailsWithExistingInstance() throws Exception {

	when(repository.findOne(any(String.class)))
			.thenReturn(ServiceInstanceBindingFixture.getServiceInstanceBinding());

	service.createServiceInstanceBinding(buildCreateRequest());
}
 
开发者ID:cf-platform-eng,项目名称:mongodb-broker,代码行数:9,代码来源:MongoServiceInstanceBindingServiceTest.java

示例6: testBinding

import org.springframework.cloud.servicebroker.exception.ServiceInstanceBindingExistsException; //导入依赖的package包/类
@Test
public void testBinding() throws ServiceBrokerException,
        ServiceInstanceBindingExistsException {

    VrServiceInstanceBinding b = TestConfig.getServiceInstanceBinding();
    assertNotNull(b);
    Map<String, Object> m = b.getCredentials();
    assertNotNull(m);
    assertEquals("mysql://root:[email protected]:1234/aDB",
            m.get(VrServiceInstance.URI));
    assertNotNull(b.getId());
    assertEquals("anID", b.getServiceInstanceId());
}
 
开发者ID:cf-platform-eng,项目名称:vrealize-service-broker,代码行数:14,代码来源:VrServiceInstanceBindingServiceTest.java

示例7: checkIfUserExists

import org.springframework.cloud.servicebroker.exception.ServiceInstanceBindingExistsException; //导入依赖的package包/类
@Override
public void checkIfUserExists() throws EcsManagementClientException, IOException {
    ServiceInstance instance = instanceRepository.find(instanceId);
    if (instance == null)
        throw new ServiceInstanceDoesNotExistException(instanceId);
    if (instance.remoteConnectionKeyExists(bindingId))
        throw new ServiceInstanceBindingExistsException(instanceId, bindingId);
}
 
开发者ID:codedellemc,项目名称:ecs-cf-service-broker,代码行数:9,代码来源:RemoteConnectBindingWorkflow.java

示例8: testCreateExistingNamespaceUserFails

import org.springframework.cloud.servicebroker.exception.ServiceInstanceBindingExistsException; //导入依赖的package包/类
/**
 * If the binding-service attempts to create a namespace user that already
 * exists, the service will throw an error.
 *
 */
@Test(expected = ServiceInstanceBindingExistsException.class)
public void testCreateExistingNamespaceUserFails() {
    when(ecs.lookupServiceDefinition(NAMESPACE_SERVICE_ID))
            .thenReturn(namespaceServiceFixture());
    when(ecs.userExists(BINDING_ID)).thenReturn(true);

    bindSvc.createServiceInstanceBinding(namespaceBindingRequestFixture());
}
 
开发者ID:codedellemc,项目名称:ecs-cf-service-broker,代码行数:14,代码来源:EcsServiceInstanceBindingServiceTest.java

示例9: testCreateExistingBucketUserFails

import org.springframework.cloud.servicebroker.exception.ServiceInstanceBindingExistsException; //导入依赖的package包/类
/**
 * If the binding-service attempts to create a bucket user that already
 * exists, the service will throw an error.
 *
 * @throws EcsManagementClientException if ecs management API returns an error
 */
@Test(expected = ServiceInstanceBindingExistsException.class)
public void testCreateExistingBucketUserFails()
        throws EcsManagementClientException {
    when(ecs.lookupServiceDefinition(BUCKET_SERVICE_ID))
            .thenReturn(bucketServiceFixture());
    when(ecs.getObjectEndpoint()).thenReturn(OBJ_ENDPOINT);
    when(ecs.userExists(BINDING_ID)).thenReturn(true);

    bindSvc.createServiceInstanceBinding(
            bucketBindingPermissionRequestFixture());
}
 
开发者ID:codedellemc,项目名称:ecs-cf-service-broker,代码行数:18,代码来源:EcsServiceInstanceBindingServiceTest.java

示例10: createBindingWithDuplicateIdFails

import org.springframework.cloud.servicebroker.exception.ServiceInstanceBindingExistsException; //导入依赖的package包/类
@Test
public void createBindingWithDuplicateIdFails() throws Exception {
	when(serviceInstanceBindingService.createServiceInstanceBinding(eq(createRequest)))
		.thenThrow(new ServiceInstanceBindingExistsException(createRequest.getServiceInstanceId(), createRequest.getBindingId()));

	setupCatalogService(createRequest.getServiceDefinitionId());

	mockMvc.perform(put(buildCreateUrl(false))
			.content(DataFixture.toJson(createRequest))
			.accept(MediaType.APPLICATION_JSON)
			.contentType(MediaType.APPLICATION_JSON))
			.andExpect(status().isConflict())
			.andExpect(jsonPath("$.description", containsString(createRequest.getServiceInstanceId())))
			.andExpect(jsonPath("$.description", containsString(createRequest.getBindingId())));
}
 
开发者ID:spring-cloud,项目名称:spring-cloud-cloudfoundry-service-broker,代码行数:16,代码来源:ServiceInstanceBindingControllerIntegrationTest.java

示例11: newServiceInstanceBindingCreatedSuccessfullyWithBindEffector

import org.springframework.cloud.servicebroker.exception.ServiceInstanceBindingExistsException; //导入依赖的package包/类
@Test
public void newServiceInstanceBindingCreatedSuccessfullyWithBindEffector()
        throws ServiceBrokerException, ServiceInstanceBindingExistsException, PollingException {
   when(admin.getRestApi()).thenReturn(brooklynApi);
   when(admin.getCredentialsFromSensors(
           anyString(),
           anyString(),
           any(Predicate.class),
           any(Predicate.class),
           any(Predicate.class),
           any(Predicate.class)
   )).thenReturn(new AsyncResult<>(Collections.<String, Object>emptyMap()));
   when(admin.hasEffector(anyString(), anyString(), anyString())).thenReturn(new AsyncResult<>(true));
   when(admin.invokeEffector(anyString(), anyString(), anyString(), anyString(), anyMap())).thenReturn(new AsyncResult<>(TASK_RESPONSE_COMPLETE));
   when(brooklynApi.getActivityApi()).thenReturn(activityApi);
   when(activityApi.get(anyString()))
           .thenReturn(TASK_SUMMARY_INCOMPLETE)
           .thenReturn(TASK_SUMMARY_INCOMPLETE)
           .thenReturn(TASK_SUMMARY_INCOMPLETE)
           .thenReturn(TASK_SUMMARY_INCOMPLETE)
           .thenReturn(TASK_SUMMARY_COMPLETE);
   doCallRealMethod().when(admin).blockUntilTaskCompletes(anyString());
   doCallRealMethod().when(admin).blockUntilTaskCompletes(anyString(), any(Duration.class), any(Object[].class));
   when(instanceRepository.findOne(anyString(), anyBoolean())).thenReturn(serviceInstance);
   when(serviceDefinition.getMetadata()).thenReturn(ImmutableMap.of());
   when(brooklynCatalogService.getServiceDefinition(anyString())).thenReturn(serviceDefinition);
   CreateServiceInstanceBindingRequest request = new CreateServiceInstanceBindingRequest(serviceInstance.getServiceDefinitionId(), "planId", "appGuid", null);
   CreateServiceInstanceBindingResponse binding = bindingService.createServiceInstanceBinding(request.withBindingId(SVC_INST_BIND_ID));

   // TODO assert binding was completed successfully
   //assertEquals(SVC_INST_BIND_ID, binding.getServiceBindingId());
}
 
开发者ID:cloudfoundry-incubator,项目名称:apache-brooklyn-service-broker,代码行数:33,代码来源:BrooklynServiceInstanceBindingServiceTest.java

示例12: testServiceInstanceBindingFailureWithBindEffector

import org.springframework.cloud.servicebroker.exception.ServiceInstanceBindingExistsException; //导入依赖的package包/类
@Test(expected = RuntimeException.class)
public void testServiceInstanceBindingFailureWithBindEffector()
        throws ServiceBrokerException, ServiceInstanceBindingExistsException, PollingException {
   when(admin.getRestApi()).thenReturn(brooklynApi);
   when(admin.getCredentialsFromSensors(
           anyString(),
           anyString(),
           any(Predicate.class),
           any(Predicate.class),
           any(Predicate.class),
           any(Predicate.class)
   )).thenReturn(new AsyncResult<>(Collections.<String, Object>emptyMap()));
   when(admin.hasEffector(anyString(), anyString(), anyString())).thenReturn(new AsyncResult<>(true));
   when(admin.invokeEffector(anyString(), anyString(), anyString(), anyString(), anyMap())).thenReturn(new AsyncResult<>(null));
   when(brooklynApi.getActivityApi()).thenReturn(activityApi);
   when(activityApi.get(anyString()))
           .thenReturn(TASK_SUMMARY_INCOMPLETE)
           .thenReturn(TASK_SUMMARY_INCOMPLETE)
           .thenReturn(TASK_SUMMARY_INCOMPLETE)
           .thenReturn(TASK_SUMMARY_INCOMPLETE)
           .thenReturn(TASK_SUMMARY_COMPLETE);
   doCallRealMethod().when(admin).blockUntilTaskCompletes(anyString());
   doCallRealMethod().when(admin).blockUntilTaskCompletes(anyString(), any(Duration.class), any(Object[].class));
   when(instanceRepository.findOne(anyString(), anyBoolean())).thenReturn(serviceInstance);
   when(serviceDefinition.getMetadata()).thenReturn(ImmutableMap.of());
   when(brooklynCatalogService.getServiceDefinition(anyString())).thenReturn(serviceDefinition);
   CreateServiceInstanceBindingRequest request = new CreateServiceInstanceBindingRequest(serviceInstance.getServiceDefinitionId(), "planId", "appGuid", null);
   bindingService.createServiceInstanceBinding(request.withBindingId(SVC_INST_BIND_ID));
}
 
开发者ID:cloudfoundry-incubator,项目名称:apache-brooklyn-service-broker,代码行数:30,代码来源:BrooklynServiceInstanceBindingServiceTest.java

示例13: testWhitelistCreatedSuccessfully

import org.springframework.cloud.servicebroker.exception.ServiceInstanceBindingExistsException; //导入依赖的package包/类
@Test
public void testWhitelistCreatedSuccessfully() throws ServiceInstanceBindingExistsException, ServiceBrokerException {

   bindingService = new BrooklynServiceInstanceBindingService(new BrooklynRestAdmin(brooklynApi, httpClient, config), bindingRepository, instanceRepository, brooklynCatalogService);

   when(admin.getCredentialsFromSensors(anyString(), anyString(), any(Predicate.class), any(Predicate.class), any(Predicate.class), any(Predicate.class))).thenCallRealMethod();

   when(brooklynApi.getSensorApi()).thenReturn(sensorApi);
   when(sensorApi.list(anyString(), anyString())).thenReturn(ImmutableList.of(
           new SensorSummary("my.sensor", "my sensor type", "my sensor description", ImmutableMap.of()),
           new SensorSummary("sensor.one.name", "sensor one type", "sensor one description", ImmutableMap.of())
   ));
   when(brooklynApi.getEntityApi()).thenReturn(entityApi);
   when(entityApi.list(any())).thenReturn(ImmutableList.of(
           new EntitySummary("entityId", "name", "entityType", "catalogItemId", ImmutableMap.of())
   ));
   when(instanceRepository.findOne(anyString(), anyBoolean())).thenReturn(serviceInstance);
   when(brooklynCatalogService.getServiceDefinition(Mockito.anyString())).thenReturn(serviceDefinition);
   when(serviceInstance.getServiceDefinitionId()).thenReturn(SVC_DEFN_ID);
   when(serviceDefinition.getMetadata()).thenReturn(ImmutableMap.of("planYaml", WHITELIST_YAML));
   when(brooklynApi.getEffectorApi()).thenReturn(effectorApi);
   when(effectorApi.invoke(anyString(), anyString(), anyString(), anyString(), anyMap())).thenReturn(bindEffectorResponse);
   when(sensorApi.get(Mockito.anyString(), Mockito.anyString(), Mockito.anyString(), anyBoolean())).thenReturn("");
   when(serviceInstance.getEntityId()).thenReturn("entityId");

   CreateServiceInstanceBindingRequest request = new CreateServiceInstanceBindingRequest(serviceInstance.getServiceDefinitionId(), "planId", "appGuid", null);
   CreateServiceInstanceBindingResponse binding = bindingService.createServiceInstanceBinding(request.withBindingId(SVC_INST_BIND_ID));

   BrooklynServiceInstanceBinding expectedBinding = new BrooklynServiceInstanceBinding(SVC_INST_BIND_ID, serviceInstance.getServiceInstanceId(), EXPECTED_CREDENTIALS, "appGuid", "childEntityId");

   // TODO: test binding properly
   //assertEquals(expectedBinding.getAppGuid(), binding.getAppGuid());
   //assertEquals(expectedBinding.getCredentials(), binding.getCredentials());
   //assertEquals(expectedBinding.getServiceBindingId(), binding.getServiceBindingId());
   //assertEquals(expectedBinding.getServiceInstanceId(), binding.getServiceInstanceId());
}
 
开发者ID:cloudfoundry-incubator,项目名称:apache-brooklyn-service-broker,代码行数:37,代码来源:BrooklynServiceInstanceBindingServiceTest.java

示例14: serviceInstanceCreationFailsWithExistingInstance

import org.springframework.cloud.servicebroker.exception.ServiceInstanceBindingExistsException; //导入依赖的package包/类
@Test(expected = ServiceInstanceBindingExistsException.class)
public void serviceInstanceCreationFailsWithExistingInstance()
        throws ServiceBrokerException, ServiceInstanceBindingExistsException {

   when(bindingRepository.findOne(anyString()))
           .thenReturn(TEST_SERVICE_INSTANCE_BINDING);
   when(admin.getApplicationSensors(anyString())).thenReturn(new AsyncResult<>(Collections.<String, Object>emptyMap()));
   CreateServiceInstanceBindingRequest request = new CreateServiceInstanceBindingRequest(serviceInstance.getServiceDefinitionId(), "planId", "appGuid", null);

   bindingService.createServiceInstanceBinding(request.withBindingId(SVC_INST_BIND_ID));
   bindingService.createServiceInstanceBinding(request.withBindingId(SVC_INST_BIND_ID));
}
 
开发者ID:cloudfoundry-incubator,项目名称:apache-brooklyn-service-broker,代码行数:13,代码来源:BrooklynServiceInstanceBindingServiceTest.java

示例15: serviceInstanceBindingRetrievedSuccessfully

import org.springframework.cloud.servicebroker.exception.ServiceInstanceBindingExistsException; //导入依赖的package包/类
@Test
public void serviceInstanceBindingRetrievedSuccessfully()
        throws ServiceBrokerException, ServiceInstanceBindingExistsException {

   BrooklynServiceInstanceBinding binding = TEST_SERVICE_INSTANCE_BINDING;
   when(bindingRepository.findOne(anyString())).thenReturn(binding);

   assertEquals(binding.getServiceBindingId(), bindingService.getServiceInstanceBinding(binding.getServiceBindingId()).getServiceBindingId());
}
 
开发者ID:cloudfoundry-incubator,项目名称:apache-brooklyn-service-broker,代码行数:10,代码来源:BrooklynServiceInstanceBindingServiceTest.java


注:本文中的org.springframework.cloud.servicebroker.exception.ServiceInstanceBindingExistsException类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。