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


Java ServiceInstanceBinding类代码示例

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


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

示例1: testCreateInstanceBindingPlanShared_success_shouldReturnBinding

import org.cloudfoundry.community.servicebroker.model.ServiceInstanceBinding; //导入依赖的package包/类
@Test
public void testCreateInstanceBindingPlanShared_success_shouldReturnBinding() throws Exception {
  String instanceId = UUID.randomUUID().toString();
  CreateServiceInstanceRequest request = getCreateInstanceRequest(instanceId,
                                                                  "shared-plan");
  instanceService.createServiceInstance(request);
  CreateServiceInstanceBindingRequest bindingRequest =
      new CreateServiceInstanceBindingRequest(getServiceInstance(instanceId)
                                                  .getServiceDefinitionId(),
                                              "FAKE-BASE_GUID-shared-plan",
                                              "appGuid").withBindingId("bindingId")
          .withServiceInstanceId(instanceId);
  ServiceInstanceBinding binding = instanceBindingService.createServiceInstanceBinding(
      bindingRequest);
  assertThat(binding.getServiceInstanceId(), equalTo(instanceId));
}
 
开发者ID:trustedanalytics,项目名称:hive-broker,代码行数:17,代码来源:HiveBrokerIntegrationTest.java

示例2: deleteServiceInstanceBinding

import org.cloudfoundry.community.servicebroker.model.ServiceInstanceBinding; //导入依赖的package包/类
@Override
public ServiceInstanceBinding deleteServiceInstanceBinding(DeleteServiceInstanceBindingRequest request) throws ServiceBrokerException {
    DbDumperServiceInstanceBinding dbDumperServiceInstanceBinding = repositoryInstanceBinding.findOne(request.getBindingId());
    if (dbDumperServiceInstanceBinding == null) {
        throw new ServiceBrokerException("Cannot find binding instance: " + request.getBindingId());
    }
    Map<String, Object> credentials = Maps.newHashMap();
    ServiceInstanceBinding serviceInstanceBinding = new ServiceInstanceBinding(
            dbDumperServiceInstanceBinding.getId(),
            dbDumperServiceInstanceBinding.getDbDumperServiceInstance().getServiceInstanceId(),
            credentials,
            null,
            dbDumperServiceInstanceBinding.getAppGuid()
    );
    repositoryInstanceBinding.delete(dbDumperServiceInstanceBinding);
    return serviceInstanceBinding;
}
 
开发者ID:orange-cloudfoundry,项目名称:db-dumper-service,代码行数:18,代码来源:DbDumperServiceInstanceBindingService.java

示例3: when

import org.cloudfoundry.community.servicebroker.model.ServiceInstanceBinding; //导入依赖的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

示例4: assertCredentials

import org.cloudfoundry.community.servicebroker.model.ServiceInstanceBinding; //导入依赖的package包/类
public void assertCredentials(ServiceInstanceBinding serviceInstanceBinding, List<DbDumperCredential> dbDumperCredentials) {
    Map<String, Object> credentials = serviceInstanceBinding.getCredentials();
    List<Map<String, Object>> dumpFiles = (List<Map<String, Object>>) credentials.get("dumps");
    assertThat(dumpFiles).hasSize(dbDumperCredentials.size());
    SimpleDateFormat dateFormater = new SimpleDateFormat(this.dateFormat);
    assertThat(credentials.get("database_type")).isEqualTo(DATABASE_TYPE.name());
    assertThat(credentials.get("database_ref")).isEqualTo(databaseRef.getInUrlFormat());
    for (int i = 0; i < dumpFiles.size(); i++) {
        Map<String, Object> dumpFile = dumpFiles.get(i);
        DbDumperCredential dbDumperCredential = dbDumperCredentials.get(i);
        assertThat(dumpFile.get("size")).isEqualTo(dbDumperCredential.getSize());
        assertThat(dumpFile.get("download_url")).isEqualTo(dbDumperCredential.getDownloadUrl());
        assertThat(dumpFile.get("show_url")).isEqualTo(dbDumperCredential.getShowUrl());
        assertThat(dumpFile.get("filename")).isEqualTo(dbDumperCredential.getFilename());
        assertThat(dumpFile.get("created_at")).isEqualTo(dateFormater.format(dbDumperCredential.getCreatedAt()));
        assertThat(dumpFile.get("dump_id")).isEqualTo(dbDumperCredential.getId());
        assertThat(dumpFile.get("deleted")).isEqualTo(dbDumperCredential.getDeleted());
        assertThat(dumpFile.get("tags")).isEqualTo(dbDumperCredential.getTags());
    }

}
 
