use of com.enonic.xp.app.Application in project xp by enonic.
the class MixinServiceImpl method getAll.
@Override
public Mixins getAll() {
final Set<Mixin> list = new LinkedHashSet<>();
for (final Application application : this.applicationService.getInstalledApplications()) {
final Mixins types = getByApplication(application.getKey());
list.addAll(types.getList());
}
return Mixins.from(list);
}
use of com.enonic.xp.app.Application in project xp by enonic.
the class FilterScriptImplTest method setup.
@BeforeEach
public void setup() throws Exception {
this.portalRequest = new PortalRequest();
this.portalResponse = PortalResponse.create().build();
final BundleContext bundleContext = Mockito.mock(BundleContext.class);
final Bundle bundle = Mockito.mock(Bundle.class);
Mockito.when(bundle.getBundleContext()).thenReturn(bundleContext);
final Application application = Mockito.mock(Application.class);
Mockito.when(application.getBundle()).thenReturn(bundle);
Mockito.when(application.getClassLoader()).thenReturn(getClass().getClassLoader());
Mockito.when(application.isStarted()).thenReturn(true);
Mockito.when(application.getConfig()).thenReturn(ConfigBuilder.create().build());
final ApplicationService applicationService = Mockito.mock(ApplicationService.class);
Mockito.when(applicationService.getInstalledApplication(ApplicationKey.from("myapplication"))).thenReturn(application);
this.resourceService = Mockito.mock(ResourceService.class);
Mockito.when(resourceService.getResource(Mockito.any())).thenAnswer(invocation -> {
final ResourceKey resourceKey = (ResourceKey) invocation.getArguments()[0];
final URL resourceUrl = FilterScriptImplTest.class.getResource("/" + resourceKey.getApplicationKey() + resourceKey.getPath());
return new UrlResource(resourceKey, resourceUrl);
});
final ScriptAsyncService scriptAsyncService = Mockito.mock(ScriptAsyncService.class);
final ScriptRuntimeFactoryImpl runtimeFactory = new ScriptRuntimeFactoryImpl(applicationService, this.resourceService, scriptAsyncService);
final PortalScriptServiceImpl scriptService = new PortalScriptServiceImpl(runtimeFactory);
scriptService.initialize();
this.factory = new FilterScriptFactoryImpl();
this.factory.setScriptService(scriptService);
final HttpServletRequest req = Mockito.mock(HttpServletRequest.class);
ServletRequestHolder.setRequest(req);
}
use of com.enonic.xp.app.Application in project xp by enonic.
the class ApplicationResourceTest method createApplication.
private Application createApplication(final String url) {
final Application application = Mockito.mock(Application.class);
Mockito.when(application.getKey()).thenReturn(ApplicationKey.from("testapplication"));
Mockito.when(application.getVersion()).thenReturn(new Version(1, 0, 0));
Mockito.when(application.getDisplayName()).thenReturn("application name");
Mockito.when(application.getUrl()).thenReturn(url);
Mockito.when(application.getVendorName()).thenReturn("Enonic");
Mockito.when(application.getVendorUrl()).thenReturn("https://www.enonic.com");
Mockito.when(application.getMinSystemVersion()).thenReturn("5.0");
Mockito.when(application.getMaxSystemVersion()).thenReturn("5.1");
Mockito.when(application.isStarted()).thenReturn(true);
Mockito.when(application.getModifiedTime()).thenReturn(Instant.parse("2012-01-01T00:00:00.00Z"));
return application;
}
use of com.enonic.xp.app.Application in project xp by enonic.
the class ApplicationResourceTest method install_url.
@Test
public void install_url() throws Exception {
Application application = createApplication();
Mockito.when(this.applicationService.installGlobalApplication(eq(new URL(application.getUrl())), any())).thenReturn(application);
String jsonString = request().path("app/installUrl").entity("{\"URL\":\"http://enonic.net\"}", MediaType.APPLICATION_JSON_TYPE).post().getAsString();
assertJson("install_url_result.json", jsonString);
}
use of com.enonic.xp.app.Application in project xp by enonic.
the class ApplicationResourceTest method install.
@Test
public void install() throws Exception {
ApplicationResource resource = getResourceInstance();
ByteSource byteSource = ByteSource.wrap("bytes".getBytes());
Application application = createApplication();
MultipartItem multipartItem = Mockito.mock(MultipartItem.class);
Mockito.when(multipartItem.getBytes()).thenReturn(byteSource);
String fileName = application.getDisplayName();
Mockito.when(multipartItem.getFileName()).thenReturn(fileName);
MultipartForm multipartForm = Mockito.mock(MultipartForm.class);
Mockito.when(this.applicationService.installGlobalApplication(Mockito.isA(ByteSource.class), eq(fileName))).thenReturn(application);
Mockito.when(multipartForm.get("file")).thenReturn(multipartItem);
ApplicationInstallResultJson result = resource.install(multipartForm);
assertEquals(new ApplicationInstalledJson(application, false), result.getApplicationInstalledJson());
}
Aggregations