Skip to content

Commit

Permalink
PI-15482: import testNG, class renamed
Browse files Browse the repository at this point in the history
  • Loading branch information
nicolasmagurno authored and naponce committed Apr 29, 2019
1 parent 441eea5 commit 34086ec
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 19 deletions.
6 changes: 6 additions & 0 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,12 @@
<artifactId>commons-lang3</artifactId>
<version>3.8.1</version>
</dependency>
<dependency>
<groupId>org.testng</groupId>
<artifactId>testng</artifactId>
<version>6.14.3</version>
<scope>test</scope>
</dependency>
</dependencies>

<build>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,10 @@
/**
* Functionality to find Credentials by key from a different sources: Database, ResourceFile, in memory cache, etc.
*/
public class SourceBackedCredentials implements DeveloperSpecificAppmarketCredentialsSupplier {
public class SourceBackedCredentialsSupplier implements DeveloperSpecificAppmarketCredentialsSupplier {
private final Function<String, Credentials> credentialsFinder;

public SourceBackedCredentials(Function<String, Credentials> credentialsFinder) {
public SourceBackedCredentialsSupplier(Function<String, Credentials> credentialsFinder) {
this.credentialsFinder = credentialsFinder;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
* Creates an in-memory cache of (developer key ⟶ developer secret) pairs from a string of the following format:
* <p>
* devKey1:devPassword1,devKey2:devPassTwo
* @deprecated will be replaced by {@link SourceBackedCredentials}
* @deprecated will be replaced by {@link SourceBackedCredentialsSupplier}
*/
@Deprecated
public class StringBackedCredentialsSupplier implements DeveloperSpecificAppmarketCredentialsSupplier {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,46 +4,40 @@

import java.util.function.Function;

import org.junit.Before;
import org.junit.Test;
import org.testng.annotations.BeforeMethod;
import org.testng.annotations.Test;

import static org.assertj.core.api.Assertions.assertThat;

public class SourceBackedCredentialsTest {
private SourceBackedCredentials findCredentials;
public class SourceBackedCredentialsSupplierTest {
private SourceBackedCredentialsSupplier sourceBackedCredentialsSupplier;
private Function<String, Credentials> functionTest = (String k) -> {
if (k.equalsIgnoreCase("bad-key")) {
return Credentials.invalidCredentials();
}
return new Credentials(k,"s1");
};

@Before
@BeforeMethod
public void setUp() {
findCredentials = new SourceBackedCredentials(functionTest);
sourceBackedCredentialsSupplier = new SourceBackedCredentialsSupplier(functionTest);
}

@Test
public void returnsGoodCredentials_whenKeyIsFound() throws Exception {
//Given
public void returnsGoodCredentials_whenKeyIsFound() {
Credentials expected = Credentials.builder().developerKey("key1").developerSecret("s1").build();

//When
Credentials credentials = findCredentials.getConsumerCredentials("key1");
Credentials credentials = sourceBackedCredentialsSupplier.getConsumerCredentials("key1");

//Then
assertThat(credentials).isEqualTo(expected);
}

@Test
public void returnsInvalidCredentials_whenKeyIsNotFound() throws Exception {
//Given
public void returnsInvalidCredentials_whenKeyIsNotFound() {
Credentials expected = Credentials.invalidCredentials();

//When
Credentials credentials = findCredentials.getConsumerCredentials("bad-key");
Credentials credentials = sourceBackedCredentialsSupplier.getConsumerCredentials("bad-key");

//Then
assertThat(credentials).isEqualTo(expected);
}
}

0 comments on commit 34086ec

Please sign in to comment.