Skip to content

Commit

Permalink
fix test and increase version to RC3
Browse files Browse the repository at this point in the history
  • Loading branch information
masciale89 committed Jun 19, 2023
1 parent ae7a76a commit 4fe0104
Show file tree
Hide file tree
Showing 10 changed files with 39 additions and 42 deletions.
4 changes: 2 additions & 2 deletions assertion-rest-client-native/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -72,11 +72,11 @@ tasks.named('test') {
/*
!! WARNING:
Generated client do not handle `Ocp-Apim-Subscription-Key` header.
We added it to `ApiClient` class, by defining the interseptor as
We added it to `ApiClient` class, by defining the interceptor as
`interceptor = t -> t.header("Ocp-Apim-Subscription-Key", config.getSubscriptionKey());`
If we need to regenerate the client, please copy/paste this pieace of code again to `ApiClient class construction`.
If we need to regenerate the client, please copy/paste this piece of code again to `ApiClient class construction`.
----------------
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,5 +16,5 @@ public class AssertionSimpleClientConfig {

@Builder.Default private String assertionRequestEndpoint = "/assertions";

@Builder.Default private String SubscriptionKey = "FakeSubscriptionKey";
@Builder.Default private String subscriptionKey = "FakeSubscriptionKey";
}
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ repositories {
}

allprojects {
version = '1.0.0-RC2'
version = '1.0.0-RC3'
group = 'it.pagopa.tech.lollipop-consumer-java-sdk'
sourceCompatibility = '11'
targetCompatibility = '11'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ void setUp() {

@Test
void getExistingAssertionAndResetScheduleEvictionWithStorageEnabled()
throws InterruptedException, ExecutionException {
throws InterruptedException {
doReturn(true).when(storageConfigMock).isAssertionStorageEnabled();
doReturn(1000L).when(storageConfigMock).getStorageEvictionDelay();
doReturn(TimeUnit.MILLISECONDS).when(storageConfigMock).getStorageEvictionDelayTimeUnit();
Expand Down Expand Up @@ -71,36 +71,34 @@ void getNotExistingAssertionWithStorageEnabled() {
sut.close();
}

// TODO
// @Test
// void saveAssertionAndScheduleEvictionWithStorageEnabled()
// throws InterruptedException, ExecutionException {
// doReturn(true).when(storageConfigMock).isAssertionStorageEnabled();
// doReturn(1000L).when(storageConfigMock).getStorageEvictionDelay();
//
// doReturn(TimeUnit.MILLISECONDS).when(storageConfigMock).getStorageEvictionDelayTimeUnit();
// doReturn(100L).when(storageConfigMock).getMaxNumberOfElements();
@Test
void saveAssertionAndScheduleEvictionWithStorageEnabled() throws InterruptedException {
doReturn(true).when(storageConfigMock).isAssertionStorageEnabled();
doReturn(1000L).when(storageConfigMock).getStorageEvictionDelay();

// ConcurrentHashMap<String, SoftReference<SamlAssertion>> assertionMap =
// new ConcurrentHashMap<>();
// DelayQueue<DelayedCacheObject<SamlAssertion>> delayedCacheObjects = new DelayQueue<>();
doReturn(TimeUnit.MILLISECONDS).when(storageConfigMock).getStorageEvictionDelayTimeUnit();
doReturn(100L).when(storageConfigMock).getMaxNumberOfElements();

// sut = new SimpleAssertionStorage(assertionMap, delayedCacheObjects, storageConfigMock);
// SamlAssertion samlAssertion = new SamlAssertion();
ConcurrentHashMap<String, SoftReference<SamlAssertion>> assertionMap =
new ConcurrentHashMap<>();
DelayQueue<DelayedCacheObject<SamlAssertion>> delayedCacheObjects = new DelayQueue<>();

// sut.saveAssertion(ASSERTION_REF_1, samlAssertion);
// delayedCacheObjects.poll(100, TimeUnit.MILLISECONDS);
sut = new SimpleAssertionStorage(assertionMap, delayedCacheObjects, storageConfigMock);
SamlAssertion samlAssertion = new SamlAssertion();

// assertEquals(1, assertionMap.size());
// assertEquals(1, delayedCacheObjects.size());
// assertEquals(samlAssertion, assertionMap.get(ASSERTION_REF_1).get());
sut.saveAssertion(ASSERTION_REF_1, samlAssertion);
delayedCacheObjects.poll(100, TimeUnit.MILLISECONDS);

// delayedCacheObjects.poll(1100, TimeUnit.MILLISECONDS);
// assertEquals(0, assertionMap.size());
// assertEquals(0, delayedCacheObjects.size());
assertEquals(1, assertionMap.size());
assertEquals(1, delayedCacheObjects.size());
assertEquals(samlAssertion, assertionMap.get(ASSERTION_REF_1).get());

// sut.close();
// }
delayedCacheObjects.poll(1100, TimeUnit.MILLISECONDS);
assertEquals(0, assertionMap.size());
assertEquals(0, delayedCacheObjects.size());

sut.close();
}

@Test
void saveAssertionToMaximumCapacityWithStorageEnabled() throws InterruptedException {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@
import java.util.HashMap;
import java.util.Map;
import java.util.concurrent.*;
import lombok.SneakyThrows;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;

Expand Down Expand Up @@ -67,7 +66,7 @@ void getNotExistingAssertionWithStorageEnabled() {
}

@Test
void saveAssertionAndScheduleEvictionWithStorageEnabled()
void saveIdpCertAndScheduleEvictionWithStorageEnabled()
throws InterruptedException, ExecutionException {
doReturn(true).when(storageConfigMock).isIdpCertDataStorageEnabled();

Expand Down Expand Up @@ -120,15 +119,14 @@ private CompletableFuture<Boolean> waitEvictionEnd(
CompletableFuture<Boolean> future = new CompletableFuture<>();
ExecutorService executorService = Executors.newSingleThreadScheduledExecutor();
executorService.submit(
new Runnable() {
@SneakyThrows
@Override
public void run() {
ScheduledFuture<?> scheduledFuture =
scheduledEvictionsMap.get(IDPCERTDATA_1);
() -> {
ScheduledFuture<?> scheduledFuture = scheduledEvictionsMap.get(IDPCERTDATA_1);
try {
scheduledFuture.get();
future.complete(true);
} catch (InterruptedException | ExecutionException e) {
throw new RuntimeException(e);
}
future.complete(true);
});
return future;
}
Expand Down
2 changes: 1 addition & 1 deletion samples/servlet/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ plugins {


group = 'it.pagopa.tech.lollipop.consumer.samples'
version = '1.0.0-RC2'
version = '1.0.0-RC3'
sourceCompatibility = '11'

application {
Expand Down
2 changes: 1 addition & 1 deletion samples/simple/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ plugins {


group = 'it.pagopa.tech.lollipop.consumer.samples'
version = '1.0.0-RC2'
version = '1.0.0-RC3'
sourceCompatibility = '11'

application {
Expand Down
2 changes: 1 addition & 1 deletion samples/simpleTypesafe/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ plugins {


group = 'it.pagopa.tech.lollipop.consumer.samples'
version = '1.0.0-RC2'
version = '1.0.0-RC3'
sourceCompatibility = '11'

application {
Expand Down
2 changes: 1 addition & 1 deletion samples/spring/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ plugins {
}

group = 'it.pagopa.tech.lollipop.consumer.samples'
version = '1.0.0-RC2'
version = '1.0.0-RC3'
sourceCompatibility = '11'

configurations {
Expand Down
1 change: 1 addition & 0 deletions samples/spring/src/main/resources/application.properties
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ lollipop.idp.storage.config.storageEvictionDelay=${IDP_STORAGE_EVICTION_DELAY:1}
##Assertion Client Configs
lollipop.assertion.rest.config.baseUri=${ASSERTION_REST_URI:http://localhost:3000}
lollipop.assertion.rest.config.assertionRequestEndpoint=${ASSERTION_REST_ENDPOINT:/assertions}
lollipop.assertion.rest.config.subscriptionKey=${ASSERTION_REST_SUBSCRIPTION_KEY:FakeSubscriptionKey}

##Assertion Storage Configs
lollipop.assertion.rest.config.assertionStorageEnabled=${ASSERTION_STORAGE_ENABLED:true}
Expand Down

0 comments on commit 4fe0104

Please sign in to comment.