Skip to content

Commit

Permalink
Merge pull request #8 from absmartly/feature/bumping-pom-version
Browse files Browse the repository at this point in the history
Bumping POM Version
  • Loading branch information
hermeswaldemarin committed Nov 9, 2023
2 parents dd3bb67 + 91cd64a commit 0ac4181
Show file tree
Hide file tree
Showing 22 changed files with 400 additions and 351 deletions.
2 changes: 1 addition & 1 deletion build.gradle
Expand Up @@ -13,7 +13,7 @@ plugins {


ext {
VERSION = "1.6.1"
VERSION = "1.6.2"
GROUP_ID = "com.absmartly.sdk"

slf4jVersion = "1.7.30"
Expand Down
19 changes: 10 additions & 9 deletions core-api/src/test/java/com/absmartly/sdk/ABSmartlyTest.java
Expand Up @@ -13,6 +13,7 @@
import org.mockito.ArgumentCaptor;
import org.mockito.MockedConstruction;
import org.mockito.MockedStatic;
import org.mockito.Mockito;

import com.absmartly.sdk.java.time.Clock;
import com.absmartly.sdk.json.ContextData;
Expand Down Expand Up @@ -83,9 +84,9 @@ void createContext() {
final ArgumentCaptor<AudienceMatcher> audienceMatcherCaptor = ArgumentCaptor
.forClass(AudienceMatcher.class);

contextStatic.verify(times(1),
contextStatic.verify(Mockito.timeout(5000).times(1),
() -> Context.create(any(), any(), any(), any(), any(), any(), any(), any(), any()));
contextStatic.verify(times(1),
contextStatic.verify(Mockito.timeout(5000).times(1),
() -> Context.create(clockCaptor.capture(), configCaptor.capture(), schedulerCaptor.capture(),
dataFutureCaptor.capture(), dataProviderCaptor.capture(), eventHandlerCaptor.capture(),
eventLoggerCaptor.capture(), variableParserCaptor.capture(),
Expand Down Expand Up @@ -124,7 +125,7 @@ void createContextWith() {
final Context context = absmartly.createContextWith(contextConfig, data);
assertSame(contextMock, context);

verify(dataProviderCtor.constructed().get(0), times(0)).getContextData();
verify(dataProviderCtor.constructed().get(0), Mockito.timeout(5000).times(0)).getContextData();

final ArgumentCaptor<Clock> clockCaptor = ArgumentCaptor.forClass(Clock.class);
final ArgumentCaptor<ContextConfig> configCaptor = ArgumentCaptor.forClass(ContextConfig.class);
Expand All @@ -143,9 +144,9 @@ void createContextWith() {
final ArgumentCaptor<AudienceMatcher> audienceMatcherCaptor = ArgumentCaptor
.forClass(AudienceMatcher.class);

contextStatic.verify(times(1),
contextStatic.verify(Mockito.timeout(5000).times(1),
() -> Context.create(any(), any(), any(), any(), any(), any(), any(), any(), any()));
contextStatic.verify(times(1),
contextStatic.verify(Mockito.timeout(5000).times(1),
() -> Context.create(clockCaptor.capture(), configCaptor.capture(), schedulerCaptor.capture(),
dataFutureCaptor.capture(), dataProviderCaptor.capture(), eventHandlerCaptor.capture(),
eventLoggerCaptor.capture(), variableParserCaptor.capture(),
Expand Down Expand Up @@ -177,7 +178,7 @@ void getContextData() {
final ABSmartly absmartly = ABSmartly.create(config);

final CompletableFuture<ContextData> contextDataFuture = absmartly.getContextData();
verify(dataProvider, times(1)).getContextData();
verify(dataProvider, Mockito.timeout(5000).times(1)).getContextData();

assertSame(dataFuture, contextDataFuture);
}
Expand Down Expand Up @@ -234,9 +235,9 @@ void createContextWithCustomImpls() {
final ArgumentCaptor<VariableParser> variableParserCaptor = ArgumentCaptor.forClass(VariableParser.class);
final ArgumentCaptor<AudienceMatcher> audienceMatcher = ArgumentCaptor.forClass(AudienceMatcher.class);

contextStatic.verify(times(1),
contextStatic.verify(Mockito.timeout(5000).times(1),
() -> Context.create(any(), any(), any(), any(), any(), any(), any(), any(), any()));
contextStatic.verify(times(1),
contextStatic.verify(Mockito.timeout(5000).times(1),
() -> Context.create(clockCaptor.capture(), configCaptor.capture(), schedulerCaptor.capture(),
dataFutureCaptor.capture(), dataProviderCaptor.capture(), eventHandlerCaptor.capture(),
eventLoggerCaptor.capture(), variableParserCaptor.capture(), audienceMatcher.capture()));
Expand Down Expand Up @@ -274,7 +275,7 @@ void close() throws IOException, InterruptedException {

absmartly.close();

verify(scheduler, times(1)).awaitTermination(anyLong(), any());
verify(scheduler, Mockito.timeout(5000).times(1)).awaitTermination(anyLong(), any());
}
}
}
43 changes: 25 additions & 18 deletions core-api/src/test/java/com/absmartly/sdk/ClientTest.java
Expand Up @@ -12,6 +12,7 @@
import org.junit.jupiter.api.Test;
import org.mockito.MockedConstruction;
import org.mockito.MockedStatic;
import org.mockito.Mockito;

import com.absmartly.sdk.java.nio.charset.StandardCharsets;
import com.absmartly.sdk.json.ContextData;
Expand Down Expand Up @@ -104,15 +105,18 @@ void createWithDefaults() {
client.publish(event);
assertDoesNotThrow(client::close);

verify(httpClient, times(1)).get("https://localhost/v1/context", expectedQuery, null);
verify(httpClient, times(1)).put("https://localhost/v1/context", null, expectedHeaders, publishBytes);
verify(httpClient, times(1)).close();
verify(httpClient, Mockito.timeout(5000).times(1)).get("https://localhost/v1/context", expectedQuery, null);
verify(httpClient, Mockito.timeout(5000).times(1)).put("https://localhost/v1/context", null,
expectedHeaders, publishBytes);
verify(httpClient, Mockito.timeout(5000).times(1)).close();

verify(deserCtor.constructed().get(0), times(1)).deserialize(any(), anyInt(), anyInt());
verify(deserCtor.constructed().get(0), times(1)).deserialize(dataBytes, 0, dataBytes.length);
verify(deserCtor.constructed().get(0), Mockito.timeout(5000).times(1)).deserialize(any(), anyInt(),
anyInt());
verify(deserCtor.constructed().get(0), Mockito.timeout(5000).times(1)).deserialize(dataBytes, 0,
dataBytes.length);

verify(serCtor.constructed().get(0), times(1)).serialize(any());
verify(serCtor.constructed().get(0), times(1)).serialize(event);
verify(serCtor.constructed().get(0), Mockito.timeout(5000).times(1)).serialize(any());
verify(serCtor.constructed().get(0), Mockito.timeout(5000).times(1)).serialize(event);
}
}

Expand Down Expand Up @@ -194,8 +198,8 @@ void getContextDataExceptionallyHTTP() {
assertTrue(actual.getCause() instanceof Exception);
assertEquals("Internal Server Error", actual.getCause().getMessage());

verify(httpClient, times(1)).get("https://localhost/v1/context", expectedQuery, null);
verify(deser, times(0)).deserialize(any(), anyInt(), anyInt());
verify(httpClient, Mockito.timeout(5000).times(1)).get("https://localhost/v1/context", expectedQuery, null);
verify(deser, Mockito.timeout(5000).times(0)).deserialize(any(), anyInt(), anyInt());
}

@Test
Expand Down Expand Up @@ -223,8 +227,8 @@ void getContextDataExceptionallyConnection() {
final CompletionException actual = assertThrows(CompletionException.class, dataFuture::join);
assertSame(actual.getCause(), failure);

verify(httpClient, times(1)).get("https://localhost/v1/context", expectedQuery, null);
verify(deser, times(0)).deserialize(any(), anyInt(), anyInt());
verify(httpClient, Mockito.timeout(5000).times(1)).get("https://localhost/v1/context", expectedQuery, null);
verify(deser, Mockito.timeout(5000).times(0)).deserialize(any(), anyInt(), anyInt());
}

@Test
Expand Down Expand Up @@ -255,9 +259,10 @@ void publish() {
final CompletableFuture<Void> publishFuture = client.publish(event);
publishFuture.join();

verify(ser, times(1)).serialize(event);
verify(httpClient, times(1)).put(any(), any(), any(), any());
verify(httpClient, times(1)).put("https://localhost/v1/context", null, expectedHeaders, bytes);
verify(ser, Mockito.timeout(5000).times(1)).serialize(event);
verify(httpClient, Mockito.timeout(5000).times(1)).put(any(), any(), any(), any());
verify(httpClient, Mockito.timeout(5000).times(1)).put("https://localhost/v1/context", null, expectedHeaders,
bytes);
}

@Test
Expand Down Expand Up @@ -291,8 +296,9 @@ void publishExceptionallyHTTP() {
assertTrue(actual.getCause() instanceof Exception);
assertEquals("Internal Server Error", actual.getCause().getMessage());

verify(ser, times(1)).serialize(event);
verify(httpClient, times(1)).put("https://localhost/v1/context", null, expectedHeaders, bytes);
verify(ser, Mockito.timeout(5000).times(1)).serialize(event);
verify(httpClient, Mockito.timeout(5000).times(1)).put("https://localhost/v1/context", null, expectedHeaders,
bytes);
}

@Test
Expand Down Expand Up @@ -326,7 +332,8 @@ void publishExceptionallyConnection() {
final CompletionException actual = assertThrows(CompletionException.class, publishFuture::join);
assertSame(actual.getCause(), failure);

verify(ser, times(1)).serialize(event);
verify(httpClient, times(1)).put("https://localhost/v1/context", null, expectedHeaders, bytes);
verify(ser, Mockito.timeout(5000).times(1)).serialize(event);
verify(httpClient, Mockito.timeout(5000).times(1)).put("https://localhost/v1/context", null, expectedHeaders,
bytes);
}
}

0 comments on commit 0ac4181

Please sign in to comment.