コード例 #1
0
  @Test
  public void deleteMacro() throws IOException {
    scanner.deleteMacro(MACRO_NAME);

    File file = new File(macrosDir, MACRO_NAME + ".groovy"); // $NON-NLS-1$
    assertFalse(file.exists());
  }
コード例 #2
0
  @Test
  public void saveMacro() throws IOException {
    scanner.saveMacro(MACRO_NAME, "code"); // $NON-NLS-1$

    File file = new File(macrosDir, MACRO_NAME + ".groovy"); // $NON-NLS-1$
    assertEquals("code", FileUtils.readFileToString(file, Charsets.UTF_8)); // $NON-NLS-1$
  }
コード例 #3
0
  @Before
  public void setUp() throws IOException {
    File dataDir = tempDir.getRoot();
    when(settings.getDocumentrDataDir()).thenReturn(dataDir);

    macrosDir = new File(dataDir, GroovyMacroScanner.MACROS_DIR_NAME);
    File macroFile = new File(macrosDir, MACRO_NAME + ".groovy"); // $NON-NLS-1$
    FileUtils.writeStringToFile(macroFile, MACRO, Charsets.UTF_8);

    scanner.init();
  }
コード例 #4
0
 @Test
 public void verifyMacroGood() {
   assertTrue(scanner.verifyMacro(MACRO).isEmpty());
 }
コード例 #5
0
 @Test
 public void getMacroCode() throws IOException {
   String result = scanner.getMacroCode(MACRO_NAME);
   assertEquals(MACRO, result);
 }
コード例 #6
0
 @Test
 public void listMacros() {
   List<String> result = scanner.listMacros();
   assertEquals(Lists.newArrayList(MACRO_NAME), result);
 }
コード例 #7
0
 @Test
 public void findGroovyMacros() {
   Set<IMacro> macros = scanner.findGroovyMacros();
   IMacro macro = macros.iterator().next();
   assertEquals(MACRO_CLASS_NAME, macro.getClass().getName());
 }
コード例 #8
0
 @Test
 public void verifyMacroBad() {
   assertFalse(scanner.verifyMacro("xyz").isEmpty()); // $NON-NLS-1$
   assertFalse(scanner.verifyMacro("class Xyz {}").isEmpty()); // $NON-NLS-1$
   assertFalse(scanner.verifyMacro("@Macro\nclass Xyz {}").isEmpty()); // $NON-NLS-1$
 }