From 27841072bd165a6b0cf4179fa99d057868b144fe Mon Sep 17 00:00:00 2001 From: Lars Briem Date: Sun, 24 Nov 2019 17:56:57 +0100 Subject: [PATCH] #389 Support More Complex CSS Selectors Test building of predicates. --- .../web/selenium/css/TransformerTest.java | 61 ------------------- 1 file changed, 61 deletions(-) delete mode 100644 src/test/java/de/retest/web/selenium/css/TransformerTest.java diff --git a/src/test/java/de/retest/web/selenium/css/TransformerTest.java b/src/test/java/de/retest/web/selenium/css/TransformerTest.java deleted file mode 100644 index 59eba1b71..000000000 --- a/src/test/java/de/retest/web/selenium/css/TransformerTest.java +++ /dev/null @@ -1,61 +0,0 @@ -package de.retest.web.selenium.css; - -import static org.assertj.core.api.Assertions.assertThat; -import static org.junit.Assert.assertFalse; -import static org.junit.jupiter.api.Assertions.assertAll; -import static org.junit.jupiter.api.Assertions.assertTrue; -import static org.mockito.Mockito.when; - -import java.util.function.Function; -import java.util.function.Predicate; -import java.util.regex.Pattern; - -import org.junit.jupiter.api.Test; -import org.junit.jupiter.api.extension.ExtendWith; -import org.mockito.Mock; -import org.mockito.junit.jupiter.MockitoExtension; - -import de.retest.recheck.ui.descriptors.Element; - -@ExtendWith( MockitoExtension.class ) -class TransformerTest { - - private static final String SELECTOR_PATTERN = "[a-z;]+"; - private static final String SELECTED_PART = "abc;"; - private static final String REMAINING_PART = "b l u b"; - private static final String TRIMMED_REMAINING_PART = REMAINING_PART.trim(); - @Mock - private Function> factory; - @Mock - private Element element; - - @Test - void does_not_match() throws Exception { - final Pattern cssPattern = Pattern.compile( "^(" + SELECTOR_PATTERN + ";)(.*)" ); - final Transformer transformer = new Transformer( cssPattern, factory ); - - final String selectorString = "002;blub"; - final Selector cssSelector = transformer.transform( selectorString ); - - assertAll( () -> assertFalse( cssSelector.matches() ), - () -> assertFalse( cssSelector.predicate().test( element ) ), - () -> assertThat( cssSelector.remainingSelector() ).isEqualTo( selectorString ) ); - } - - @Test - void matches_regex() throws Exception { - when( factory.apply( SELECTED_PART ) ).thenReturn( e -> true ); - final Transformer transformer = newTransformer(); - - final Selector cssSelector = transformer.transform( SELECTED_PART + REMAINING_PART ); - - assertAll( () -> assertTrue( cssSelector.matches() ), - () -> assertTrue( cssSelector.predicate().test( element ) ), - () -> assertThat( cssSelector.remainingSelector() ).isEqualTo( TRIMMED_REMAINING_PART ) ); - } - - private Transformer newTransformer() { - final Pattern cssPattern = Pattern.compile( "^(" + SELECTOR_PATTERN + ";)(.*)" ); - return new Transformer( cssPattern, factory ); - } -}