Skip to content

Commit

Permalink
Remove usage of BiFunction from keycloak-core module
Browse files Browse the repository at this point in the history
  • Loading branch information
mhajas authored and hmlnarik committed Apr 4, 2022
1 parent 395bd44 commit 01e16a5
Showing 1 changed file with 8 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@

import java.nio.charset.Charset;
import java.util.NoSuchElementException;
import java.util.function.BiFunction;

import javax.xml.stream.XMLEventReader;
import javax.xml.stream.XMLStreamException;
Expand Down Expand Up @@ -249,9 +248,13 @@ public void testXMLBombAttack() throws XMLStreamException {
}
}

private interface StartElementHasQNameBooleanBiFunction {
Boolean apply(StartElement el, HasQName qName);
}

@Test
public void testGetBooleanAttributeValue() throws XMLStreamException, ParsingException {
testGetBooleanAttributeValue(new BiFunction<StartElement, HasQName, Boolean>() {
testGetBooleanAttributeValue(new StartElementHasQNameBooleanBiFunction() {
@Override
public Boolean apply(StartElement t, HasQName u) {
return StaxParserUtil.getBooleanAttributeValue(t, u);
Expand All @@ -261,15 +264,15 @@ public Boolean apply(StartElement t, HasQName u) {

@Test
public void testGetBooleanAttributeValueRP() throws XMLStreamException, ParsingException {
testGetBooleanAttributeValue(new BiFunction<StartElement, HasQName, Boolean>() {
testGetBooleanAttributeValue(new StartElementHasQNameBooleanBiFunction() {
@Override
public Boolean apply(StartElement t, HasQName u) {
return StaxParserUtil.getBooleanAttributeValueRP(t, u);
}
});
}

private void testGetBooleanAttributeValue(BiFunction<StartElement, HasQName, Boolean> predicate) throws XMLStreamException, ParsingException {
private void testGetBooleanAttributeValue(StartElementHasQNameBooleanBiFunction predicate) throws XMLStreamException, ParsingException {
testGetBooleanAttributeValue("<a AllowCreate=\"false\">text</a>", predicate, false);
testGetBooleanAttributeValue("<a AllowCreate=\"true\">text</a>", predicate, true);
testGetBooleanAttributeValue("<a AllowCreate=\"0\">text</a>", predicate, false);
Expand All @@ -278,7 +281,7 @@ private void testGetBooleanAttributeValue(BiFunction<StartElement, HasQName, Boo
testGetBooleanAttributeValue("<a>text</a>", predicate, null);
}

private void testGetBooleanAttributeValue(String xml, BiFunction<StartElement, HasQName, Boolean> predicate, Boolean expectedResult) throws XMLStreamException, ParsingException {
private void testGetBooleanAttributeValue(String xml, StartElementHasQNameBooleanBiFunction predicate, Boolean expectedResult) throws XMLStreamException, ParsingException {
XMLEventReader reader = StaxParserUtil.getXMLEventReader(IOUtils.toInputStream(xml, Charset.defaultCharset()));

assertThat(reader.nextEvent(), instanceOf(StartDocument.class));
Expand Down

0 comments on commit 01e16a5

Please sign in to comment.