Search in sources :

Example 1 with ContentTypeFilter

use of com.enonic.xp.schema.content.ContentTypeFilter in project xp by enonic.

the class ContentTypeFilterTypeTest method testContentFilterAllow.

@Test
public void testContentFilterAllow() throws Exception {
    final ContentTypeFilter filter = ContentTypeFilter.create().defaultAllow().denyContentType(ContentTypeName.from("myapplication:com.enonic.tweet")).denyContentType("myapplication:system.folder").denyContentTypes(ContentTypeNames.from("myapplication:com.enonic.article", "myapplication:com.enonic.employee")).build();
    assertEquals(ContentTypeFilter.AccessType.ALLOW, filter.getDefaultAccess());
    assertFalse(filter.isContentTypeAllowed(ContentTypeName.from("myapplication:com.enonic.tweet")));
    assertFalse(filter.isContentTypeAllowed(ContentTypeName.from("myapplication:system.folder")));
    assertFalse(filter.isContentTypeAllowed(ContentTypeName.from("myapplication:com.enonic.article")));
    assertFalse(filter.isContentTypeAllowed(ContentTypeName.from("myapplication:com.enonic.employee")));
    assertTrue(filter.isContentTypeAllowed(ContentTypeName.from("myapplication:other")));
}
Also used : ContentTypeFilter(com.enonic.xp.schema.content.ContentTypeFilter) Test(org.junit.jupiter.api.Test)

Example 2 with ContentTypeFilter

use of com.enonic.xp.schema.content.ContentTypeFilter in project xp by enonic.

the class ContentTypeFilterTypeTest method testContentFilterDeny.

@Test
public void testContentFilterDeny() throws Exception {
    final ContentTypeFilter filter = ContentTypeFilter.create().defaultDeny().allowContentType(ContentTypeName.from("myapplication:com.enonic.tweet")).allowContentType("myapplication:system.folder").allowContentTypes(ContentTypeNames.from("myapplication:com.enonic.article", "myapplication:com.enonic.employee")).build();
    assertEquals(ContentTypeFilter.AccessType.DENY, filter.getDefaultAccess());
    assertTrue(filter.isContentTypeAllowed(ContentTypeName.from("myapplication:com.enonic.tweet")));
    assertTrue(filter.isContentTypeAllowed(ContentTypeName.from("myapplication:system.folder")));
    assertTrue(filter.isContentTypeAllowed(ContentTypeName.from("myapplication:com.enonic.article")));
    assertTrue(filter.isContentTypeAllowed(ContentTypeName.from("myapplication:com.enonic.employee")));
    assertFalse(filter.isContentTypeAllowed(ContentTypeName.from("myapplication:other")));
}
Also used : ContentTypeFilter(com.enonic.xp.schema.content.ContentTypeFilter) Test(org.junit.jupiter.api.Test)

Example 3 with ContentTypeFilter

use of com.enonic.xp.schema.content.ContentTypeFilter in project xp by enonic.

the class ContentTypeFilterTypeTest method testContentFilterIteration.

@Test
public void testContentFilterIteration() throws Exception {
    final ContentTypeFilter filter = ContentTypeFilter.create().defaultAllow().denyContentType(ContentTypeName.from("myapplication:com.enonic.tweet")).denyContentType("myapplication:system.folder").denyContentTypes(ContentTypeNames.from("myapplication:com.enonic.article", "myapplication:com.enonic.employee")).build();
    final Iterator<ContentTypeName> iterator = filter.iterator();
    assertEquals(ContentTypeName.from("myapplication:com.enonic.tweet"), iterator.next());
    assertEquals(ContentTypeName.from("myapplication:system.folder"), iterator.next());
    assertEquals(ContentTypeName.from("myapplication:com.enonic.article"), iterator.next());
    assertEquals(ContentTypeName.from("myapplication:com.enonic.employee"), iterator.next());
    assertFalse(iterator.hasNext());
}
Also used : ContentTypeFilter(com.enonic.xp.schema.content.ContentTypeFilter) ContentTypeName(com.enonic.xp.schema.content.ContentTypeName) Test(org.junit.jupiter.api.Test)

Aggregations

ContentTypeFilter (com.enonic.xp.schema.content.ContentTypeFilter)3 Test (org.junit.jupiter.api.Test)3 ContentTypeName (com.enonic.xp.schema.content.ContentTypeName)1