use of com.enonic.xp.app.ApplicationKey in project xp by enonic.
the class DeployDirectoryWatcher method installApplication.
private void installApplication(final File file) {
// Installs the application
final ByteSource byteSource = Files.asByteSource(file);
final Application application = DeployHelper.runAsAdmin(() -> applicationService.installLocalApplication(byteSource, file.getName()));
final ApplicationKey applicationKey = application.getKey();
final String path = file.getPath();
// Stores a mapping fileName -> applicationKey. Needed for uninstallation
this.applicationKeyByPath.put(path, applicationKey);
// Updates the mapping applicationKey -> stack<fileName>. Needed in some particular case for uninstallatioon
this.pathsByApplicationKey.compute(applicationKey, (applicationKeyParam, fileNameStack) -> {
if (fileNameStack == null) {
fileNameStack = new Stack<>();
}
fileNameStack.remove(path);
fileNameStack.push(path);
return fileNameStack;
});
}
use of com.enonic.xp.app.ApplicationKey in project xp by enonic.
the class ValidationErrorCodeTest method from.
@Test
void from() {
final ApplicationKey applicationKey = ApplicationKey.from("someApp");
final ValidationErrorCode validationErrorCode = ValidationErrorCode.from(applicationKey, "someCode");
assertEquals(applicationKey, validationErrorCode.getApplicationKey());
assertEquals("someCode", validationErrorCode.getCode());
}
use of com.enonic.xp.app.ApplicationKey in project xp by enonic.
the class ApplicationServiceImplTest method configuration_comes_twice_invalidators_called.
@Test
public void configuration_comes_twice_invalidators_called() throws Exception {
final ApplicationKey key = ApplicationKey.from("myapp");
final Bundle bundle = deployAppBundle("myapp");
applicationRegistry.installApplication(bundle);
service.getInstalledApplication(key);
final ApplicationInvalidator mock = mock(ApplicationInvalidator.class);
applicationRegistry.addInvalidator(mock);
applicationRegistry.configureApplication(bundle, ConfigBuilder.create().add("a", "b").build());
applicationRegistry.configureApplication(bundle, ConfigBuilder.create().add("c", "d").build());
verify(mock, times(1)).invalidate(eq(key), eq(ApplicationInvalidationLevel.FULL));
}
use of com.enonic.xp.app.ApplicationKey in project xp by enonic.
the class ApplicationServiceImplTest method start_application_no_triggerEvent.
@Test
public void start_application_no_triggerEvent() throws Exception {
final Bundle bundle = deployAppBundle("app1");
applicationRegistry.installApplication(bundle);
final ApplicationKey applicationKey = ApplicationKey.from("app1");
assertEquals(Bundle.INSTALLED, bundle.getState());
this.service.startApplication(applicationKey, false);
assertEquals(Bundle.ACTIVE, bundle.getState());
verify(this.eventPublisher, never()).publish(Mockito.argThat(new ApplicationEventMatcher(ApplicationClusterEvents.start(applicationKey))));
verify(this.eventPublisher, never()).publish(Mockito.argThat(new ApplicationEventMatcher(ApplicationClusterEvents.started(applicationKey))));
}
use of com.enonic.xp.app.ApplicationKey in project xp by enonic.
the class ApplicationServiceImplTest method stop_system_application_ignored.
@Test
public void stop_system_application_ignored() throws Exception {
final Bundle bundle = deploySystemAppBundle("systemApp");
applicationRegistry.installApplication(bundle);
bundle.start();
assertEquals(Bundle.ACTIVE, bundle.getState());
final ApplicationKey applicationKey = ApplicationKey.from("systemApp");
this.service.stopApplication(applicationKey, true);
assertEquals(Bundle.ACTIVE, bundle.getState());
}
Aggregations