Java / Maven Selenium - Retrolambdas для Java 7 - PullRequest
0 голосов
/ 12 октября 2018

Привет всем: у меня есть некоторые проблемы с использованием Lambdas в Java 7. В рабочих целях я не могу перейти на Java 8. Я изучал Retrolambdas и пытаюсь их реализовать.

Это мойPOM

    <?xml version="1.0" encoding="UTF-8"?>
<project xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         xmlns="http://maven.apache.org/POM/4.0.0"
         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>

    <groupId>cl.coopeuch</groupId>
    <artifactId>automatizacion_test_eibs</artifactId>
    <version>1.0-SNAPSHOT</version>

    <properties>
        <maven.compiler.source>1.7</maven.compiler.source>
        <maven.compiler.target>1.7</maven.compiler.target>
        <junit.version>5.0.0</junit.version>
        <selenium.version>3.4.0</selenium.version>
        <surefire.version>2.12.4</surefire.version>
        <slf4j.version>1.7.25</slf4j.version>
        <log4j.version>2.9.1</log4j.version>
        <testng.version>6.11</testng.version>
        <apache.poi.version>3.16</apache.poi.version>
    </properties>

    <dependencies>
        <dependency>
            <groupId>org.seleniumhq.selenium</groupId>
            <artifactId>selenium-java</artifactId>
            <version>${selenium.version}</version>
        </dependency>
        <dependency>
            <groupId>junit</groupId>
            <artifactId>junit</artifactId>
            <version>4.12</version>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>org.slf4j</groupId>
            <artifactId>slf4j-api</artifactId>
            <version>${slf4j.version}</version>
        </dependency>
        <dependency>
            <groupId>org.seleniumhq.selenium</groupId>
            <artifactId>selenium-chrome-driver</artifactId>
            <version>${selenium.version}</version>
        </dependency>
        <dependency>
            <groupId>org.seleniumhq.selenium</groupId>
            <artifactId>selenium-remote-driver</artifactId>
            <version>${selenium.version}</version>
        </dependency>
        <dependency>
            <groupId>org.seleniumhq.selenium</groupId>
            <artifactId>selenium-firefox-driver</artifactId>
            <version>${selenium.version}</version>
        </dependency>
        <dependency>
            <groupId>org.seleniumhq.selenium</groupId>
            <artifactId>selenium-server</artifactId>
            <version>${selenium.version}</version>
        </dependency>
        <dependency>
            <groupId>org.seleniumhq.selenium</groupId>
            <artifactId>selenium-ie-driver</artifactId>
            <version>${selenium.version}</version>
        </dependency>
        <dependency>
            <groupId>org.seleniumhq.selenium</groupId>
            <artifactId>selenium-edge-driver</artifactId>
            <version>${selenium.version}</version>
        </dependency>
        <dependency>
            <groupId>org.seleniumhq.selenium</groupId>
            <artifactId>selenium-opera-driver</artifactId>
            <version>${selenium.version}</version>
        </dependency>
        <dependency>
            <groupId>org.seleniumhq.selenium</groupId>
            <artifactId>selenium-safari-driver</artifactId>
            <version>${selenium.version}</version>
        </dependency>
        <dependency>
            <groupId>org.apache.poi</groupId>
            <artifactId>poi</artifactId>
            <version>${apache.poi.version}</version>
        </dependency>
        <dependency>
            <groupId>org.apache.logging.log4j</groupId>
            <artifactId>log4j-core</artifactId>
            <version>${log4j.version}</version>
        </dependency>
        <dependency>
            <groupId>org.apache.logging.log4j</groupId>
            <artifactId>log4j-api</artifactId>
            <version>${log4j.version}</version>
        </dependency>
        <dependency>
            <groupId>org.apache.poi</groupId>
            <artifactId>poi-ooxml</artifactId>
            <version>${apache.poi.version}</version>
        </dependency>
        <dependency>
            <groupId>org.testng</groupId>
            <artifactId>testng</artifactId>
            <version>${testng.version}</version>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>io.appium</groupId>
            <artifactId>java-client</artifactId>
            <version>${appium.version}</version>
            <scope>test</scope>
        </dependency>

        <dependency>
            <groupId>io.cucumber</groupId>
            <artifactId>gherkin</artifactId>
            <version>${cucumber.version}</version>
        </dependency>

        <dependency>
            <groupId>io.cucumber</groupId>
            <artifactId>cucumber-core</artifactId>
            <version>${cucumber.version}</version>
            <scope>test</scope>
        </dependency>

        <dependency>
            <groupId>com.github.stephenc.monte</groupId>
            <artifactId>monte-screen-recorder</artifactId>
            <version>0.7.7.0</version>
        </dependency>

        <dependency>
            <groupId>io.cucumber</groupId>
            <artifactId>cucumber-jvm</artifactId>
            <version>${cucumber.version}</version>
            <type>pom</type>
        </dependency>

        <dependency>
            <groupId>io.cucumber</groupId>
            <artifactId>cucumber-java</artifactId>
            <version>3.0.0</version>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>io.cucumber</groupId>
            <artifactId>cucumber-core</artifactId>
            <version>3.0.2</version>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>info.cukes</groupId>
            <artifactId>cucumber-junit</artifactId>
            <version>1.2.5</version>
            <scope>test</scope>
        </dependency>

        <dependency>
            <groupId>net.sourceforge.streamsupport</groupId>
            <artifactId>streamsupport</artifactId>
            <version>1.1.2</version>
        </dependency>

        <!--retrolambda -->
        <dependency>
            <groupId>net.orfjackal.retrolambda</groupId>
            <artifactId>retrolambda-maven-plugin</artifactId>
            <version>2.5.5</version>
        </dependency>


    </dependencies>
    <build>
        <plugins>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-surefire-plugin</artifactId>
                <version>${surefire.version}</version>
                <configuration>
                    <skipTests>true</skipTests>
                </configuration>
            </plugin>
           <!-- Retrolambda -->
            <plugin>
                <groupId>net.orfjackal.retrolambda</groupId>
                <artifactId>retrolambda-maven-plugin</artifactId>
                <version>2.5.5</version>
                <executions>
                    <execution>
                        <goals>
                            <goal>process-main</goal>
                            <goal>process-test</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>
        </plugins>


    </build>

</project>

Как видите, я добавил плагин и зависимость для Retrolambdas, но в некоторых классах невозможно распознать некоторые операции импорта и методы, подобные следующему:

import java.util.stream.Stream;

import static java.lang.Math.toIntExact;

Часть класса здесь:

public Object[][] getData(Class clazz) {
        ClassLoader classLoader = getClass().getClassLoader();
        Path path = null;
        try {
            String name = clazz.getSimpleName() + ".txt";
            path = Paths.get(classLoader.getResource("datos/" + name).toURI());
        } catch (NullPointerException | URISyntaxException e) {
            logger.error(e);
        }
        try {
            Stream<String> stream = Files.lines(path);
            List<String> stream2 = new ArrayList<>();
            stream.forEach((String s) -> stream2.add(s));
            int count = toIntExact(stream2.size());
            stream2.forEach(s -> initializeArray(count, fieldCount(s)));
            x = 0;
            stream2.forEach(s -> assign(field(s)));
        } catch (IOException e) {
            logger.error(e);
        }
        return result;
    }

Некоторые аннотации, такие как forEach, toIntExact, Stream, строки помечены красным.

Может ли кто-нибудь помочь мне?

...