use of com.enonic.xp.app.Application in project xp by enonic.
the class ApplicationImplTest method testApplication.
@Test
public void testApplication() throws Exception {
final Bundle bundle = deployBundle();
final ApplicationUrlResolver urlResolver = Mockito.mock(ApplicationUrlResolver.class);
final Application application = new ApplicationBuilder().bundle(bundle).urlResolver(urlResolver).build();
assertEquals("myapplication", application.getKey().toString());
assertEquals("1.0.0", application.getVersion().toString());
assertEquals("myapplication", application.getDisplayName());
assertEquals("http://enonic.com/path/to/application", application.getUrl());
assertEquals("Enonic AS", application.getVendorName());
assertEquals("http://enonic.com", application.getVendorUrl());
assertEquals(bundle, application.getBundle());
assertTrue(application.getModifiedTime().getEpochSecond() > 0);
assertFalse(application.isStarted());
assertTrue(ApplicationBundleUtils.isApplication(bundle));
assertNotNull(application.getClassLoader());
assertEquals("[1.2.0,2.0.0)", application.getSystemVersion());
assertEquals("2.0.0", application.getMaxSystemVersion());
assertEquals("1.2.0", application.getMinSystemVersion());
application.getFiles();
Mockito.verify(urlResolver, Mockito.times(1)).findFiles();
application.resolveFile("a/b.txt");
Mockito.verify(urlResolver, Mockito.times(1)).findUrl("a/b.txt");
bundle.start();
assertTrue(application.isStarted());
}
use of com.enonic.xp.app.Application in project xp by enonic.
the class XDataServiceImpl method getAll.
@Override
public XDatas getAll() {
final Set<XData> list = new LinkedHashSet<>(this.builtInTypes.getAll().getList());
for (final Application application : this.applicationService.getInstalledApplications()) {
final XDatas types = getByApplication(application.getKey());
list.addAll(types.getList());
}
return XDatas.from(list);
}
use of com.enonic.xp.app.Application in project xp by enonic.
the class MainExecutorTest method mainJsError.
@Test
public void mainJsError() {
final ResourceKey key = ResourceKey.from("foo.bar:/main.js");
when(this.scriptService.hasScript(key)).thenReturn(true);
when(this.scriptService.executeAsync(key)).thenReturn(CompletableFuture.failedFuture(new RuntimeException()));
final Application app = mock(Application.class);
when(app.getKey()).thenReturn(ApplicationKey.from("foo.bar"));
this.executor.activated(app);
}
use of com.enonic.xp.app.Application in project xp by enonic.
the class MainExecutorTest method mainJsMissing.
@Test
public void mainJsMissing() {
final Application app = mock(Application.class);
when(app.getKey()).thenReturn(ApplicationKey.from("foo.bar"));
this.executor.activated(app);
verify(this.scriptService, times(1)).hasScript(any());
verify(this.scriptService, times(0)).execute(any());
}
use of com.enonic.xp.app.Application 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());
}
Aggregations