Search in sources :

Example 6 with Domain

use of org.cloudfoundry.client.v2.domains.Domain in project promregator by promregator.

the class CFAccessorSimulator method retrieveAllDomains.

@Override
public Mono<ListOrganizationDomainsResponse> retrieveAllDomains(String orgId) {
    List<DomainResource> domains = new ArrayList<DomainResource>();
    for (int i = 1; i <= 100; i++) {
        DomainResource domain = DomainResource.builder().entity(DomainEntity.builder().name(SHARED_DOMAIN).internal(false).build()).metadata(Metadata.builder().id(SHARED_DOMAIN_UUID + i).createdAt(CREATED_AT_TIMESTAMP).build()).build();
        domains.add(domain);
    }
    DomainResource domain = DomainResource.builder().entity(DomainEntity.builder().name(INTERNAL_DOMAIN).internal(true).build()).metadata(Metadata.builder().id(INTERNAL_DOMAIN_UUID).createdAt(CREATED_AT_TIMESTAMP).build()).build();
    domains.add(domain);
    ListOrganizationDomainsResponse response = ListOrganizationDomainsResponse.builder().addAllResources(domains).build();
    return Mono.just(response);
}
Also used : DomainResource(org.cloudfoundry.client.v2.domains.DomainResource) ArrayList(java.util.ArrayList) ListOrganizationDomainsResponse(org.cloudfoundry.client.v2.organizations.ListOrganizationDomainsResponse)

Example 7 with Domain

use of org.cloudfoundry.client.v2.domains.Domain in project promregator by promregator.

the class CFAccessorSimulator method retrieveSpaceSummary.

@Override
public Mono<GetSpaceSummaryResponse> retrieveSpaceSummary(String spaceId) {
    if (spaceId.equals(SPACE_UUID)) {
        List<SpaceApplicationSummary> list = new LinkedList<>();
        for (int i = 1; i <= 100; i++) {
            Domain sharedDomain = Domain.builder().id(SHARED_DOMAIN_UUID + i).name(SHARED_DOMAIN).build();
            final String[] urls = { APP_HOST_PREFIX + i + "." + SHARED_DOMAIN };
            final Route[] routes = { Route.builder().domain(sharedDomain).host(APP_HOST_PREFIX + i).build() };
            SpaceApplicationSummary sas = SpaceApplicationSummary.builder().id(APP_UUID_PREFIX + i).name("testapp" + i).addAllUrls(Arrays.asList(urls)).addAllRoutes(Arrays.asList(routes)).instances(this.amountInstances).state("STARTED").build();
            list.add(sas);
        }
        GetSpaceSummaryResponse resp = GetSpaceSummaryResponse.builder().addAllApplications(list).build();
        return Mono.just(resp).delayElement(this.getSleepRandomDuration());
    }
    log.error("Invalid retrieveSpaceSummary request");
    return null;
}
Also used : GetSpaceSummaryResponse(org.cloudfoundry.client.v2.spaces.GetSpaceSummaryResponse) SpaceApplicationSummary(org.cloudfoundry.client.v2.spaces.SpaceApplicationSummary) Domain(org.cloudfoundry.client.v2.domains.Domain) LinkedList(java.util.LinkedList) Route(org.cloudfoundry.client.v2.routes.Route)

Example 8 with Domain

use of org.cloudfoundry.client.v2.domains.Domain in project promregator by promregator.

the class CFAccessorSimulatorTest method testRetrieveAllDomains.

@Test
void testRetrieveAllDomains() {
    CFAccessorSimulator subject = new CFAccessorSimulator(2);
    Mono<ListOrganizationDomainsResponse> mono = subject.retrieveAllDomains(CFAccessorSimulator.ORG_UUID);
    ListOrganizationDomainsResponse result = mono.block();
    Assertions.assertNotNull(result);
    Assertions.assertNotNull(result.getResources());
    Assertions.assertEquals(101, result.getResources().size());
    for (int i = 0; i <= 99; i++) {
        int domainSequenceId = i + 1;
        DomainResource item = result.getResources().get(i);
        Assertions.assertEquals(CFAccessorSimulator.SHARED_DOMAIN, item.getEntity().getName());
        Assertions.assertFalse(item.getEntity().getInternal());
        Assertions.assertTrue(item.getMetadata().getId().contains(CFAccessorSimulator.SHARED_DOMAIN_UUID + domainSequenceId));
    }
    // get the shared domain
    DomainResource sharedDomain = result.getResources().get(100);
    Assertions.assertTrue(sharedDomain.getEntity().getInternal());
    Assertions.assertEquals(CFAccessorSimulator.INTERNAL_DOMAIN, sharedDomain.getEntity().getName());
}
Also used : DomainResource(org.cloudfoundry.client.v2.domains.DomainResource) ListOrganizationDomainsResponse(org.cloudfoundry.client.v2.organizations.ListOrganizationDomainsResponse) Test(org.junit.jupiter.api.Test)

