OcelotProcessor extends AbstractProcessor { void createPropertiesFile(TypeElement te, ElementVisitor visitor) { try (Writer w = fws.getFileObjectWriterInClassOutput(getPackagePath(te), te.getSimpleName().toString()+".properties")) { te.accept(visitor, w); } catch(IOException ioe) { messager.printMessage(Diagnostic.Kind.ERROR, " properties generation class : " + te); } }  @Override void init(ProcessingEnvironment processingEnv); @Override boolean process(Set<? extends TypeElement> annotations, RoundEnvironment roundEnv); void processElement(Element element);  }
@Test public void createPropertiesFileTest() throws IOException { System.out.println("createPropertiesFile"); TypeElement te = mock(TypeElement.class); Name name = mock(Name.class); ElementVisitor visitor = mock(ElementVisitor.class); Writer writer = mock(Writer.class); when(te.getSimpleName()).thenReturn(name); when(name.toString()).thenReturn("ClassName"); when(fws.getFileObjectWriterInClassOutput(eq("package"), eq("ClassName.properties"))).thenReturn(writer).thenThrow(IOException.class); doReturn("package").when(instance).getPackagePath(eq(te)); instance.createPropertiesFile(te, visitor); instance.createPropertiesFile(te, visitor); verify(te).accept(eq(visitor), eq(writer)); }