@Test public void shouldNotFindBuilderForClassWhenClassFounderReturnsNull() { // given given(classFinder.findClass(CLASS_NAME, project)).willReturn(null); // when PsiClass result = builderFinder.findBuilderForClass(psiClass); // then assertThat(result, is(nullValue())); }
@Test public void shouldNotFindBuilderForAnnotationType() { // given given(psiClass.isAnnotationType()).willReturn(true); // when PsiClass result = builderFinder.findBuilderForClass(psiClass); // then assertThat(result, is(nullValue())); }
@Test public void shouldNotFindClassForEnum() { // given given(psiClass.isEnum()).willReturn(true); // when PsiClass result = builderFinder.findClassForBuilder(psiClass); // then assertThat(result, is(nullValue())); }
@Test public void shouldFindClassForBuilderWhenClassWithTheExactBuildersNameIsPresent() { // given given(classFinder.findClass(CLASS_NAME, project)).willReturn(psiClass); // when PsiClass result = builderFinder.findClassForBuilder(psiClass); // then assertThat(result, is(notNullValue())); assertThat(result.getName(), is(CLASS_NAME)); }
@Test public void shouldFindBuilderForClassWhenBuilderWithTheExactClassNameIsPresent() { // given PsiClass builderClass = mock(PsiClass.class); given(builderClass.getName()).willReturn(BUILDER_NAME); given(classFinder.findClass(BUILDER_NAME, project)).willReturn(builderClass); // when PsiClass result = builderFinder.findBuilderForClass(psiClass); // then assertThat(result, is(notNullValue())); assertThat(result.getName(), is(BUILDER_NAME)); }