Example 9 with Domain

use of org.cloudfoundry.client.v2.domains.Domain in project promregator by promregator.

the class CFAccessorMock method retrieveAllDomains.

@Override
public Mono<ListOrganizationDomainsResponse> retrieveAllDomains(String orgId) {
    List<DomainResource> domains = new ArrayList<DomainResource>();
    DomainResource domain = DomainResource.builder().entity(DomainEntity.builder().name(UNITTEST_INTERNAL_DOMAIN).internal(true).build()).metadata(Metadata.builder().id(UNITTEST_INTERNAL_DOMAIN_UUID).createdAt(CREATED_AT_TIMESTAMP).build()).build();
    domains.add(domain);
    domain = DomainResource.builder().entity(DomainEntity.builder().name(UNITTEST_SHARED_DOMAIN).internal(false).build()).metadata(Metadata.builder().id(UNITTEST_SHARED_DOMAIN_UUID).createdAt(CREATED_AT_TIMESTAMP).build()).build();
    domains.add(domain);
    domain = DomainResource.builder().entity(DomainEntity.builder().name(UNITTEST_ADDITIONAL_SHARED_DOMAIN).internal(false).build()).metadata(Metadata.builder().id(UNITTEST_ADDITIONAL_SHARED_DOMAIN_UUID).createdAt(CREATED_AT_TIMESTAMP).build()).build();
    domains.add(domain);
    ListOrganizationDomainsResponse response = ListOrganizationDomainsResponse.builder().addAllResources(domains).build();
    return Mono.just(response);
}
Also used : DomainResource(org.cloudfoundry.client.v2.domains.DomainResource) ArrayList(java.util.ArrayList) ListOrganizationDomainsResponse(org.cloudfoundry.client.v2.organizations.ListOrganizationDomainsResponse)

Example 10 with Domain

use of org.cloudfoundry.client.v2.domains.Domain in project promregator by promregator.

the class CFAccessorMassMock method retrieveSpaceSummary.

@Override
public Mono<GetSpaceSummaryResponse> retrieveSpaceSummary(String spaceId) {
    if (spaceId.equals(UNITTEST_SPACE_UUID)) {
        List<SpaceApplicationSummary> list = new LinkedList<>();
        for (int i = 0; i < 100; i++) {
            Domain sharedDomain = Domain.builder().id(UNITTEST_SHARED_DOMAIN_UUID + i).name(UNITTEST_SHARED_DOMAIN).build();
            final String[] urls = { "hostapp" + i + "." + UNITTEST_SHARED_DOMAIN };
            final Route[] routes = { Route.builder().domain(sharedDomain).host("hostapp" + i).build() };
            SpaceApplicationSummary sas = SpaceApplicationSummary.builder().id(UNITTEST_APP_UUID_PREFIX + i).name("testapp" + i).addAllUrls(Arrays.asList(urls)).addAllRoutes(Arrays.asList(routes)).instances(this.amountInstances).build();
            list.add(sas);
        }
        GetSpaceSummaryResponse resp = GetSpaceSummaryResponse.builder().addAllApplications(list).build();
        return Mono.just(resp).delayElement(this.getSleepRandomDuration());
    }
    Assertions.fail("Invalid retrieveSpaceSummary request");
    return null;
}
Also used : GetSpaceSummaryResponse(org.cloudfoundry.client.v2.spaces.GetSpaceSummaryResponse) SpaceApplicationSummary(org.cloudfoundry.client.v2.spaces.SpaceApplicationSummary) Domain(org.cloudfoundry.client.v2.domains.Domain) LinkedList(java.util.LinkedList) Route(org.cloudfoundry.client.v2.routes.Route)

Aggregations

LinkedList (java.util.LinkedList)12 SpaceApplicationSummary (org.cloudfoundry.client.v2.spaces.SpaceApplicationSummary)11 Flux (reactor.core.publisher.Flux)11 Mono (reactor.core.publisher.Mono)11 OrganizationResource (org.cloudfoundry.client.v2.organizations.OrganizationResource)10 SharedDomainEntity (org.cloudfoundry.client.v2.shareddomains.SharedDomainEntity)10 GetSpaceSummaryResponse (org.cloudfoundry.client.v2.spaces.GetSpaceSummaryResponse)10 SpaceResource (org.cloudfoundry.client.v2.spaces.SpaceResource)10 ApplicationResource (org.cloudfoundry.client.v2.applications.ApplicationResource)9 IOException (java.io.IOException)8 Path (java.nio.file.Path)8 Duration (java.time.Duration)8 Map (java.util.Map)8 Assertions.assertThat (org.assertj.core.api.Assertions.assertThat)8 CloudFoundryClient (org.cloudfoundry.client.CloudFoundryClient)8 Arrays (java.util.Arrays)7 Collection (java.util.Collection)7 Collections (java.util.Collections)7 Date (java.util.Date)7 Optional (java.util.Optional)7