Skip to content

Commit

Permalink
Fix regex check (#172)
Browse files Browse the repository at this point in the history
  • Loading branch information
boretti committed May 22, 2018
1 parent 3075997 commit 48ce78d
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 2 deletions.
Expand Up @@ -61,8 +61,7 @@ public void addMethod(FactoryAnnotatedElementMirror faem) {
}

public boolean isAccepted(FactoryAnnotatedElementMirror faem) {
return Arrays.stream(acceptingRegex).map(a -> faem.getSurroundingFullyQualifiedName().matches(a)).findAny()
.orElse(false);
return Arrays.stream(acceptingRegex).anyMatch(a -> faem.getSurroundingFullyQualifiedName().matches(a));
}

public void processGenerateOneFactoryInterface() {
Expand Down
Expand Up @@ -81,6 +81,20 @@ public void testConstructorWithOneEntryAndIsAcceptedReturnFalse() {
assertThatFunction(underTest::isAccepted, factoryAnnotatedElementMiror).is(false);
}

@Test(fastFail = false)
public void testIsAccepted() throws IOException {
FactoryGroup underTest = new FactoryGroup(processingEnv, "a.*,b.*:target");

when(factoryAnnotatedElementMiror.getSurroundingFullyQualifiedName()).thenReturn("aa");
assertThat(underTest.isAccepted(factoryAnnotatedElementMiror)).is(true);

when(factoryAnnotatedElementMiror.getSurroundingFullyQualifiedName()).thenReturn("bb");
assertThat(underTest.isAccepted(factoryAnnotatedElementMiror)).is(true);

when(factoryAnnotatedElementMiror.getSurroundingFullyQualifiedName()).thenReturn("cc");
assertThat(underTest.isAccepted(factoryAnnotatedElementMiror)).is(false);
}

@Test
public void testConstructorWithTwoEntryAndOneTargetMethod() throws IOException {
when(processingEnv.getFiler().createSourceFile(Mockito.eq("target"), Mockito.anyVararg()))
Expand Down

0 comments on commit 48ce78d

Please sign in to comment.