use of com.enonic.xp.page.DescriptorKey in project xp by enonic.
the class DescriptorKeysTest method testFrom_array.
@Test
public void testFrom_array() {
final DescriptorKey key1 = DescriptorKey.from("app1:abc");
final DescriptorKey key2 = DescriptorKey.from("app2:abc");
final DescriptorKeys keys = DescriptorKeys.from(key1, key2);
assertEquals("[app1:abc, app2:abc]", keys.toString());
}
use of com.enonic.xp.page.DescriptorKey in project xp by enonic.
the class PageDescriptorServiceImpl method getByKey.
@Override
public PageDescriptor getByKey(final DescriptorKey key) {
final ResourceProcessor<DescriptorKey, PageDescriptor> processor = newProcessor(key);
final PageDescriptor descriptor = this.resourceService.processResource(processor);
if (descriptor == null) {
return createDefaultDescriptor(key);
}
return PageDescriptor.copyOf(descriptor).config(this.mixinService.inlineFormItems(descriptor.getConfig())).build();
}
use of com.enonic.xp.page.DescriptorKey in project xp by enonic.
the class FlattenedPageIndexUpgraderTest method test.
private void test(final String dataFile, final String oldIndexDocumentFile, final String newIndexDocumentFile) throws Exception {
final JsonNode pageComponents = loadJson(dataFile);
final PropertyTree data = new JsonToPropertyTreeTranslator().translate(pageComponents);
final List<PropertySet> components = Lists.newArrayList(data.getSets("components"));
if (components.size() == 0) {
throw new RuntimeException("page components is empty");
}
final String descriptorKeyStr = data.getString(PropertyPath.from("components.page.descriptor"));
if (descriptorKeyStr == null) {
throw new RuntimeException("page descriptorKey is null");
}
final DescriptorKey descriptorKey = DescriptorKey.from(descriptorKeyStr);
final PatternIndexConfigDocument oldDocument = getIndexConfigDocument(oldIndexDocumentFile);
final PatternIndexConfigDocument newDocument = new FlattenedPageIndexUpgrader(descriptorKey, components).upgrade(oldDocument);
assertEquals(getIndexConfigDocument(newIndexDocumentFile), newDocument);
}
use of com.enonic.xp.page.DescriptorKey in project xp by enonic.
the class AdminToolHandlerTest method setup.
@BeforeEach
public final void setup() throws Exception {
this.adminToolDescriptorService = Mockito.mock(AdminToolDescriptorService.class);
ControllerScript controllerScript = Mockito.mock(ControllerScript.class);
this.portalResponse = PortalResponse.create().build();
Mockito.when(controllerScript.execute(Mockito.any(PortalRequest.class))).thenReturn(this.portalResponse);
final ControllerScriptFactory controllerScriptFactory = Mockito.mock(ControllerScriptFactory.class);
Mockito.when(controllerScriptFactory.fromDir(Mockito.any(ResourceKey.class))).thenReturn(controllerScript);
this.handler = new AdminToolHandler();
this.handler.setAdminToolDescriptorService(this.adminToolDescriptorService);
this.handler.setControllerScriptFactory(controllerScriptFactory);
this.rawRequest = Mockito.mock(HttpServletRequest.class);
Mockito.when(this.rawRequest.isUserInRole(Mockito.anyString())).thenReturn(true);
this.portalRequest = new PortalRequest();
this.portalRequest.setRawRequest(this.rawRequest);
this.portalRequest.setMode(RenderMode.ADMIN);
final DescriptorKey defaultDescriptorKey = AdminToolPortalHandler.DEFAULT_DESCRIPTOR_KEY;
this.portalRequest.setBaseUri(AdminToolPortalHandler.ADMIN_TOOL_PREFIX + defaultDescriptorKey.getApplicationKey() + "/" + defaultDescriptorKey.getName());
this.portalRequest.setApplicationKey(defaultDescriptorKey.getApplicationKey());
this.webResponse = WebResponse.create().build();
this.chain = Mockito.mock(WebHandlerChain.class);
}
use of com.enonic.xp.page.DescriptorKey in project xp by enonic.
the class AdminToolHandlerTest method mockDescriptor.
private void mockDescriptor(DescriptorKey descriptorKey, boolean hasAccess) {
AdminToolDescriptor descriptor = Mockito.mock(AdminToolDescriptor.class);
Mockito.when(descriptor.getKey()).thenReturn(descriptorKey);
Mockito.when(descriptor.isAccessAllowed(Mockito.any(PrincipalKeys.class))).thenReturn(hasAccess);
Mockito.when(this.adminToolDescriptorService.getByKey(Mockito.any(DescriptorKey.class))).thenReturn(descriptor);
}
Aggregations