Skip to content

Commit

Permalink
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Change tests from Groovy/Spock into Java/Junit
Browse files Browse the repository at this point in the history
trondsevre committed Nov 13, 2024

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature.
1 parent 346ecac commit 531c4e8
Showing 14 changed files with 339 additions and 215 deletions.
2 changes: 2 additions & 0 deletions src/main/java/no/fint/oauth/OAuthTokenProps.java
Original file line number Diff line number Diff line change
@@ -6,6 +6,7 @@
import com.fasterxml.jackson.databind.ObjectMapper;
import jakarta.annotation.PostConstruct;
import lombok.Getter;
import lombok.Setter;
import lombok.ToString;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Configuration;
@@ -14,6 +15,7 @@
import java.io.IOException;

@Getter
@Setter
@ToString
@Configuration
@JsonIgnoreProperties(ignoreUnknown = true)
9 changes: 7 additions & 2 deletions src/main/java/no/fint/oauth/TokenService.java
Original file line number Diff line number Diff line change
@@ -17,16 +17,21 @@
public class TokenService {

private static final String BEARER_TOKEN_TEMPLATE = "Bearer %s";
private final RestClient restClient = RestClient.builder().build();
private final RestClient restClient;
private final OAuthTokenProps props;
private final MultiValueMap<String, String> formData;
private AuthToken authToken;

public TokenService(OAuthTokenProps props) {
public TokenService(OAuthTokenProps props, RestClient restClient) {
this.props = props;
this.restClient = restClient;
this.formData = createFormData();
}

public TokenService(OAuthTokenProps props) {
this(props, RestClient.builder().build());
}

@PostConstruct
public void init() {
if (StringUtils.isEmpty(props.getRequestUrl())) {

This file was deleted.

This file was deleted.

35 changes: 0 additions & 35 deletions src/test/groovy/no/fint/oauth/OAuthConfigSpec.groovy

This file was deleted.

18 changes: 0 additions & 18 deletions src/test/groovy/no/fint/oauth/OAuthRestTemplateFactorySpec.groovy

This file was deleted.

33 changes: 0 additions & 33 deletions src/test/groovy/no/fint/oauth/TokenServiceIntegrationSpec.groovy

This file was deleted.

74 changes: 0 additions & 74 deletions src/test/groovy/no/fint/oauth/TokenServiceSpec.groovy

This file was deleted.

10 changes: 0 additions & 10 deletions src/test/groovy/no/fint/oauth/testutils/TestApplication.java

This file was deleted.

25 changes: 25 additions & 0 deletions src/test/java/no/fint/oauth/AuthTokenTest.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
package no.fint.oauth;

import org.junit.jupiter.api.Test;
import static org.junit.jupiter.api.Assertions.*;

public class AuthTokenTest {

@Test
public void testAuthTokenCreation() {
String accessToken = "sampleAccessToken";
String tokenType = "Bearer";
int expiresIn = 3600;
String acr = "Level4";
String scope = "read write";

AuthToken authToken = new AuthToken(accessToken, tokenType, expiresIn, acr, scope);

assertNotNull(authToken);
assertEquals(accessToken, authToken.accessToken());
assertEquals(tokenType, authToken.tokenType());
assertEquals(expiresIn, authToken.expiresIn());
assertEquals(acr, authToken.acr());
assertEquals(scope, authToken.scope());
}
}
Loading

0 comments on commit 531c4e8

Please sign in to comment.