use of com.enonic.xp.node.Node in project xp by enonic.
the class ApplicationServiceImplTest method install_stored_application_denied.
@Test
public void install_stored_application_denied() throws Exception {
when(appFilterService.accept(any(ApplicationKey.class))).thenReturn(false);
final Node node = Node.create().id(NodeId.from("myNodeId")).name("myBundle").parentPath(ApplicationRepoServiceImpl.APPLICATION_PATH).build();
final String bundleName = "my-bundle";
when(this.repoService.getApplicationSource(node.id())).thenReturn(createBundleSource(bundleName));
final Application application = this.service.installStoredApplication(node.id());
assertNull(application);
}
use of com.enonic.xp.node.Node in project xp by enonic.
the class ApplicationServiceImplTest method install_stored_applications.
@Test
public void install_stored_applications() throws Exception {
final String bundleName1 = "my-bundle1";
final String bundleName2 = "my-bundle2";
ApplicationKey applicationKey1 = ApplicationKey.from(bundleName1);
ApplicationKey applicationKey2 = ApplicationKey.from(bundleName2);
when(appFilterService.accept(applicationKey2)).thenReturn(false);
final Node node1 = Node.create().id(NodeId.from("myNodeId1")).name("myBundle1").parentPath(ApplicationRepoServiceImpl.APPLICATION_PATH).build();
final Node node2 = Node.create().id(NodeId.from("myNodeId2")).name("myBundle2").parentPath(ApplicationRepoServiceImpl.APPLICATION_PATH).build();
when(this.repoService.getApplications()).thenReturn(Nodes.from(node1, node2));
when(this.repoService.getApplicationSource(node1.id())).thenReturn(createBundleSource(bundleName1));
when(this.repoService.getApplicationSource(node2.id())).thenReturn(createBundleSource(bundleName2));
this.service.installAllStoredApplications(ApplicationInstallationParams.create().triggerEvent(false).build());
assertFalse(this.service.isLocalApplication(applicationKey1));
assertNotNull(this.service.getInstalledApplication(applicationKey1));
assertNull(this.service.getInstalledApplication(applicationKey2));
verifyInstalledEvents(node1, never());
verifyStartedEvent(applicationKey1, never());
}
use of com.enonic.xp.node.Node in project xp by enonic.
the class ApplicationServiceImplTest method install_global.
@Test
public void install_global() 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.installGlobalApplication(byteSource, bundleName);
assertNotNull(application);
assertEquals(bundleName, application.getKey().getName());
assertFalse(this.service.isLocalApplication(application.getKey()));
assertEquals(application, this.service.getInstalledApplication(application.getKey()));
verifyInstalledEvents(applicationNode, times(1));
verifyStartedEvent(application.getKey(), times(1));
}
use of com.enonic.xp.node.Node in project xp by enonic.
the class ApplicationServiceImplTest method update_installed_application.
@Test
public void update_installed_application() 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);
mockRepoGetNode(node, bundleName);
final Application updatedApplication = this.service.installGlobalApplication(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());
assertFalse(this.service.isLocalApplication(updatedApplication.getKey()));
}
use of com.enonic.xp.node.Node in project xp by enonic.
the class ApplicationServiceImplTest method install_stored_application.
@Test
public void install_stored_application() throws Exception {
final Node node = Node.create().id(NodeId.from("myNodeId")).name("myBundle").parentPath(ApplicationRepoServiceImpl.APPLICATION_PATH).build();
final String bundleName = "my-bundle";
when(this.repoService.getApplicationSource(node.id())).thenReturn(createBundleSource(bundleName));
final Application application = this.service.installStoredApplication(node.id());
assertNotNull(application);
assertEquals(bundleName, application.getKey().getName());
assertFalse(this.service.isLocalApplication(application.getKey()));
assertEquals(application, this.service.getInstalledApplication(application.getKey()));
verifyInstalledEvents(node, never());
verifyStartedEvent(application.getKey(), never());
}
Aggregations