Search in sources :

Example 1 with Applications

use of com.enonic.xp.app.Applications in project xp by enonic.

the class ApplicationServiceImplTest method get_all_applications.

@Test
public void get_all_applications() throws Exception {
    final Bundle bundle1 = deployAppBundle("app1");
    final Bundle bundle2 = deployAppBundle("app2");
    deployBundle("noapp");
    applicationRegistry.installApplication(bundle1);
    applicationRegistry.installApplication(bundle2);
    final Applications result = this.service.getInstalledApplications();
    assertNotNull(result);
    assertEquals(2, result.getSize());
}
Also used : Applications(com.enonic.xp.app.Applications) Bundle(org.osgi.framework.Bundle) Test(org.junit.jupiter.api.Test)

Example 2 with Applications

use of com.enonic.xp.app.Applications in project xp by enonic.

the class SseEntryPointTest method testSubscribe.

@Test
public void testSubscribe() {
    listener.setSse(sse);
    final SseEventSink eventSink = mock(SseEventSink.class);
    doNothing().when(broadcaster).register(eventSink);
    final Application application = mock(Application.class);
    when(application.getKey()).thenReturn(ApplicationKey.from("appKey"));
    when(application.getVersion()).thenReturn(Version.emptyVersion);
    final Applications applications = Applications.from(application);
    when(applicationService.getInstalledApplications()).thenReturn(applications);
    when(applicationService.isLocalApplication(any(ApplicationKey.class))).thenReturn(false);
    final ArgumentCaptor<ListApplicationJson> listApplicationCaptor = ArgumentCaptor.forClass(ListApplicationJson.class);
    listener.subscribe(eventSink);
    verify(broadcaster, times(1)).register(eventSink);
    verify(sse, times(1)).newEventBuilder();
    verify(eventBuilder).data(eq(ListApplicationJson.class), listApplicationCaptor.capture());
    verify(applicationService, times(1)).getInstalledApplications();
    verify(applicationService, times(1)).isLocalApplication(any(ApplicationKey.class));
    final List<ApplicationInfoJson> actualApplications = listApplicationCaptor.getValue().getApplications();
    assertNotNull(actualApplications);
    assertFalse(actualApplications.isEmpty());
    assertEquals("appKey", actualApplications.get(0).getKey());
    assertFalse(actualApplications.get(0).getLocal());
}
Also used : ApplicationInfoJson(com.enonic.xp.impl.server.rest.model.ApplicationInfoJson) ApplicationKey(com.enonic.xp.app.ApplicationKey) ListApplicationJson(com.enonic.xp.impl.server.rest.model.ListApplicationJson) Applications(com.enonic.xp.app.Applications) SseEventSink(javax.ws.rs.sse.SseEventSink) Application(com.enonic.xp.app.Application) Test(org.junit.jupiter.api.Test)

Aggregations

Applications (com.enonic.xp.app.Applications)2 Test (org.junit.jupiter.api.Test)2 Application (com.enonic.xp.app.Application)1 ApplicationKey (com.enonic.xp.app.ApplicationKey)1 ApplicationInfoJson (com.enonic.xp.impl.server.rest.model.ApplicationInfoJson)1 ListApplicationJson (com.enonic.xp.impl.server.rest.model.ListApplicationJson)1 SseEventSink (javax.ws.rs.sse.SseEventSink)1 Bundle (org.osgi.framework.Bundle)1