Search in sources :

Example 1 with EventEntity

use of org.cloudfoundry.client.v2.events.EventEntity in project cf-java-client by cloudfoundry.

the class DefaultApplicationsTest method requestEvents.

private static void requestEvents(CloudFoundryClient cloudFoundryClient, String applicationId, EventEntity... entities) {
    ListEventsResponse.Builder responseBuilder = fill(ListEventsResponse.builder());
    for (EventEntity entity : entities) {
        responseBuilder.resource(EventResource.builder().metadata(fill(Metadata.builder()).id("test-event-id").build()).entity(entity).build());
    }
    when(cloudFoundryClient.events().list(ListEventsRequest.builder().actee(applicationId).orderDirection(OrderDirection.DESCENDING).resultsPerPage(50).page(1).build())).thenReturn(Mono.just(responseBuilder.totalPages(1).build()));
}
Also used : ListEventsResponse(org.cloudfoundry.client.v2.events.ListEventsResponse) EventEntity(org.cloudfoundry.client.v2.events.EventEntity)

Example 2 with EventEntity

use of org.cloudfoundry.client.v2.events.EventEntity in project cf-java-client by cloudfoundry.

the class DefaultApplications method convertToApplicationEvent.

private static ApplicationEvent convertToApplicationEvent(EventResource resource) {
    EventEntity entity = resource.getEntity();
    Date timestamp = null;
    try {
        timestamp = DateUtils.parseFromIso8601(entity.getTimestamp());
    } catch (IllegalArgumentException iae) {
    // do not set time
    }
    return ApplicationEvent.builder().actor(entity.getActorName()).description(eventDescription(getMetadataRequest(entity), getEntryNames(entity.getType()))).id(ResourceUtils.getId(resource)).event(entity.getType()).time(timestamp).build();
}
Also used : EventEntity(org.cloudfoundry.client.v2.events.EventEntity) Date(java.util.Date)

Aggregations

EventEntity (org.cloudfoundry.client.v2.events.EventEntity)2 Date (java.util.Date)1 ListEventsResponse (org.cloudfoundry.client.v2.events.ListEventsResponse)1