Kong / unirest-java

Unirest in Java: Simplified, lightweight HTTP client library.
http://kong.github.io/unirest-java/
MIT License
2.6k stars 594 forks source link

MockServer is not found #466

Closed mehiatt closed 1 year ago

mehiatt commented 1 year ago

I was trying to mock the unirest request:

@Test
public void POST_AuthUser_201() throws Exception {
        when(Unirest.get(MockServer.GET)).thenReturn(getRequest);
        ...
}

However I can't import MockServer. I have tried serveral maven imports in pom.xml including:

                 <dependency>
            <groupId>com.konghq</groupId>
            <artifactId>unirest-java</artifactId>
            <version>3.14.1</version>
            <classifier>standalone</classifier>
        </dependency>
        <dependency>
            <groupId>com.konghq</groupId>
            <artifactId>unirest-bdd-tests</artifactId>
            <version>3.14.1</version>
            <scope>import</scope>
        </dependency>
        <dependency>
            <groupId>com.konghq</groupId>
            <artifactId>unirest-mocks</artifactId>
            <version>3.11.09</version>
            <scope>test</scope>
        </dependency>

and I can't import MockServer from any of them. Tried two different IDEs as well (Eclipse and IntelliJ).

Based on the examples I have found online and in the docs, one of these imports should be working.

ryber commented 1 year ago

"MockServer" is not a production class, it's part of Unirest's test suite. If you want to use the Unirest mocking library see https://github.com/Kong/unirest-java/tree/main/unirest-mocks#usage

What documentation did you see that said you should be able to do that? Unirest has no native support for Mockito that would allow that