开发者ID:orange-cloudfoundry,项目名称:db-dumper-service,代码行数:22,代码来源:DbDumperServiceInstanceBindingServiceTest.java

示例5: createServiceInstanceBinding

import org.cloudfoundry.community.servicebroker.model.ServiceInstanceBinding; //导入依赖的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

示例6: deleteServiceInstanceBinding

import org.cloudfoundry.community.servicebroker.model.ServiceInstanceBinding; //导入依赖的package包/类
@Override
public ServiceInstanceBinding deleteServiceInstanceBinding(
		DeleteServiceInstanceBindingRequest request)
		throws ServiceBrokerException {
	try {
		log(request.getBindingId(), "Removing binding ", IN_PROGRESS);
		ServiceInstanceBinding binding = bindings.removeBinding(request
				.getBindingId());
		log(request.getBindingId(), "Removing binding ", COMPLETE);

		return binding;
	} catch (Exception e) {
		log(request.getBindingId(), "Failed to remove binding ", FAILED);
		throw e;
	}
}
 
开发者ID:krujos,项目名称:data-lifecycle-service-broker,代码行数:17,代码来源:LCServiceInstanceBindingService.java

示例7: itShouldNotBindToTheSameAppTwice

import org.cloudfoundry.community.servicebroker.model.ServiceInstanceBinding; //导入依赖的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

示例8: itShouldReturnAppToInstancePairsAndBindToMutipleApps

import org.cloudfoundry.community.servicebroker.model.ServiceInstanceBinding; //导入依赖的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

示例9: buildServiceInstanceBindings

import org.cloudfoundry.community.servicebroker.model.ServiceInstanceBinding; //导入依赖的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

示例10: itShouldReturnTheProdCreds

import org.cloudfoundry.community.servicebroker.model.ServiceInstanceBinding; //导入依赖的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

示例11: createServiceInstanceBinding

import org.cloudfoundry.community.servicebroker.model.ServiceInstanceBinding; //导入依赖的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);
}
 
开发者ID:trustedanalytics,项目名称:broker-store,代码行数:23,代码来源:ServiceInstanceBindingServiceStore.java

示例12: deleteServiceInstanceBinding

import org.cloudfoundry.community.servicebroker.model.ServiceInstanceBinding; //导入依赖的package包/类
@Override
public ServiceInstanceBinding deleteServiceInstanceBinding(DeleteServiceInstanceBindingRequest deleteRequest)
        throws ServiceBrokerException {
    LOGGER.debug(LoggerHelper.getParamsAsString("deleteServiceInstanceBinding", deleteRequest.getBindingId(),
            deleteRequest.getInstance(), deleteRequest.getServiceId(), deleteRequest.getPlanId()));
    Optional<ServiceInstanceBinding> bindingInstance;
    try {
        Location storingLocation = Location.newInstance(deleteRequest.getBindingId(),
            deleteRequest.getInstance().getServiceInstanceId());

        bindingInstance = store.deleteById(storingLocation)
                .map(createRequest -> rewriteMissingAttrs(createRequest, deleteRequest))
                .map(this::getServiceInstanceBinding);

    } catch (IOException e) {
        throw new ServiceBrokerException(e.getMessage(), e);
    }
    return bindingInstance.orElse(null);
}
 
