Search in sources :

Example 1 with Expander

use of com.evolveum.midpoint.studio.impl.Expander in project midpoint-studio by Evolveum.

the class ExpanderTest method testMid7781Variants.

private void testMid7781Variants(String keyToExpand) throws IOException {
    Project project = getProject();
    EnvironmentService es = EnvironmentService.getInstance(project);
    Expander expander = new Expander(es.getSelected(), null, project);
    PsiFile psiFile = myFixture.configureByFile("mid-7781/functionalLibraries/lib.xml");
    VirtualFile file = psiFile.getVirtualFile();
    myFixture.configureByFile("mid-7781/include/email/sample.html");
    String expected = FileUtils.readFileToString(new File("./src/test/testData/expander/mid-7781/include/email/sample.html"), StandardCharsets.UTF_8);
    String value = expander.expand(keyToExpand, file);
    assertEquals(expected, value);
}
Also used : VirtualFile(com.intellij.openapi.vfs.VirtualFile) Project(com.intellij.openapi.project.Project) Expander(com.evolveum.midpoint.studio.impl.Expander) EnvironmentService(com.evolveum.midpoint.studio.impl.EnvironmentService) PsiFile(com.intellij.psi.PsiFile) VirtualFile(com.intellij.openapi.vfs.VirtualFile) File(java.io.File) PsiFile(com.intellij.psi.PsiFile)

Example 2 with Expander

use of com.evolveum.midpoint.studio.impl.Expander in project midpoint-studio by Evolveum.

the class ExpanderTest method testExpandFile.

private void testExpandFile(String fileExpected, String fileToExpand, String... expandChunkFiles) {
    for (String s : expandChunkFiles) {
        myFixture.configureByFile(s);
    }
    PsiFile file = myFixture.configureByFile(fileToExpand);
    Editor editor = myFixture.getEditor();
    String text = editor.getDocument().getText();
    Project project = getProject();
    Environment environment = new Environment();
    EnvironmentService es = EnvironmentService.getInstance(project);
    es.add(environment);
    EncryptionService cm = project != null ? EncryptionService.getInstance(project) : null;
    Expander expander = new Expander(environment, cm, project);
    String result = expander.expand(text, file.getVirtualFile());
    LOG.info("Expanded result:\n" + result);
    Diff d = DiffBuilder.compare(Input.fromFile(new File(getTestDataPath(), fileExpected))).withTest(Input.fromString(result)).build();
    if (d.hasDifferences()) {
        LOG.error(d.fullDescription());
        fail();
    }
}
Also used : Project(com.intellij.openapi.project.Project) Expander(com.evolveum.midpoint.studio.impl.Expander) Diff(org.xmlunit.diff.Diff) EncryptionService(com.evolveum.midpoint.studio.impl.EncryptionService) Environment(com.evolveum.midpoint.studio.impl.Environment) PsiFile(com.intellij.psi.PsiFile) EnvironmentService(com.evolveum.midpoint.studio.impl.EnvironmentService) Editor(com.intellij.openapi.editor.Editor) VirtualFile(com.intellij.openapi.vfs.VirtualFile) File(java.io.File) PsiFile(com.intellij.psi.PsiFile)

Aggregations

EnvironmentService (com.evolveum.midpoint.studio.impl.EnvironmentService)2 Expander (com.evolveum.midpoint.studio.impl.Expander)2 Project (com.intellij.openapi.project.Project)2 VirtualFile (com.intellij.openapi.vfs.VirtualFile)2 PsiFile (com.intellij.psi.PsiFile)2 File (java.io.File)2 EncryptionService (com.evolveum.midpoint.studio.impl.EncryptionService)1 Environment (com.evolveum.midpoint.studio.impl.Environment)1 Editor (com.intellij.openapi.editor.Editor)1 Diff (org.xmlunit.diff.Diff)1