Skip to content
This repository was archived by the owner on Jul 7, 2021. It is now read-only.
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 16 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,59 +9,67 @@
[![License](https://img.shields.io/badge/License-Apache%202.0-blue.svg)](http://www.apache.org/licenses/LICENSE-2.0)

### Releases

[![Maven Central](https://maven-badges.herokuapp.com/maven-central/org.proshin/finapi-java-client/badge.svg)](https://maven-badges.herokuapp.com/maven-central/org.proshin/finapi-java-client)
[![FOSSA Status](https://app.fossa.io/api/projects/git%2Bgithub.com%2Fproshin-roman%2Ffinapi-java-client.svg?type=shield)](https://app.fossa.io/projects/git%2Bgithub.com%2Fproshin-roman%2Ffinapi-java-client?ref=badge_shield)
[![](https://jitpack.io/v/proshin-roman/finapi-java-client.svg)](https://jitpack.io/#proshin-roman/finapi-java-client)

### Builds

[![Build Status](https://travis-ci.com/proshin-roman/finapi-java-client.svg?branch=master)](https://travis-ci.com/proshin-roman/finapi-java-client)
[![Build status](https://ci.appveyor.com/api/projects/status/n88wydxq8oa0eou0/branch/master?svg=true)](https://ci.appveyor.com/project/proshin-roman/finapi-java-client/branch/master)

### Code quality

[![codecov](https://codecov.io/gh/proshin-roman/finapi-java-client/branch/master/graph/badge.svg)](https://codecov.io/gh/proshin-roman/finapi-java-client)
[![Coverage Status](https://coveralls.io/repos/github/proshin-roman/finapi-java-client/badge.svg?branch=coverall-integration)](https://coveralls.io/github/proshin-roman/finapi-java-client?branch=master)
[![codebeat badge](https://codebeat.co/badges/907cb4b8-0f65-446a-a874-9ece228ab579)](https://codebeat.co/projects/github-com-proshin-roman-finapi-java-client-master)
[![SonarCloud](https://sonarcloud.io/api/project_badges/measure?project=org.proshin%3Afinapi-java-client&metric=alert_status)](https://sonarcloud.io/dashboard?id=org.proshin%3Afinapi-java-client)
[![CodeFactor](https://www.codefactor.io/repository/github/proshin-roman/finapi-java-client/badge)](https://www.codefactor.io/repository/github/proshin-roman/finapi-java-client)
[![Hits-of-Code](https://hitsofcode.com/github/proshin-roman/finapi-java-client)](https://hitsofcode.com/view/github/proshin-roman/finapi-java-client)


### Puzzle Driven Development

[![PDD status](http://www.0pdd.com/svg?name=proshin-roman/finapi-java-client)](http://www.0pdd.com/p?name=proshin-roman/finapi-java-client)

### Community
[![Join the chat at https://gitter.im/finapi-java-client/Lobby](https://badges.gitter.im/finapi-java-client/Lobby.svg)](https://gitter.im/finapi-java-client/Lobby?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge)

[![Join the chat at https://gitter.im/finapi-java-client/Lobby](https://badges.gitter.im/finapi-java-client/Lobby.svg)](https://gitter.im/finapi-java-client/Lobby?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge)

**finapi-java-client** is a true-OOP Java client for API provided by [finAPI](https://finapi.io).

## Principles

The project is following the next principles (it is a subset of [those ones](https://www.elegantobjects.org/#principles)):
- No null
![nullfree status](https://iwillfailyou.com/nullfree/proshin-roman/finapi-java-client)
- No getters and setters
![setterfree status](https://iwillfailyou.com/setterfree/proshin-roman/finapi-java-client)
- No mutable objects
![allfinal status](https://iwillfailyou.com/allfinal/proshin-roman/finapi-java-client)
- No static methods, not even private ones
![staticfree status](https://iwillfailyou.com/staticfree/proshin-roman/finapi-java-client)
![allpublic status](https://iwillfailyou.com/allpublic/proshin-roman/finapi-java-client)
- No instanceof, type casting or reflection
- No implementation inheritance
![inheritancefree status](https://iwillfailyou.com/inheritancefree/proshin-roman/finapi-java-client)
- No multiple returns
![nomultiplereturn status](https://iwillfailyou.com/nomultiplereturn/proshin-roman/finapi-java-client)

All badges are through [iwillfailyou](https://iwillfailyou.com/)

![nullfree status](https://iwillfailyou.com/nullfree/proshin-roman/finapi-java-client)
![staticfree status](https://iwillfailyou.com/staticfree/proshin-roman/finapi-java-client)
![allfinal status](https://iwillfailyou.com/allfinal/proshin-roman/finapi-java-client)
![allpublic status](https://iwillfailyou.com/allpublic/proshin-roman/finapi-java-client)

## How to use

Just add the following lines into your `pom.xml`

```!xml
<dependency>
<groupId>org.proshin</groupId>
<artifactId>finapi-java-client</artifactId>
<version>${version}</version>
</dependency>
```

You can find the latest `version` on [`Releases`](https://github.com/proshin-roman/finapi-java-client/releases) page.

## What about logging?
Expand Down Expand Up @@ -98,6 +106,7 @@ Versioning is done using [jgitver](https://github.com/jgitver/jgitver) tool, so
the version.

## License

Copyright 2018-2019 Roman Proshin

Licensed under the Apache License, Version 2.0 (the "License");
Expand Down
19 changes: 18 additions & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -280,7 +280,7 @@
<plugin>
<groupId>com.iwillfailyou</groupId>
<artifactId>iwillfailyou-maven-plugin</artifactId>
<version>0.2.0</version>
<version>0.5.0</version>

<!-- then configure it, if you need: -->
<configuration>
Expand All @@ -304,7 +304,24 @@
<allpublic>
<disabled>false</disabled><!-- default false -->
<threshold>0</threshold><!-- default 0 -->
<!-- sonarcloud recommends removing 'public' for junit5 classes and tests -->
<exclude>glob:**/test/**/*Test.java</exclude>
</allpublic>
<setterfree>
<disabled>false</disabled><!-- default false -->
<threshold>0</threshold><!-- default 0 -->
</setterfree>
<nomultiplereturn>
<disabled>false</disabled><!-- default false -->
<threshold>0</threshold><!-- default 0 -->
</nomultiplereturn>
<inheritancefree>
<disabled>false</disabled><!-- default false -->
<threshold>0</threshold><!-- default 0 -->
<!-- test classes can extend 'TestWithMockedEndpoint' -->
<!-- custom Exceptions can extend 'RuntimeException' -->
<exclude>glob:**/test/**/*Test.java,glob:**/main/**/*Exception.java</exclude>
</inheritancefree>
</configuration>
</plugin>
</plugins>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ public FpTwoStepProcedures(final JSONObject origin) {
}

@Override
@SuppressWarnings("nomultiplereturn") // will be fixed in https://github.com/iwillfailyou/java-inspections/pull/24
public Optional<TwoStepProcedure> defaultOne() {
return new OptionalOf<>(
this.origin,
Expand Down
2 changes: 2 additions & 0 deletions src/main/java/org/proshin/finapi/endpoint/FpEndpoint.java
Original file line number Diff line number Diff line change
Expand Up @@ -168,10 +168,12 @@ public String patch(final String path, final AccessToken token, final Jsonable b
);
}

@SuppressWarnings("allpublic")
private String execute(final HttpUriRequest request) {
return this.execute(request, HttpStatus.SC_OK);
}

@SuppressWarnings("allpublic")
private String execute(final HttpUriRequest request, final int expected) {
try {
final HttpResponse response = this.client.execute(request);
Expand Down
1 change: 1 addition & 0 deletions src/main/java/org/proshin/finapi/mandator/FpMandator.java
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ public Page<User> users(final UsersCriteria criteria) {
}

@Override
@SuppressWarnings("nomultiplereturn") // will be fixed in https://github.com/iwillfailyou/java-inspections/pull/24
public DeletionResult deleteUsers(final Iterable<String> ids) {
return new FpDeletionResult(
new JSONObject(
Expand Down
4 changes: 2 additions & 2 deletions src/test/java/org/proshin/finapi/TestWithMockedEndpoint.java
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
import org.proshin.finapi.endpoint.FpEndpoint;

@ExtendWith(MockServerExtension.class)
@SuppressWarnings({"AbstractClassWithoutAbstractMethods", "allfinal"})
@SuppressWarnings({"AbstractClassWithoutAbstractMethods", "allfinal", "allpublic"})
public abstract class TestWithMockedEndpoint {

@SuppressWarnings({"InstanceVariableMayNotBeInitialized", "allfinal"})
Expand All @@ -33,7 +33,7 @@ public abstract class TestWithMockedEndpoint {
private Endpoint endpoint;

@BeforeEach
public void init(@Nonnull final MockServerClient server) {
void init(@Nonnull final MockServerClient server) {
this.server = server;
this.endpoint = new FpEndpoint("http://localhost:" + this.server.remoteAddress().getPort());
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,10 @@
import org.proshin.finapi.TestWithMockedEndpoint;
import org.proshin.finapi.fake.FakeAccessToken;

public final class FpAccessTokensTest extends TestWithMockedEndpoint {
final class FpAccessTokensTest extends TestWithMockedEndpoint {

@Test
public void testThatClientTokenReturnsValidToken() {
void testThatClientTokenReturnsValidToken() {
final String clientId = "client ID #1";
final String clientSecret = "client secret #1";
this.server()
Expand Down Expand Up @@ -57,13 +57,13 @@ public void testThatClientTokenReturnsValidToken() {
final AccessToken token = new FpAccessTokens(this.endpoint()).clientToken(clientId, clientSecret);
assertThat(token.accessToken()).isEqualTo("access token");
assertThat(token.tokenType()).isEqualTo("bearer");
assertThat(token.refreshToken().isPresent()).isFalse();
assertThat(token.refreshToken()).isNotPresent();
assertThat(token.expiresIn()).isEqualTo(156);
assertThat(token.scope()).isEqualTo("all");
}

@Test
public void testThatUserTokenReturnsValidToken() {
void testThatUserTokenReturnsValidToken() {
final String clientId = "client ID #2";
final String clientSecret = "client secret #2";
final String username = "username #2";
Expand Down Expand Up @@ -103,7 +103,7 @@ public void testThatUserTokenReturnsValidToken() {
}

@Test
public void testGettingUserTokenUsingRefreshToken() {
void testGettingUserTokenUsingRefreshToken() {
final String clientId = "client ID #2";
final String clientSecret = "client secret #2";
final String refreshToken = "refresh token";
Expand Down Expand Up @@ -141,7 +141,7 @@ public void testGettingUserTokenUsingRefreshToken() {
}

@Test
public void testRevokeTokenAccessTokenOnly() {
void testRevokeTokenAccessTokenOnly() {
final String clientId = "client ID #2";
final String clientSecret = "client secret #2";
final String refreshToken = "refresh token";
Expand All @@ -167,7 +167,7 @@ public void testRevokeTokenAccessTokenOnly() {
}

@Test
public void testRevokeTokenRefreshTokenOnly() {
void testRevokeTokenRefreshTokenOnly() {
final String clientId = "client ID #2";
final String clientSecret = "client secret #2";
final String refreshToken = "refresh token";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@
import org.junit.jupiter.api.Test;
import org.proshin.finapi.exception.NoFieldException;

public final class UserAccessTokenTest {
final class UserAccessTokenTest {

@Test
public void testThatUserTokenFailsIfNoRefreshTokenIsSent() {
void testThatUserTokenFailsIfNoRefreshTokenIsSent() {
final AccessToken token = new UserAccessToken(new JSONObject(
String.join("",
"{",
Expand Down
4 changes: 2 additions & 2 deletions src/test/java/org/proshin/finapi/account/FpAccountTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,10 @@
import org.proshin.finapi.primitives.BankingInterface;
import org.proshin.finapi.primitives.OffsetDateTimeOf;

public final class FpAccountTest extends TestWithMockedEndpoint {
final class FpAccountTest extends TestWithMockedEndpoint {

@Test
public void testFields() {
void testFields() {
final Account account = new FpAccount(
this.endpoint(),
new FakeAccessToken("secure user token"),
Expand Down
8 changes: 4 additions & 4 deletions src/test/java/org/proshin/finapi/account/FpAccountsTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,10 @@
import org.proshin.finapi.fake.FakeAccessToken;
import org.proshin.finapi.primitives.OffsetDateTimeOf;

public final class FpAccountsTest extends TestWithMockedEndpoint {
final class FpAccountsTest extends TestWithMockedEndpoint {

@Test
public void testOne() {
void testOne() {
this.server()
.when(
HttpRequest.request("/api/v1/accounts/2")
Expand All @@ -47,7 +47,7 @@ public void testOne() {
}

@Test
public void testQuery() {
void testQuery() {
this.server()
.when(
HttpRequest.request("/api/v1/accounts")
Expand Down Expand Up @@ -81,7 +81,7 @@ public void testQuery() {
}

@Test
public void testDailyBalances() {
void testDailyBalances() {
this.server()
.when(
HttpRequest.request("/api/v1/accounts/dailyBalances")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,10 @@
import org.proshin.finapi.fake.FakeAccessToken;
import org.proshin.finapi.primitives.LocalDateOf;

public final class FpDirectDebitTest extends TestWithMockedEndpoint {
final class FpDirectDebitTest extends TestWithMockedEndpoint {

@Test
public void testRequest() {
void testRequest() {
this.server()
.when(
HttpRequest.request("/api/v1/accounts/requestSepaDirectDebit")
Expand Down Expand Up @@ -92,7 +92,7 @@ public void testRequest() {
}

@Test
public void testExecute() {
void testExecute() {
this.server()
.when(
HttpRequest.request("/api/v1/accounts/executeSepaDirectDebit")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,10 @@
import org.proshin.finapi.fake.FakeAccessToken;
import org.proshin.finapi.primitives.LocalDateOf;

public final class FpMoneyTransferTest extends TestWithMockedEndpoint {
final class FpMoneyTransferTest extends TestWithMockedEndpoint {

@Test
public void testRequest() {
void testRequest() {
this.server()
.when(
HttpRequest.request("/api/v1/accounts/requestSepaMoneyTransfer")
Expand Down Expand Up @@ -102,7 +102,7 @@ public void testRequest() {
}

@Test
public void testExecute() {
void testExecute() {
this.server()
.when(
HttpRequest.request("/api/v1/accounts/executeSepaMoneyTransfer")
Expand Down
6 changes: 3 additions & 3 deletions src/test/java/org/proshin/finapi/account/TypeTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -22,19 +22,19 @@
import org.junit.jupiter.params.provider.CsvSource;
import org.junit.jupiter.params.provider.ValueSource;

public final class TypeTest {
final class TypeTest {

@ParameterizedTest
@CsvSource({"1, Checking", "2, Savings", "3, CreditCard", "4, Security", "5, Loan", "6, Pocket", "7, Membership",
"8, Bausparen"
})
public void testCorrectTypes(final int typeCode, @Nonnull final Type expectedType) {
void testCorrectTypes(final int typeCode, @Nonnull final Type expectedType) {
assertThat(new TypeOf(typeCode).get()).isEqualTo(expectedType);
}

@ParameterizedTest
@ValueSource(ints = {0, -1, 9, 10, 100})
public void testIllegalCode(final int typeCode) {
void testIllegalCode(final int typeCode) {
assertThatExceptionOfType(IllegalArgumentException.class)
.isThrownBy(() -> new TypeOf(typeCode).get());
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,10 @@
import org.json.JSONObject;
import org.junit.jupiter.api.Test;

public final class FpSepaExecutingResponseTest {
final class FpSepaExecutingResponseTest {

@Test
public void test() {
void test() {
final SepaExecutingResponse response = new FpSepaExecutingResponse(
new JSONObject('{' +
" \"successMessage\": \"Auftrag ausgeführt.\"," +
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,10 @@
import org.json.JSONObject;
import org.junit.jupiter.api.Test;

public final class FpSepaRequestingResponseTest {
final class FpSepaRequestingResponseTest {

@Test
public void test() {
void test() {
final SepaRequestingResponse response = new FpSepaRequestingResponse(new JSONObject('{' +
" \"successMessage\": \"Auftrag ausgeführt.\"," +
" \"warnMessage\": \"Es liegen Warnungen vor.\"," +
Expand Down
6 changes: 3 additions & 3 deletions src/test/java/org/proshin/finapi/bank/BanksTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,10 @@
import org.proshin.finapi.primitives.paging.PagingCriteria;

@SuppressWarnings("JUnitTestMethodWithNoAssertions")
public final class BanksTest extends TestWithMockedEndpoint {
final class BanksTest extends TestWithMockedEndpoint {

@Test
public void testOne() {
void testOne() {
this.server()
.when(
HttpRequest.request("/api/v1/banks/123")
Expand All @@ -49,7 +49,7 @@ public void testOne() {
}

@Test
public void testSearch() {
void testSearch() {
this.server()
.when(
HttpRequest.request("/api/v1/banks")
Expand Down
Loading