Search in sources :

Example 41 with Branch

use of com.enonic.xp.branch.Branch in project xp by enonic.

the class AbstractContentServiceTest method createString.

private String createString(final Content content, final int indent) {
    final Branch currentBranch = ContextAccessor.current().getBranch();
    /*  final CompareContentResult compareStatus = this.contentService.compare(
            new CompareContentParams( content.getId(), currentBranch.equals( WS_DEFAULT ) ? WS_OTHER : WS_DEFAULT ) );
*/
    StringBuilder builder = new StringBuilder();
    builder.append(new String(new char[indent]).replace('\0', ' '));
    builder.append("'");
    builder.append("--");
    builder.append(content.getName());
    return builder.toString();
}
Also used : Branch(com.enonic.xp.branch.Branch)

Example 42 with Branch

use of com.enonic.xp.branch.Branch in project xp by enonic.

the class GetActiveContentVersionsResultTest method test_ordering.

@Test
public void test_ordering() throws Exception {
    final Instant oldest = Instant.parse("2014-09-25T10:00:00.00Z");
    final Instant middle = Instant.parse("2014-09-25T11:00:00.00Z");
    final Instant newest = Instant.parse("2014-09-25T12:00:00.00Z");
    final Branch archive = Branch.from("archive");
    final Branch draft = Branch.from("draft");
    final Branch master = Branch.from("master");
    final ContentVersion oldVersion = ContentVersion.create().id(ContentVersionId.from("b")).modified(middle).timestamp(middle).build();
    final ContentVersion oldestVersion = ContentVersion.create().id(ContentVersionId.from("a")).modified(oldest).timestamp(oldest).build();
    final ContentVersion newVersion = ContentVersion.create().id(ContentVersionId.from("c")).modified(newest).timestamp(newest).build();
    final GetActiveContentVersionsResult result = GetActiveContentVersionsResult.create().add(ActiveContentVersionEntry.from(master, oldVersion)).add(ActiveContentVersionEntry.from(draft, newVersion)).add(ActiveContentVersionEntry.from(archive, oldestVersion)).build();
    final UnmodifiableIterator<ActiveContentVersionEntry> iterator = result.getActiveContentVersions().iterator();
    assertEquals(draft, iterator.next().getBranch());
    assertEquals(master, iterator.next().getBranch());
    assertEquals(archive, iterator.next().getBranch());
}
Also used : Branch(com.enonic.xp.branch.Branch) Instant(java.time.Instant) Test(org.junit.jupiter.api.Test)

Example 43 with Branch

use of com.enonic.xp.branch.Branch in project xp by enonic.

the class GetActiveContentVersionsResultTest method skip_null.

@Test
public void skip_null() throws Exception {
    final Instant now = Instant.now();
    final ContentVersion version = ContentVersion.create().id(ContentVersionId.from("a")).modified(now).build();
    final Branch draft = Branch.from("draft");
    final Branch master = Branch.from("master");
    final GetActiveContentVersionsResult result = GetActiveContentVersionsResult.create().add(ActiveContentVersionEntry.from(draft, version)).add(ActiveContentVersionEntry.from(master, null)).build();
    assertEquals(1, result.getActiveContentVersions().size());
}
Also used : Branch(com.enonic.xp.branch.Branch) Instant(java.time.Instant) Test(org.junit.jupiter.api.Test)

Example 44 with Branch

use of com.enonic.xp.branch.Branch in project xp by enonic.

the class GetActiveContentVersionsResultTest method same_version.

@Test
public void same_version() throws Exception {
    final Instant now = Instant.now();
    final ContentVersion version = ContentVersion.create().id(ContentVersionId.from("a")).modified(now).timestamp(now).build();
    final Branch draft = Branch.from("draft");
    final Branch master = Branch.from("master");
    final GetActiveContentVersionsResult result = GetActiveContentVersionsResult.create().add(ActiveContentVersionEntry.from(draft, version)).add(ActiveContentVersionEntry.from(master, version)).build();
    assertEquals(2, result.getActiveContentVersions().size());
}
Also used : Branch(com.enonic.xp.branch.Branch) Instant(java.time.Instant) Test(org.junit.jupiter.api.Test)

Example 45 with Branch

use of com.enonic.xp.branch.Branch in project xp by enonic.

the class ContextImplTest method testBranch.

@Test
public void testBranch() {
    final ContextImpl context = createContext();
    assertNull(context.getBranch());
    final Branch value = Branch.from("branch");
    context.getLocalScope().setAttribute(value);
    assertSame(value, context.getBranch());
}
Also used : Branch(com.enonic.xp.branch.Branch) Test(org.junit.jupiter.api.Test)

Aggregations

Branch (com.enonic.xp.branch.Branch)52 Test (org.junit.jupiter.api.Test)19 Node (com.enonic.xp.node.Node)13 RepositoryId (com.enonic.xp.repository.RepositoryId)12 Context (com.enonic.xp.context.Context)10 NodeId (com.enonic.xp.node.NodeId)8 AbstractNodeTest (com.enonic.xp.repo.impl.node.AbstractNodeTest)8 Repository (com.enonic.xp.repository.Repository)7 ContextAccessor (com.enonic.xp.context.ContextAccessor)5 ContextBuilder (com.enonic.xp.context.ContextBuilder)5 ContentId (com.enonic.xp.content.ContentId)4 PropertyTree (com.enonic.xp.data.PropertyTree)4 CreateBranchParams (com.enonic.xp.repository.CreateBranchParams)4 ContentConstants (com.enonic.xp.content.ContentConstants)3 CreateNodeParams (com.enonic.xp.node.CreateNodeParams)3 FindNodesByParentResult (com.enonic.xp.node.FindNodesByParentResult)3 GetActiveNodeVersionsResult (com.enonic.xp.node.GetActiveNodeVersionsResult)3 NodeIds (com.enonic.xp.node.NodeIds)3 NodePath (com.enonic.xp.node.NodePath)3 NodeVersionMetadata (com.enonic.xp.node.NodeVersionMetadata)3