OcelotProcessor extends AbstractProcessor { String getPackagePath(TypeElement te) { return te.getQualifiedName().toString().replaceAll("." + te.getSimpleName(), ""); }  @Override void init(ProcessingEnvironment processingEnv); @Override boolean process(Set<? extends TypeElement> annotations, RoundEnvironment roundEnv); void processElement(Element element);  }
@Test public void test_getPackagePath() { System.out.println("getPackagePath"); TypeElement element = mock(TypeElement.class); Name qname = mock(Name.class); when(qname.toString()).thenReturn("a.b.c.d.Test"); Name name = mock(Name.class); when(name.toString()).thenReturn("Test"); when(element.getQualifiedName()).thenReturn(qname); when(element.getSimpleName()).thenReturn(name); String result = instance.getPackagePath(element); assertThat(result).isNotNull(); assertThat(result).isEqualTo("a.b.c.d"); }