use of com.enonic.xp.app.Application in project xp by enonic.
the class ApplicationServiceImplTest method install_local.
@Test
public void install_local() throws Exception {
final Node applicationNode = Node.create().id(NodeId.from("myNode")).parentPath(NodePath.ROOT).name("myNode").build();
final String bundleName = "my-bundle";
mockRepoCreateNode(applicationNode);
mockRepoGetNode(applicationNode, bundleName);
final ByteSource byteSource = createBundleSource(bundleName);
final Application application = this.service.installLocalApplication(byteSource, bundleName);
assertNotNull(application);
assertEquals(bundleName, application.getKey().getName());
assertTrue(this.service.isLocalApplication(application.getKey()));
assertEquals(application, this.service.getInstalledApplication(application.getKey()));
verifyInstalledEvents(applicationNode, never());
verifyStartedEvent(application.getKey(), never());
}
use of com.enonic.xp.app.Application in project xp by enonic.
the class ApplicationServiceImplTest method install_local_overriding_global.
@Test
public void install_local_overriding_global() throws Exception {
final Node node = Node.create().id(NodeId.from("myNode")).parentPath(NodePath.ROOT).name("myNode").build();
final String bundleName = "my-bundle";
mockRepoCreateNode(node);
when(this.repoService.updateApplicationNode(Mockito.isA(Application.class), Mockito.isA(ByteSource.class))).thenReturn(node);
mockRepoGetNode(node, bundleName);
final Application originalApplication = this.service.installGlobalApplication(ByteSource.wrap(ByteStreams.toByteArray(newBundle(bundleName, true, "1.0.0").build())), bundleName);
assertFalse(this.service.isLocalApplication(originalApplication.getKey()));
final Application updatedApplication = this.service.installLocalApplication(ByteSource.wrap(ByteStreams.toByteArray(newBundle(bundleName, true, "1.0.1").build())), bundleName);
assertEquals("1.0.0", originalApplication.getVersion().toString());
assertEquals("1.0.1", updatedApplication.getVersion().toString());
assertTrue(this.service.isLocalApplication(updatedApplication.getKey()));
assertEquals(updatedApplication, this.service.getInstalledApplication(updatedApplication.getKey()));
assertTrue(this.service.isLocalApplication(updatedApplication.getKey()));
}
use of com.enonic.xp.app.Application in project xp by enonic.
the class ApplicationNodeTransformerTest method app_binary_updated.
@Test
public void app_binary_updated() throws Exception {
final PropertyTree data = new PropertyTree();
final BinaryReference appReference = BinaryReference.from(ApplicationNodeTransformer.APPLICATION_BINARY_REF);
data.addBinaryReference(ApplicationNodeTransformer.APPLICATION_BINARY_REF, appReference);
final Node existingNode = Node.create().id(NodeId.from("myNode")).parentPath(NodePath.ROOT).name("myNode").data(data).attachedBinaries(AttachedBinaries.create().add(new AttachedBinary(appReference, "abc")).build()).build();
final Application app = Mockito.mock(Application.class);
Mockito.when(app.getKey()).thenReturn(ApplicationKey.from("myApp"));
Mockito.when(app.getVersion()).thenReturn(Version.valueOf("1.0.0"));
Mockito.when(app.getMaxSystemVersion()).thenReturn("1.0.0");
Mockito.when(app.getMinSystemVersion()).thenReturn("1.0.0.");
Mockito.when(app.getDisplayName()).thenReturn("displayName");
final ByteSource updatedSource = ByteSource.wrap(ByteStreams.toByteArray(newBundle("myBundleUpdated", true).build()));
final UpdateNodeParams updateNodeParams = ApplicationNodeTransformer.toUpdateNodeParams(app, updatedSource, existingNode);
final BinaryAttachments binaryAttachments = updateNodeParams.getBinaryAttachments();
assertEquals(updatedSource, binaryAttachments.get(appReference).getByteSource());
}
use of com.enonic.xp.app.Application in project xp by enonic.
the class ApplicationServiceImplTest method uninstall_local_application.
@Test
public void uninstall_local_application() throws Exception {
final Node applicationNode = Node.create().id(NodeId.from("myNode")).parentPath(NodePath.ROOT).name("myNode").build();
final String bundleName = "my-bundle";
mockRepoCreateNode(applicationNode);
final ByteSource byteSource = createBundleSource(bundleName);
final Application application = this.service.installLocalApplication(byteSource, bundleName);
assertNotNull(this.service.getInstalledApplication(application.getKey()));
this.service.uninstallApplication(application.getKey(), false);
assertNull(this.service.getInstalledApplication(application.getKey()));
verify(this.eventPublisher, never()).publish(Mockito.argThat(new ApplicationEventMatcher(ApplicationClusterEvents.uninstall(application.getKey()))));
verify(this.eventPublisher, never()).publish(Mockito.argThat(new ApplicationEventMatcher(ApplicationClusterEvents.uninstalled(application.getKey()))));
}
use of com.enonic.xp.app.Application in project xp by enonic.
the class ApplicationServiceImplTest method install_global_when_local_installed.
@Test
public void install_global_when_local_installed() throws Exception {
final Node applicationNode = Node.create().id(NodeId.from("myNode")).parentPath(NodePath.ROOT).name("myNode").build();
final String bundleName = "my-bundle";
mockRepoCreateNode(applicationNode);
final ByteSource byteSource = createBundleSource(bundleName);
final Application application = this.service.installLocalApplication(byteSource, bundleName);
assertTrue(this.service.isLocalApplication(application.getKey()));
when(this.repoService.getApplicationNode(application.getKey())).thenReturn(applicationNode);
this.service.installGlobalApplication(byteSource, bundleName);
assertTrue(this.service.isLocalApplication(application.getKey()));
verifyInstalledEvents(applicationNode, times(1));
}
Aggregations