开发者ID:trustedanalytics,项目名称:broker-store,代码行数:20,代码来源:ServiceInstanceBindingServiceStore.java

示例13: createServiceInstanceBinding

import org.cloudfoundry.community.servicebroker.model.ServiceInstanceBinding; //导入依赖的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

示例14: testCreateInstanceAndBinding_success_shouldReturnCredentialsMap

import org.cloudfoundry.community.servicebroker.model.ServiceInstanceBinding; //导入依赖的package包/类
@Test
public void testCreateInstanceAndBinding_success_shouldReturnCredentialsMap() throws Exception {
  // arrange
  final String INSTANCE_ID = "instanceId2";
  final String BINDING_ID = "bindingId2";
  when(h2oProvisionerRestApi.createH2oInstance(INSTANCE_ID, conf.getH2oMapperNodes(),
      conf.getH2oMapperMemory(), true, yarnConfig))
          .thenReturn(new ResponseEntity<>(CREDENTIALS, HttpStatus.OK));
  instanceService
      .createServiceInstance(CfBrokerRequestsFactory.getCreateInstanceRequest(INSTANCE_ID));
  freeze().until(() -> credentialsStore.getById(Location.newInstance(INSTANCE_ID)).isPresent());

  // act
  CreateServiceInstanceBindingRequest request =
      CfBrokerRequestsFactory.getCreateServiceBindingRequest(INSTANCE_ID, BINDING_ID);
  ServiceInstanceBinding createdBinding = bindingService.createServiceInstanceBinding(request);

  // assert
  Map<String, Object> credentials = createdBinding.getCredentials();
  assertThat(createdBinding.getServiceInstanceId(), equalTo(INSTANCE_ID));
  assertThat(credentials.get("hostname"), equalTo("http://h2o.com"));
  assertThat(credentials.get("port"), equalTo("54321"));
  assertThat(credentials.get("username"), equalTo("user"));
  assertThat(credentials.get("password"), equalTo("pass"));
}
 
开发者ID:trustedanalytics,项目名称:h2o-broker,代码行数:26,代码来源:H2oBrokerIntegrationTest.java

示例15: createServiceInstanceBinding_credentialsInStore_bindingCreated

import org.cloudfoundry.community.servicebroker.model.ServiceInstanceBinding; //导入依赖的package包/类
@Test
public void createServiceInstanceBinding_credentialsInStore_bindingCreated() throws Exception {
  // arrange
  CreateServiceInstanceBindingRequest request =
      CfBrokerRequestsFactory.getCreateServiceBindingRequest(INSTANCE_ID, BINDING_ID);
  when(delegateMock.createServiceInstanceBinding(request))
      .thenReturn(new ServiceInstanceBinding(BINDING_ID, INSTANCE_ID, null, SYSLOG, APP_GUID));

  H2oCredentials expectedCredentials = new H2oCredentials("a", "b", "c", "d");
  when(credentialsStoreMock.getById(Location.newInstance(INSTANCE_ID)))
      .thenReturn(Optional.of(expectedCredentials));

  // act
  ServiceInstanceBinding createdBinding = bindingService.createServiceInstanceBinding(request);

  // assert
  assertThat(createdBinding.getId(), equalTo(BINDING_ID));
  assertThat(createdBinding.getServiceInstanceId(), equalTo(INSTANCE_ID));
  assertThat(createdBinding.getSyslogDrainUrl(), equalTo(SYSLOG));
  assertThat(createdBinding.getAppGuid(), equalTo(APP_GUID));
  assertThat(createdBinding.getCredentials(), equalTo(expectedCredentials.toMap()));
}
 
开发者ID:trustedanalytics,项目名称:h2o-broker,代码行数:23,代码来源:H2oServiceInstanceBindingServiceTest.java


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