本文整理汇总了Java中org.springframework.cloud.servicebroker.model.CreateServiceInstanceRequest类的典型用法代码示例。如果您正苦于以下问题:Java CreateServiceInstanceRequest类的具体用法?Java CreateServiceInstanceRequest怎么用?Java CreateServiceInstanceRequest使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
CreateServiceInstanceRequest类属于org.springframework.cloud.servicebroker.model包,在下文中一共展示了CreateServiceInstanceRequest类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: createServiceInstance
import org.springframework.cloud.servicebroker.model.CreateServiceInstanceRequest; //导入依赖的package包/类
@Override
public CreateServiceInstanceResponse createServiceInstance(CreateServiceInstanceRequest request) {
// TODO MongoDB dashboard
ServiceInstance instance = repository.findOne(request.getServiceInstanceId());
if (instance != null) {
throw new ServiceInstanceExistsException(request.getServiceInstanceId(), request.getServiceDefinitionId());
}
instance = new ServiceInstance(request);
if (mongo.databaseExists(instance.getServiceInstanceId())) {
// ensure the instance is empty
mongo.deleteDatabase(instance.getServiceInstanceId());
}
DB db = mongo.createDatabase(instance.getServiceInstanceId());
if (db == null) {
throw new ServiceBrokerException("Failed to create new DB instance: " + instance.getServiceInstanceId());
}
repository.save(instance);
return new CreateServiceInstanceResponse();
}
示例2: newServiceInstanceCreatedSuccessfullyWithExistingDB
import org.springframework.cloud.servicebroker.model.CreateServiceInstanceRequest; //导入依赖的package包/类
@Test
public void newServiceInstanceCreatedSuccessfullyWithExistingDB() throws Exception {
when(repository.findOne(any(String.class))).thenReturn(null);
when(mongo.databaseExists(any(String.class))).thenReturn(true);
when(mongo.createDatabase(any(String.class))).thenReturn(db);
CreateServiceInstanceRequest request = buildCreateRequest();
CreateServiceInstanceResponse response = service.createServiceInstance(request);
assertNotNull(response);
assertNull(response.getDashboardUrl());
assertFalse(response.isAsync());
verify(mongo).deleteDatabase(request.getServiceInstanceId());
verify(repository).save(isA(ServiceInstance.class));
}
示例3: should_map_create_service_instance_request
import org.springframework.cloud.servicebroker.model.CreateServiceInstanceRequest; //导入依赖的package包/类
@Test
public void should_map_create_service_instance_request() throws Exception {
SuffixedServiceInstanceRequestMapper mapper = new SuffixedServiceInstanceRequestMapper("-suffixed");
Map<String, Object> parameters = new HashMap<>();
parameters.put("key1", "value1");
Assert.assertEquals(new CreateServiceInstanceRequest("serviceDefinitionId",
"planId",
"organizationGuid",
"spaceGuid",
parameters)
.withServiceInstanceId("serviceInstanceId")
.withAsyncAccepted(true),
mapper.map(new CreateServiceInstanceRequest("serviceDefinitionId-suffixed",
"planId-suffixed",
"organizationGuid",
"spaceGuid",
parameters)
.withServiceInstanceId("serviceInstanceId")
.withAsyncAccepted(true)));
}
开发者ID:orange-cloudfoundry,项目名称:sec-group-broker-filter,代码行数:23,代码来源:SuffixedServiceInstanceRequestMapperTest.java
示例4: testGetCredentials
import org.springframework.cloud.servicebroker.model.CreateServiceInstanceRequest; //导入依赖的package包/类
@Test
public void testGetCredentials() throws Exception {
VrServiceInstance si = TestConfig.getServiceInstance();
CreateServiceInstanceRequest request = request();
for (String s : request.getParameters().keySet()) {
si.getParameters().put(s, request.getParameters().get(s));
}
//add the service type and host in: this data comes later after the request completes
si.getMetadata().put(VrServiceInstance.SERVICE_TYPE, "mysql");
si.getMetadata().put(VrServiceInstance.HOST, "192.168.0.1");
Map<String, Object> creds = Adaptors.getCredentials(si);
assertNotNull(creds);
assertEquals("mysql://root:[email protected]:1234/testDb",
creds.get(VrServiceInstance.URI));
}
示例5: ServiceInstance
import org.springframework.cloud.servicebroker.model.CreateServiceInstanceRequest; //导入依赖的package包/类
public ServiceInstance(CreateServiceInstanceRequest request) {
super();
serviceDefinitionId = request.getServiceDefinitionId();
planId = request.getPlanId();
organizationGuid = request.getOrganizationGuid();
spaceGuid = request.getSpaceGuid();
serviceInstanceId = request.getServiceInstanceId();
lastOperation = new LastOperationSerializer(
OperationState.IN_PROGRESS, "Provisioning", false);
// name is set on 1st create only, not by connecting remotely
name = serviceInstanceId;
// add a reference to itself, used to find remotely created instances
// of the same actual service instance
references.add(serviceInstanceId);
}
示例6: createServiceInstanceWithAsyncSucceeds
import org.springframework.cloud.servicebroker.model.CreateServiceInstanceRequest; //导入依赖的package包/类
@Test
public void createServiceInstanceWithAsyncSucceeds() throws Exception {
when(serviceInstanceService.createServiceInstance(eq(asyncCreateRequest)))
.thenReturn(asyncCreateResponse);
setupCatalogService(asyncCreateRequest.getServiceDefinitionId());
mockMvc.perform(put(buildUrl(asyncCreateRequest, false))
.content(DataFixture.toJson(asyncCreateRequest))
.contentType(MediaType.APPLICATION_JSON)
.accept(MediaType.APPLICATION_JSON))
.andExpect(status().isAccepted())
.andExpect(jsonPath("$.dashboard_url", is(asyncCreateResponse.getDashboardUrl())))
.andExpect(jsonPath("$.operation", is(asyncCreateResponse.getOperation())));
CreateServiceInstanceRequest actualRequest = verifyCreateServiceInstance();
assertTrue(actualRequest.isAsyncAccepted());
assertNull(actualRequest.getApiInfoLocation());
assertNull(actualRequest.getCfInstanceId());
assertNull(actualRequest.getOriginatingIdentity());
}
开发者ID:spring-cloud,项目名称:spring-cloud-cloudfoundry-service-broker,代码行数:22,代码来源:ServiceInstanceControllerIntegrationTest.java
示例7: createServiceInstance
import org.springframework.cloud.servicebroker.model.CreateServiceInstanceRequest; //导入依赖的package包/类
@PutMapping(value = {
"/{cfInstanceId}/v2/service_instances/{instanceId}",
"/v2/service_instances/{instanceId}"
})
public ResponseEntity<?> createServiceInstance(@PathVariable Map<String, String> pathVariables,
@PathVariable("instanceId") String serviceInstanceId,
@RequestParam(value = ASYNC_REQUEST_PARAMETER, required = false) boolean acceptsIncomplete,
@RequestHeader(value = API_INFO_LOCATION_HEADER, required = false) String apiInfoLocation,
@RequestHeader(value = ORIGINATING_IDENTITY_HEADER, required = false) String originatingIdentityString,
@Valid @RequestBody CreateServiceInstanceRequest request) {
ServiceDefinition serviceDefinition = getRequiredServiceDefinition(request.getServiceDefinitionId());
request.setServiceInstanceId(serviceInstanceId);
request.setServiceDefinition(serviceDefinition);
setCommonRequestFields(request, pathVariables.get("cfInstanceId"), apiInfoLocation,
originatingIdentityString, acceptsIncomplete);
log.debug("Creating a service instance: request={}", request);
CreateServiceInstanceResponse response = service.createServiceInstance(request);
log.debug("Creating a service instance succeeded: serviceInstanceId={}, response={}",
serviceInstanceId, response);
return new ResponseEntity<>(response, getCreateResponseCode(response));
}
开发者ID:spring-cloud,项目名称:spring-cloud-cloudfoundry-service-broker,代码行数:27,代码来源:ServiceInstanceController.java
示例8: createBlueprint
import org.springframework.cloud.servicebroker.model.CreateServiceInstanceRequest; //导入依赖的package包/类
@VisibleForTesting
public String createBlueprint(ServiceDefinition serviceDefinition, CreateServiceInstanceRequest request) {
String location = "localhost"; // default
Plan selectedPlan = null;
for(Plan p : serviceDefinition.getPlans()){
if(p.getId().equals(request.getPlanId())){
selectedPlan = p;
}
}
Map<String, Object> metadata = serviceDefinition.getMetadata();
String brooklynCatalogId = (String) metadata.get("brooklynCatalogId");
String blueprint = ((BlueprintPlan)selectedPlan).toBlueprint(brooklynCatalogId, location, request);
LOG.info("launching from blueprint: [blueprint={}]", blueprint);
return blueprint;
}
开发者ID:cloudfoundry-incubator,项目名称:apache-brooklyn-service-broker,代码行数:17,代码来源:BrooklynServiceInstanceService.java
示例9: newServiceInstanceCreatedSuccessfully
import org.springframework.cloud.servicebroker.model.CreateServiceInstanceRequest; //导入依赖的package包/类
@Test
public void newServiceInstanceCreatedSuccessfully()
throws ServiceInstanceExistsException, ServiceBrokerException {
when(admin.createApplication(any(String.class))).thenReturn(new AsyncResult<>(entity));
when(catalogService.getServiceDefinition(any(String.class))).thenReturn(serviceDefinition);
when(serviceDefinition.getPlans()).thenReturn(ImmutableList.of(new DefaultBlueprintPlan("planId", "test_name", "test_description","Test App", ImmutableMap.of("location", "test_location"))));
when(serviceDefinition.getId()).thenReturn(SVC_DEFINITION_ID);
when(admin.getDashboardUrl(any(String.class))).thenReturn(new AsyncResult<>(null));
CreateServiceInstanceRequest request = new CreateServiceInstanceRequest(serviceDefinition.getId(), "planId", "organizationGuid", "spaceGuid");
CreateServiceInstanceResponse instance = service.createServiceInstance(request.withServiceInstanceId(SVC_INST_ID));
assertNotNull(instance);
// TODO: assert service instance created successfully
// assertEquals(SVC_INST_ID, instance.getServiceInstanceId());
}
开发者ID:cloudfoundry-incubator,项目名称:apache-brooklyn-service-broker,代码行数:18,代码来源:BrooklynServiceInstanceServiceTest.java
示例10: testCreateBlueprintWithProvisioningProperties
import org.springframework.cloud.servicebroker.model.CreateServiceInstanceRequest; //导入依赖的package包/类
@Test
public void testCreateBlueprintWithProvisioningProperties() {
when(serviceDefinition.getId()).thenReturn("testService");
CreateServiceInstanceRequest request = new CreateServiceInstanceRequest(serviceDefinition.getId(), "planId", "organizationGuid", "spaceGuid", null)
.withServiceInstanceId(SVC_INST_ID);
when(serviceDefinition.getPlans()).thenReturn(ImmutableList.of(
new DefaultBlueprintPlan("planId", "planName", "planDescription","Test App", ImmutableMap.of(
"location", "testLocation",
"provisioning.properties", ImmutableMap.of(
"minCores", TEST_MIN_CORES,
"minRam", TEST_MIN_RAM
)
))
));
when(serviceDefinition.getMetadata()).thenReturn(ImmutableMap.of("brooklynCatalogId", "testService"));
String expectedBlueprint = String.format("{\"name\":\"Test App (CFService)\",\"services\":[{\"type\": \"%s\"}], \"locations\": [\"%s\"], \"brooklyn.config\":{\"provisioning.properties\":{\"minCores\":%d,\"minRam\":%d}}}", serviceDefinition.getId(), "testLocation", TEST_MIN_CORES, TEST_MIN_RAM);
String blueprint = service.createBlueprint(serviceDefinition, request);
// Remove whitespace for assertion so we're not tied to the implementation's whitespace rules
assertEquals(expectedBlueprint.replace(" ", ""), blueprint.replace(" ", ""));
}
开发者ID:cloudfoundry-incubator,项目名称:apache-brooklyn-service-broker,代码行数:21,代码来源:BrooklynServiceInstanceServiceTest.java
示例11: testCreateBlueprintWithBrooklynProperties
import org.springframework.cloud.servicebroker.model.CreateServiceInstanceRequest; //导入依赖的package包/类
@Test
public void testCreateBlueprintWithBrooklynProperties() {
when(serviceDefinition.getId()).thenReturn("testService");
CreateServiceInstanceRequest request = new CreateServiceInstanceRequest(serviceDefinition.getId(), "planId", "organizationGuid", "spaceGuid", null)
.withServiceInstanceId(SVC_INST_ID);
when(serviceDefinition.getPlans()).thenReturn(ImmutableList.of(
new DefaultBlueprintPlan("planId", "planName", "planDescription", "Test App", ImmutableMap.of(
"location", "testLocation",
"provisioning.properties", ImmutableMap.of(
"minCores", TEST_MIN_CORES,
"minRam", TEST_MIN_RAM
)
))
));
when(serviceDefinition.getMetadata()).thenReturn(ImmutableMap.of("brooklynCatalogId", "testService"));
String expectedBlueprint = String.format("{\"name\":\"Test App (CFService)\",\"services\":[{\"type\": \"%s\"}], \"locations\": [\"%s\"], \"brooklyn.config\":{\"provisioning.properties\":{\"minCores\":%d,\"minRam\":%d}}}", serviceDefinition.getId(), "testLocation", TEST_MIN_CORES, TEST_MIN_RAM);
String blueprint = service.createBlueprint(serviceDefinition, request);
// Remove whitespace for assertion so we're not tied to the implementation's whitespace rules
assertEquals(expectedBlueprint.replace(" ", ""), blueprint.replace(" ", ""));
}
开发者ID:cloudfoundry-incubator,项目名称:apache-brooklyn-service-broker,代码行数:22,代码来源:BrooklynServiceInstanceServiceTest.java
示例12: createServiceInstance
import org.springframework.cloud.servicebroker.model.CreateServiceInstanceRequest; //导入依赖的package包/类
@Override
public CreateServiceInstanceResponse createServiceInstance(CreateServiceInstanceRequest request) {
// TODO MongoDB dashboard
ServiceInstance instance = repository.findOne(request.getServiceInstanceId());
if (instance != null) {
throw new ServiceInstanceExistsException(request.getServiceInstanceId(), request.getServiceDefinitionId());
}
instance = new ServiceInstance(request);
if (mongo.databaseExists(instance.getServiceInstanceId())) {
// ensure the instance is empty
mongo.deleteDatabase(instance.getServiceInstanceId());
}
MongoDatabase db = mongo.createDatabase(instance.getServiceInstanceId());
if (db == null) {
throw new ServiceBrokerException("Failed to create new DB instance: " + instance.getServiceInstanceId());
}
repository.save(instance);
return new CreateServiceInstanceResponse();
}
开发者ID:spring-cloud-samples,项目名称:cloudfoundry-service-broker,代码行数:24,代码来源:MongoServiceInstanceService.java
示例13: ServiceInstance
import org.springframework.cloud.servicebroker.model.CreateServiceInstanceRequest; //导入依赖的package包/类
/**
* Create a ServiceInstance from a create request. If fields
* are not present in the request they will remain null in the
* ServiceInstance.
*
* @param request containing details of ServiceInstance
*/
public ServiceInstance(CreateServiceInstanceRequest request) {
this.serviceDefinitionId = request.getServiceDefinitionId();
this.planId = request.getPlanId();
this.organizationGuid = request.getOrganizationGuid();
this.spaceGuid = request.getSpaceGuid();
this.id = request.getServiceInstanceId();
}
示例14: serviceInstanceWithParams
import org.springframework.cloud.servicebroker.model.CreateServiceInstanceRequest; //导入依赖的package包/类
@Bean
public ServiceInstance serviceInstanceWithParams() {
Map<String, Object> params = new HashMap<>();
long l = System.currentTimeMillis();
params.put(POSTGRES_DB, "testDb" + l);
return new ServiceInstance(new CreateServiceInstanceRequest(null, null, null, null, params));
}
示例15: ServiceInstance
import org.springframework.cloud.servicebroker.model.CreateServiceInstanceRequest; //导入依赖的package包/类
/**
* Create a ServiceInstance from a create request. If fields
* are not present in the request they will remain null in the
* ServiceInstance.
* @param request containing details of ServiceInstance
*/
public ServiceInstance(CreateServiceInstanceRequest request) {
this.serviceDefinitionId = request.getServiceDefinitionId();
this.planId = request.getPlanId();
this.organizationGuid = request.getOrganizationGuid();
this.spaceGuid = request.getSpaceGuid();
this.id = request.getServiceInstanceId();
}