Search in sources :

Example 16 with Node

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);
}
Also used : ApplicationKey(com.enonic.xp.app.ApplicationKey) Node(com.enonic.xp.node.Node) Application(com.enonic.xp.app.Application) Test(org.junit.jupiter.api.Test)

Example 17 with Node

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());
}
Also used : ApplicationKey(com.enonic.xp.app.ApplicationKey) Node(com.enonic.xp.node.Node) Test(org.junit.jupiter.api.Test)

Example 18 with Node

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));
}
Also used : Node(com.enonic.xp.node.Node) ByteSource(com.google.common.io.ByteSource) Application(com.enonic.xp.app.Application) Test(org.junit.jupiter.api.Test)

Example 19 with Node

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()));
}
Also used : Node(com.enonic.xp.node.Node) ByteSource(com.google.common.io.ByteSource) Application(com.enonic.xp.app.Application) Test(org.junit.jupiter.api.Test)

Example 20 with Node

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());
}
Also used : Node(com.enonic.xp.node.Node) Application(com.enonic.xp.app.Application) Test(org.junit.jupiter.api.Test)

Aggregations

Node (com.enonic.xp.node.Node)521 Test (org.junit.jupiter.api.Test)371 PropertyTree (com.enonic.xp.data.PropertyTree)114 NodeId (com.enonic.xp.node.NodeId)52 AbstractNodeTest (com.enonic.xp.repo.impl.node.AbstractNodeTest)51 NodePath (com.enonic.xp.node.NodePath)45 CreateNodeParams (com.enonic.xp.node.CreateNodeParams)42 UpdateNodeParams (com.enonic.xp.node.UpdateNodeParams)34 FindNodesByQueryResult (com.enonic.xp.node.FindNodesByQueryResult)32 FindNodesByParentResult (com.enonic.xp.node.FindNodesByParentResult)29 NodeQuery (com.enonic.xp.node.NodeQuery)27 AccessControlList (com.enonic.xp.security.acl.AccessControlList)27 BinaryReference (com.enonic.xp.util.BinaryReference)26 ByteSource (com.google.common.io.ByteSource)24 Content (com.enonic.xp.content.Content)23 PropertySet (com.enonic.xp.data.PropertySet)20 NodeIds (com.enonic.xp.node.NodeIds)18 Context (com.enonic.xp.context.Context)17 InternalContext (com.enonic.xp.repo.impl.InternalContext)17 Application (com.enonic.xp.app.Application)16