Search in sources :

Example 26 with Collection

use of java.util.Collection in project spring-boot-admin by codecentric.

the class HazelcastJournaledEventStoreTest method test_store.

@Test
public void test_store() {
    Application application = Application.create("foo").withId("bar").withHealthUrl("http://health").build();
    List<ClientApplicationEvent> events = Arrays.asList(new ClientApplicationRegisteredEvent(application), new ClientApplicationDeregisteredEvent(application));
    for (ClientApplicationEvent event : events) {
        store.store(event);
    }
    // Items are stored in reverse order
    List<ClientApplicationEvent> reversed = new ArrayList<>(events);
    Collections.reverse(reversed);
    assertThat(store.findAll(), is((Collection<ClientApplicationEvent>) reversed));
}
Also used : ClientApplicationDeregisteredEvent(de.codecentric.boot.admin.event.ClientApplicationDeregisteredEvent) ArrayList(java.util.ArrayList) Collection(java.util.Collection) ClientApplicationRegisteredEvent(de.codecentric.boot.admin.event.ClientApplicationRegisteredEvent) Application(de.codecentric.boot.admin.model.Application) ClientApplicationEvent(de.codecentric.boot.admin.event.ClientApplicationEvent) Test(org.junit.Test)

Example 27 with Collection

use of java.util.Collection in project spring-boot-admin by codecentric.

the class SimpleJournaledEventStoreTest method test_store.

@Test
public void test_store() {
    SimpleJournaledEventStore store = new SimpleJournaledEventStore();
    Application application = Application.create("foo").withId("bar").withHealthUrl("http://health").build();
    List<ClientApplicationEvent> events = Arrays.asList(new ClientApplicationRegisteredEvent(application), new ClientApplicationDeregisteredEvent(application));
    for (ClientApplicationEvent event : events) {
        store.store(event);
    }
    assertThat(store.findAll(), is((Collection<ClientApplicationEvent>) Arrays.asList(events.get(1), events.get(0))));
}
Also used : ClientApplicationDeregisteredEvent(de.codecentric.boot.admin.event.ClientApplicationDeregisteredEvent) Collection(java.util.Collection) ClientApplicationRegisteredEvent(de.codecentric.boot.admin.event.ClientApplicationRegisteredEvent) Application(de.codecentric.boot.admin.model.Application) ClientApplicationEvent(de.codecentric.boot.admin.event.ClientApplicationEvent) Test(org.junit.Test)

Example 28 with Collection

use of java.util.Collection in project spring-boot-admin by codecentric.

the class SimpleJournaledEventStoreTest method test_store_capacity.

@Test
public void test_store_capacity() {
    SimpleJournaledEventStore store = new SimpleJournaledEventStore();
    store.setCapacity(2);
    Application application = Application.create("foo").withId("bar").withHealthUrl("http://health").build();
    List<ClientApplicationEvent> events = Arrays.asList(new ClientApplicationRegisteredEvent(application), new ClientApplicationDeregisteredEvent(application), new ClientApplicationDeregisteredEvent(application));
    for (ClientApplicationEvent event : events) {
        store.store(event);
    }
    assertThat(store.findAll(), is((Collection<ClientApplicationEvent>) Arrays.asList(events.get(2), events.get(1))));
}
Also used : ClientApplicationDeregisteredEvent(de.codecentric.boot.admin.event.ClientApplicationDeregisteredEvent) Collection(java.util.Collection) ClientApplicationRegisteredEvent(de.codecentric.boot.admin.event.ClientApplicationRegisteredEvent) Application(de.codecentric.boot.admin.model.Application) ClientApplicationEvent(de.codecentric.boot.admin.event.ClientApplicationEvent) Test(org.junit.Test)

Example 29 with Collection

use of java.util.Collection in project crate by crate.

the class ArrayType method value.

@Override
public Object[] value(Object value) {
    if (value == null) {
        return null;
    }
    Object[] result;
    if (value instanceof Collection) {
        Collection values = (Collection) value;
        result = new Object[values.size()];
        int idx = 0;
        for (Object o : values) {
            result[idx] = innerType.value(o);
            idx++;
        }
    } else {
        Object[] inputArray = (Object[]) value;
        result = new Object[inputArray.length];
        for (int i = 0; i < inputArray.length; i++) {
            result[i] = innerType.value(inputArray[i]);
        }
    }
    return result;
}
Also used : Collection(java.util.Collection)

Example 30 with Collection

use of java.util.Collection in project cas by apereo.

the class LogoutManagerImpl method performLogoutForTicket.

private void performLogoutForTicket(final TicketGrantingTicket ticket, final List<LogoutRequest> logoutRequests) {
    ticket.getServices().entrySet().stream().filter(entry -> entry.getValue() instanceof WebApplicationService).forEach(entry -> {
        final Service service = entry.getValue();
        LOGGER.debug("Handling single logout callback for [{}]", service);
        final LogoutRequest logoutRequest = this.singleLogoutServiceMessageHandler.handle((WebApplicationService) service, entry.getKey());
        if (logoutRequest != null) {
            LOGGER.debug("Captured logout request [{}]", logoutRequest);
            logoutRequests.add(logoutRequest);
        }
    });
    final Collection<ProxyGrantingTicket> proxyGrantingTickets = ticket.getProxyGrantingTickets();
    if (proxyGrantingTickets.isEmpty()) {
        LOGGER.debug("There are no proxy-granting tickets associated with [{}] to process for single logout", ticket.getId());
    } else {
        proxyGrantingTickets.forEach(proxyGrantingTicket -> performLogoutForTicket(proxyGrantingTicket, logoutRequests));
    }
}
Also used : WebApplicationService(org.apereo.cas.authentication.principal.WebApplicationService) List(java.util.List) Logger(org.slf4j.Logger) Service(org.apereo.cas.authentication.principal.Service) Collection(java.util.Collection) LoggerFactory(org.slf4j.LoggerFactory) CompressionUtils(org.apereo.cas.util.CompressionUtils) ProxyGrantingTicket(org.apereo.cas.ticket.proxy.ProxyGrantingTicket) TicketGrantingTicket(org.apereo.cas.ticket.TicketGrantingTicket) Collections(java.util.Collections) ArrayList(java.util.ArrayList) WebApplicationService(org.apereo.cas.authentication.principal.WebApplicationService) WebApplicationService(org.apereo.cas.authentication.principal.WebApplicationService) Service(org.apereo.cas.authentication.principal.Service) ProxyGrantingTicket(org.apereo.cas.ticket.proxy.ProxyGrantingTicket)

Aggregations

Collection (java.util.Collection)8532 ArrayList (java.util.ArrayList)2646 Map (java.util.Map)2119 List (java.util.List)1956 HashMap (java.util.HashMap)1657 Test (org.junit.Test)1476 Set (java.util.Set)1137 Iterator (java.util.Iterator)1090 HashSet (java.util.HashSet)1085 Collectors (java.util.stream.Collectors)951 IOException (java.io.IOException)823 Collections (java.util.Collections)660 Arrays (java.util.Arrays)446 Optional (java.util.Optional)423 File (java.io.File)386 Logger (org.slf4j.Logger)344 LoggerFactory (org.slf4j.LoggerFactory)330 PersistenceManager (javax.jdo.PersistenceManager)309 LinkedHashMap (java.util.LinkedHashMap)299 Query (javax.jdo.Query)294