org.cloudfoundry.operations.services.Services Java Examples

The following examples show how to use org.cloudfoundry.operations.services.Services. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: CfCreateServiceHelperTest.java    From ya-cf-app-gradle-plugin with Apache License 2.0 6 votes vote down vote up
@Test
public void testCreateServiceWithNoExistingService() {
    CloudFoundryOperations cfOps = mock(CloudFoundryOperations.class);
    Services mockServices = mock(Services.class);

    when(mockServices
        .getInstance(any(GetServiceInstanceRequest.class)))
        .thenReturn(Mono.empty());

    when(cfOps.services()).thenReturn(mockServices);

    CfServiceDetail cfServiceDetail = ImmutableCfServiceDetail
        .builder().name("testName")
        .plan("testPlan")
        .instanceName("inst")
        .build();


    Mono<ServiceInstance> createServiceResult = this.cfCreateServiceHelper.createService(cfOps, cfServiceDetail);

    StepVerifier.create(createServiceResult)
        .verifyComplete();
}
 
Example #2
Source File: CfPushDelegateTest.java    From ya-cf-app-gradle-plugin with Apache License 2.0 6 votes vote down vote up
@Test
public void testCfPushWithoutEnvOrServices() throws Exception {
    CloudFoundryOperations cfOperations = mock(CloudFoundryOperations.class);
    Applications mockApplications = mock(Applications.class);
    when(cfOperations.applications()).thenReturn(mockApplications);
    when(mockApplications.push(any(PushApplicationRequest.class))).thenReturn(Mono.empty());
    when(mockApplications.restart(any(RestartApplicationRequest.class))).thenReturn(Mono.empty());

    Services mockServices = mock(Services.class);
    when(cfOperations.services()).thenReturn(mockServices);
    ServiceInstance mockInstance = ServiceInstance.builder().name("testservice").id("id").type(ServiceInstanceType.MANAGED).build();
    when(mockServices.getInstance(any(GetServiceInstanceRequest.class))).thenReturn(Mono.just(mockInstance));

    CfProperties cfAppProperties = sampleApp();
    cfPushDelegate.push(cfOperations, cfAppProperties);
}
 
Example #3
Source File: CfServicesDetailHelperTest.java    From ya-cf-app-gradle-plugin with Apache License 2.0 6 votes vote down vote up
@Test
public void testGetServiceDetails() {
    CloudFoundryOperations cfOps = mock(CloudFoundryOperations.class);
    Services mockServices = mock(Services.class);

    when(mockServices
        .getInstance(any(GetServiceInstanceRequest.class)))
        .thenReturn(Mono.just(ServiceInstance.builder()
            .id("id")
            .type(ServiceInstanceType.MANAGED)
            .name("test")
            .build()));

    when(cfOps.services()).thenReturn(mockServices);

    Mono<Optional<ServiceInstance>> serviceDetailMono =
        this.cfServicesDetailHelper.getServiceInstanceDetail(cfOps, "srvc");

    StepVerifier.create(serviceDetailMono).expectNextMatches(serviceInstance ->
        serviceInstance.isPresent());
}
 
Example #4
Source File: CfCreateServiceHelperTest.java    From ya-cf-app-gradle-plugin with Apache License 2.0 5 votes vote down vote up
@Test
public void testCreateServiceWithAnExistingService() {
    CloudFoundryOperations cfOps = mock(CloudFoundryOperations.class);
    Services mockServices = mock(Services.class);

    when(mockServices
        .getInstance(any(GetServiceInstanceRequest.class)))
        .thenReturn(Mono.just(ServiceInstance.builder()
            .id("inst")
            .type(ServiceInstanceType.MANAGED)
            .name("inst")
            .build()));

    when(cfOps.services()).thenReturn(mockServices);

    CfServiceDetail cfServiceDetail = ImmutableCfServiceDetail
        .builder().name("testName")
        .plan("testPlan")
        .instanceName("inst")
        .build();
    
    
    Mono<ServiceInstance> createServiceResult = this.cfCreateServiceHelper.createService(cfOps, cfServiceDetail);

    StepVerifier.create(createServiceResult)
        .expectNextMatches(instance -> instance != null)
        .verifyComplete();
}