本文整理汇总了Java中org.cloudfoundry.community.servicebroker.exception.ServiceInstanceBindingExistsException类的典型用法代码示例。如果您正苦于以下问题:Java ServiceInstanceBindingExistsException类的具体用法?Java ServiceInstanceBindingExistsException怎么用?Java ServiceInstanceBindingExistsException使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
ServiceInstanceBindingExistsException类属于org.cloudfoundry.community.servicebroker.exception包,在下文中一共展示了ServiceInstanceBindingExistsException类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: when
import org.cloudfoundry.community.servicebroker.exception.ServiceInstanceBindingExistsException; //导入依赖的package包/类
@Test
public void when_creating_service_instance_binding_with_service_id_existing_and_user_ask_to_see_all_dumps_it_should_give_a_correct_service_instance_binding() throws ServiceInstanceBindingExistsException, ServiceBrokerException {
when(repositoryInstanceBinding.findOne(anyString())).thenReturn(null);
DbDumperCredential dbDumperCredential = this.forgeDbDumperCredential(dbDumperCredentials.size() + 1, true);
List<DbDumperCredential> dumperCredentials = Arrays.asList(dbDumperCredential1, dbDumperCredential2, dbDumperCredential3, dbDumperCredential);
when(credentials.getDumpsCredentials((DatabaseRef) notNull())).thenReturn(dumperCredentials);
parameters.put(DbDumperServiceInstanceBindingService.SEE_ALL_DUMPS_KEY, true);
ServiceInstanceBinding instanceBinding = this.instanceBindingService.createServiceInstanceBinding(createRequest);
assertThat(instanceBinding).isNotNull();
assertThat(instanceBinding.getAppGuid()).isEqualTo(appGuid);
assertThat(instanceBinding.getId()).isEqualTo(bindingId);
assertCredentials(instanceBinding, dumperCredentials);
}
开发者ID:orange-cloudfoundry,项目名称:db-dumper-service,代码行数:17,代码来源:DbDumperServiceInstanceBindingServiceTest.java
示例2: createServiceInstanceBinding
import org.cloudfoundry.community.servicebroker.exception.ServiceInstanceBindingExistsException; //导入依赖的package包/类
@Override
public ServiceInstanceBinding createServiceInstanceBinding(
CreateServiceInstanceBindingRequest request)
throws ServiceInstanceBindingExistsException,
ServiceBrokerException {
String bindingId = request.getBindingId(); // user
String instanceId = request.getServiceInstanceId(); // workspace
log.info(String.format("attempting to provision an FTP for workspace " +
"(serviceInstanceId) %s and user (bindingId) %s", instanceId, bindingId));
FtpServerProvisionerRequest r = new FtpServerProvisionerRequest(bindingId, instanceId);
String response = this.client.provisionFtpServer(r);
log.info(String.format("received FTP service provision response %s", response));
PersistableServiceInstanceBinding psb = new PersistableServiceInstanceBinding(
request.getBindingId(),
request.getServiceInstanceId(),
response,
null, request.getAppGuid());
return this.bindingRepository.save(psb);
}
开发者ID:joshlong,项目名称:cloudfoundry-ftp-service-broker,代码行数:27,代码来源:FtpServiceInstanceBindingService.java
示例3: itShouldThrowWhenMoreThanOneAMIIsFoundToBeDeleted
import org.cloudfoundry.community.servicebroker.exception.ServiceInstanceBindingExistsException; //导入依赖的package包/类
@Test(expected = ServiceBrokerException.class)
public void itShouldThrowWhenMoreThanOneAMIIsFoundToBeDeleted()
throws ServiceBrokerException,
ServiceInstanceBindingExistsException {
when(ec2Client.describeSnapshots())
.thenReturn(
new DescribeSnapshotsResult().withSnapshots(Arrays.asList(
new Snapshot()
.withDescription("Created by CreateImage(source_instance) for test_image from vol-e7526fac"),
new Snapshot()
.withDescription(
"Created by CreateImage(source_instance) for test_image from vol-e7526fac")
.withSnapshotId("test_snapshot"),
new Snapshot()
.withDescription("Created by CreateImage(source_instance) for ami-xx from vol-e7526fac"),
new Snapshot())));
aws.deleteStorageArtifacts("test_image");
verify(ec2Client, never()).deleteSnapshot(any());
}
示例4: itShouldNotBindToTheSameAppTwice
import org.cloudfoundry.community.servicebroker.exception.ServiceInstanceBindingExistsException; //导入依赖的package包/类
@Test(expected = ServiceInstanceBindingExistsException.class)
public void itShouldNotBindToTheSameAppTwice()
throws ServiceInstanceBindingExistsException,
ServiceBrokerException {
ArrayList<ServiceInstanceBinding> list = new ArrayList<ServiceInstanceBinding>();
list.add(new ServiceInstanceBinding("foo", serviceInstance
.getServiceInstanceId(), null, null, "test_app"));
when(bindingManager.getBindings()).thenReturn(list);
bindResult = bindingService
.createServiceInstanceBinding(createServiceInstanceBindingRequest);
createServiceInstanceBindingRequest = new CreateServiceInstanceBindingRequest(
"postgrescdm", COPY, "test_app")
.withBindingId(bindingId + "foo").and()
.withServiceInstanceId(serviceInstance.getServiceInstanceId());
bindResult = bindingService
.createServiceInstanceBinding(createServiceInstanceBindingRequest);
}
开发者ID:krujos,项目名称:data-lifecycle-service-broker,代码行数:20,代码来源:LCServiceInstanceBindingServiceCopyTest.java
示例5: itShouldReturnAppToInstancePairsAndBindToMutipleApps
import org.cloudfoundry.community.servicebroker.exception.ServiceInstanceBindingExistsException; //导入依赖的package包/类
@Test
public void itShouldReturnAppToInstancePairsAndBindToMutipleApps()
throws ServiceInstanceBindingExistsException,
ServiceBrokerException {
when(
instanceService.getInstanceIdForServiceInstance(serviceInstance
.getServiceInstanceId())).thenReturn("test_copy");
List<ServiceInstanceBinding> bindings = buildServiceInstanceBindings();
when(bindingManager.getBindings()).thenReturn(bindings);
List<InstancePair> appBindings = bindingService.getAppToCopyBinding();
assertThat(appBindings, hasSize(3));
assertTrue(appBindings.contains(new InstancePair("test_app2",
"test_copy")));
}
开发者ID:krujos,项目名称:data-lifecycle-service-broker,代码行数:18,代码来源:LCServiceInstanceBindingServiceCopyTest.java
示例6: buildServiceInstanceBindings
import org.cloudfoundry.community.servicebroker.exception.ServiceInstanceBindingExistsException; //导入依赖的package包/类
private List<ServiceInstanceBinding> buildServiceInstanceBindings() {
List<ServiceInstanceBinding> list = new ArrayList<ServiceInstanceBinding>();
IntConsumer consumer = new IntConsumer() {
@Override
public void accept(int i) {
createServiceInstanceBindingRequest.withBindingId("bind" + i)
.setAppGuid("test_app" + i);
try {
list.add(bindingService
.createServiceInstanceBinding(createServiceInstanceBindingRequest));
} catch (ServiceInstanceBindingExistsException
| ServiceBrokerException e) {
fail("Failed to create service instance bindings");
}
}
};
IntStream.range(1, 4).forEach(consumer);
return list;
}
开发者ID:krujos,项目名称:data-lifecycle-service-broker,代码行数:21,代码来源:LCServiceInstanceBindingServiceCopyTest.java
示例7: itShouldReturnTheProdCreds
import org.cloudfoundry.community.servicebroker.exception.ServiceInstanceBindingExistsException; //导入依赖的package包/类
@Test
public void itShouldReturnTheProdCreds() throws ServiceBrokerException,
ServiceInstanceBindingExistsException {
Map<String, Object> testCreds = new HashMap<String, Object>();
testCreds.put("uri", "prod_uri");
when(provider.getCreds("source_instance")).thenReturn(testCreds);
ServiceInstanceBinding bindResult = bindingService
.createServiceInstanceBinding(new CreateServiceInstanceBindingRequest(
serviceInstance.getServiceDefinitionId(), PRODUCTION,
"test_app")
.withBindingId(bindingId)
.and()
.withServiceInstanceId(
serviceInstance.getServiceInstanceId()));
assertThat(bindResult.getId(), is(equalTo(bindingId)));
}
开发者ID:krujos,项目名称:data-lifecycle-service-broker,代码行数:19,代码来源:LCServiceInstanceBindingServiceProdTest.java
示例8: createServiceInstanceBinding
import org.cloudfoundry.community.servicebroker.exception.ServiceInstanceBindingExistsException; //导入依赖的package包/类
@Override
public ServiceInstanceBinding createServiceInstanceBinding(CreateServiceInstanceBindingRequest request)
throws ServiceInstanceBindingExistsException, ServiceBrokerException {
LOGGER.debug(LoggerHelper.getParamsAsString("createServiceInstanceBinding", request.getBindingId(),
request.getServiceInstanceId(), request.getPlanId(), request.getAppGuid()));
try {
Location storingLocation = Location.newInstance(request.getBindingId(),
request.getServiceInstanceId());
Optional<CreateServiceInstanceBindingRequest> binding = store.getById(storingLocation);
if (binding.isPresent()) {
throw new ServiceInstanceBindingExistsException(getServiceInstanceBinding(binding.get()));
}
store.save(storingLocation, request);
} catch (IOException e) {
throw new ServiceBrokerException(e.getMessage(), e);
}
return getServiceInstanceBinding(request);
}
示例9: createServiceInstanceBinding
import org.cloudfoundry.community.servicebroker.exception.ServiceInstanceBindingExistsException; //导入依赖的package包/类
@Override
public ServiceInstanceBinding createServiceInstanceBinding(CreateServiceInstanceBindingRequest createServiceInstanceBindingRequest)
throws ServiceInstanceBindingExistsException, ServiceBrokerException {
String bindingId = createServiceInstanceBindingRequest.getBindingId();
String serviceInstanceId = createServiceInstanceBindingRequest.getServiceInstanceId();
String appGuid = createServiceInstanceBindingRequest.getAppGuid();
String passwd = "";
try {
passwd = this.role.bindRoleToDatabase(serviceInstanceId);
} catch (SQLException e) {
logger.error("Error while creating service instance binding '" + bindingId + "'", e);
throw new ServiceBrokerException(e.getMessage());
}
String dbURL = String.format("postgres://%s:%[email protected]%s:%d/%s", serviceInstanceId, passwd, PostgreSQLDatabase.getDatabaseHost(), PostgreSQLDatabase.getDatabasePort(), serviceInstanceId);
Map<String, Object> credentials = new HashMap<String, Object>();
credentials.put("uri", dbURL);
return new ServiceInstanceBinding(bindingId, serviceInstanceId, credentials, null, appGuid);
}
开发者ID:cloudfoundry-community,项目名称:postgresql-cf-service-broker,代码行数:23,代码来源:PostgreSQLServiceInstanceBindingService.java
示例10: when_creating_service_instance_binding_which_already_exist_it_should_raise_an_exception
import org.cloudfoundry.community.servicebroker.exception.ServiceInstanceBindingExistsException; //导入依赖的package包/类
@Test
public void when_creating_service_instance_binding_which_already_exist_it_should_raise_an_exception() {
when(repositoryInstanceBinding.findOne(anyString())).thenReturn(dbDumperServiceInstanceBinding);
try {
instanceBindingService.createServiceInstanceBinding(createRequest);
fail("Should throw an ServiceInstanceBindingExistsException");
} catch (Exception e) {
assertThat(e).isInstanceOf(ServiceInstanceBindingExistsException.class);
}
}
开发者ID:orange-cloudfoundry,项目名称:db-dumper-service,代码行数:11,代码来源:DbDumperServiceInstanceBindingServiceTest.java
示例11: createServiceInstanceBinding
import org.cloudfoundry.community.servicebroker.exception.ServiceInstanceBindingExistsException; //导入依赖的package包/类
@Override
public ServiceInstanceBinding createServiceInstanceBinding(
CreateServiceInstanceBindingRequest request)
throws ServiceInstanceBindingExistsException,
ServiceBrokerException {
String bindingId = request.getBindingId();
String appGuid = request.getAppGuid();
log(bindingId, "Creating service binding for app " + appGuid,
IN_PROGRESS);
throwIfDuplicateBinding(bindingId);
throwIfCopyAlreadyBoundToApp(appGuid, request.getServiceInstanceId());
try {
String instance = instanceService
.getInstanceIdForServiceInstance(request
.getServiceInstanceId());
ServiceInstanceBinding binding = new ServiceInstanceBinding(
bindingId, request.getServiceInstanceId(),
provider.getCreds(instance), null, appGuid);
bindings.saveBinding(binding);
log(bindingId, "Created service binding for app " + appGuid,
COMPLETE);
return binding;
} catch (Exception e) {
log(bindingId, "Failed to bind app " + appGuid, FAILED);
throw e;
}
}
示例12: throwIfCopyAlreadyBoundToApp
import org.cloudfoundry.community.servicebroker.exception.ServiceInstanceBindingExistsException; //导入依赖的package包/类
private void throwIfCopyAlreadyBoundToApp(String appGuid,
String serviceInstanceId)
throws ServiceInstanceBindingExistsException {
List<ServiceInstanceBinding> boundInstances = bindings
.getBindings()
.stream()
.filter(s -> appGuid.equals(s.getAppGuid())
&& serviceInstanceId.equals(s.getServiceInstanceId()))
.collect(Collectors.toList());
if (0 < boundInstances.size()) {
throw new ServiceInstanceBindingExistsException(
boundInstances.get(0));
}
}
示例13: throwIfDuplicateBinding
import org.cloudfoundry.community.servicebroker.exception.ServiceInstanceBindingExistsException; //导入依赖的package包/类
private void throwIfDuplicateBinding(String bindingId)
throws ServiceInstanceBindingExistsException {
if (null != bindings.getBinding(bindingId)) {
throw new ServiceInstanceBindingExistsException(
bindings.getBinding(bindingId));
}
}
示例14: setUp
import org.cloudfoundry.community.servicebroker.exception.ServiceInstanceBindingExistsException; //导入依赖的package包/类
@Before
public void setUp() throws ServiceInstanceBindingExistsException,
ServiceBrokerException {
MockitoAnnotations.initMocks(this);
bindingService = new LCServiceInstanceBindingService(provider,
instanceService, actionRepo, bindingManager);
createServiceInstanceBindingRequest = new CreateServiceInstanceBindingRequest(
"postgrescdm", COPY, "test_app").withBindingId(bindingId).and()
.withServiceInstanceId(serviceInstance.getServiceInstanceId());
}
开发者ID:krujos,项目名称:data-lifecycle-service-broker,代码行数:13,代码来源:LCServiceInstanceBindingServiceCopyTest.java
示例15: duplicateServiceShouldThrow
import org.cloudfoundry.community.servicebroker.exception.ServiceInstanceBindingExistsException; //导入依赖的package包/类
@Test(expected = ServiceInstanceBindingExistsException.class)
public void duplicateServiceShouldThrow()
throws ServiceInstanceBindingExistsException,
ServiceBrokerException {
when(bindingManager.getBinding(any())).thenReturn(
new ServiceInstanceBinding(null, null, null, null, null));
bindResult = bindingService
.createServiceInstanceBinding(createServiceInstanceBindingRequest);
}
开发者ID:krujos,项目名称:data-lifecycle-service-broker,代码行数:12,代码来源:LCServiceInstanceBindingServiceCopyTest.java