This repository has been archived by the owner on Oct 7, 2022. It is now read-only.
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
(NEW) pom.xml: cobertura configuration set to 85% target (NEW) .travis.yml: cobertura execution now fails if target coverage is not met (REF) CONTRIBUTING.md: updated documentation accordingly (FIX) Added a few unit tests to meet target coverage: - BadRequestTest - ForbiddenResponseTest - InternalServerErrorResponseTest - PageTest - UnauthorizedResponseTest (REF) Pagination: field declared as Supplier<HttpUriRequest> instead of PageUri so that cobertura would stop saying that the 'Supplier' contract of PageUri was not being tested (NEW) A few more HTTP mocks to support tests: - MockThrowingHttpClient - MockBadRequestResponse - MockInternalErrorResponse - MockUnauthorizedResponse * (#145) Fail build if code coverage target is not met (FIX) Build was not generating coverage report
- Loading branch information
Showing
17 changed files
with
995 additions
and
31 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
39 changes: 39 additions & 0 deletions
39
src/test/java/org/llorllale/youtrack/api/BadRequestTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
/* | ||
* Copyright 2018 George Aristy. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
package org.llorllale.youtrack.api; | ||
|
||
import java.io.IOException; | ||
import org.junit.Test; | ||
import org.llorllale.youtrack.api.mock.http.response.MockBadRequestResponse; | ||
|
||
/** | ||
* | ||
* @author George Aristy (george.aristy@gmail.com) | ||
* @since 1.0.0-SNAPSHOT | ||
*/ | ||
public class BadRequestTest { | ||
|
||
/** | ||
* Should throw {@link IOException} if server returns error code 400. | ||
* | ||
* @since 1.0.0 | ||
*/ | ||
@Test(expected = IOException.class) | ||
public void testHttpResponse() throws Exception { | ||
new BadRequest(() -> new MockBadRequestResponse()).httpResponse(); | ||
} | ||
} |
40 changes: 40 additions & 0 deletions
40
src/test/java/org/llorllale/youtrack/api/ForbiddenResponseTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
/* | ||
* Copyright 2018 George Aristy. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
package org.llorllale.youtrack.api; | ||
|
||
import org.junit.Test; | ||
import org.llorllale.youtrack.api.mock.http.response.MockForbiddenResponse; | ||
import org.llorllale.youtrack.api.session.UnauthorizedException; | ||
|
||
/** | ||
* Unit tests for {@link ForbiddenResponse}. | ||
* | ||
* @author George Aristy (george.aristy@gmail.com) | ||
* @since 1.0.0 | ||
*/ | ||
public class ForbiddenResponseTest { | ||
|
||
/** | ||
* Should throw {@link UnauthorizedException} if server returns error code 403. | ||
* | ||
* @since 1.0.0 | ||
*/ | ||
@Test(expected = UnauthorizedException.class) | ||
public void testHttpResponse() throws Exception { | ||
new ForbiddenResponse(() -> new MockForbiddenResponse()).httpResponse(); | ||
} | ||
} |
41 changes: 41 additions & 0 deletions
41
src/test/java/org/llorllale/youtrack/api/InternalServerErrorResponseTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
/* | ||
* Copyright 2018 George Aristy. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
package org.llorllale.youtrack.api; | ||
|
||
import java.io.IOException; | ||
import org.junit.Test; | ||
import org.llorllale.youtrack.api.mock.http.response.MockInternalErrorResponse; | ||
|
||
/** | ||
* Unit tests for {@link InternalServerErrorResponse}. | ||
* | ||
* @author George Aristy (george.aristy@gmail.com) | ||
* @since 1.0.0 | ||
*/ | ||
public class InternalServerErrorResponseTest { | ||
|
||
/** | ||
* Should throw an {@link IOException} if the YouTrack server returns an HTTP response with | ||
* code 500. | ||
* | ||
* @since 1.0.0 | ||
*/ | ||
@Test(expected = IOException.class) | ||
public void testHttpResponse() throws Exception { | ||
new InternalServerErrorResponse(() -> new MockInternalErrorResponse()).httpResponse(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,83 @@ | ||
/* | ||
* Copyright 2018 George Aristy. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
package org.llorllale.youtrack.api; | ||
|
||
import java.util.Collections; | ||
import java.util.NoSuchElementException; | ||
import static org.junit.Assert.assertFalse; | ||
import org.junit.Test; | ||
import org.llorllale.youtrack.api.mock.http.MockHttpClient; | ||
import org.llorllale.youtrack.api.mock.http.MockThrowingHttpClient; | ||
import org.llorllale.youtrack.api.mock.http.response.MockOkResponse; | ||
|
||
/** | ||
* Unit tests for {@link Page}. | ||
* | ||
* @author George Aristy (george.aristy@gmail.com) | ||
* @since 1.0.0 | ||
*/ | ||
public class PageTest { | ||
/** | ||
* Ctor must wrap IOExceptions in UncheckedException. | ||
* | ||
* @since 1.0.0 | ||
*/ | ||
@Test(expected = UncheckedException.class) | ||
public void ctorUncheckedExceptionThrow() { | ||
new Page<>( | ||
null, | ||
r -> Collections.<String>emptyList(), | ||
new MockThrowingHttpClient() | ||
); | ||
} | ||
|
||
/** | ||
* next() must throw NoSuchElementException if contents is empty. | ||
* | ||
* @since 1.0.0 | ||
*/ | ||
@Test(expected = NoSuchElementException.class) | ||
public void nextNoSuchElementException() { | ||
new Page<>( | ||
null, | ||
r -> Collections.<String>emptyList(), | ||
new MockHttpClient(new MockOkResponse()) | ||
).next(); | ||
} | ||
|
||
/** | ||
* Page.Empty.hasNext() should always return {@code false}. | ||
* | ||
* @since 1.0.0 | ||
*/ | ||
@Test | ||
public void emptyHasNextAlwaysFalse() { | ||
assertFalse( | ||
new Page.Empty<>().hasNext() | ||
); | ||
} | ||
|
||
/** | ||
* Page.Empty.next() should always throw {@link NoSuchElementException}. | ||
* | ||
* @since 1.0.0 | ||
*/ | ||
@Test(expected = NoSuchElementException.class) | ||
public void emptyNextAlwaysThrowsNoSuchElementException() { | ||
new Page.Empty<>().next(); | ||
} | ||
} |
Oops, something went wrong.