Skip to content

Commit

Permalink
release: SDK 1.21.1
Browse files Browse the repository at this point in the history
  • Loading branch information
arnaud-roland committed Jan 16, 2024
1 parent 20db236 commit a5468fb
Show file tree
Hide file tree
Showing 6 changed files with 9,867 additions and 93 deletions.
2 changes: 1 addition & 1 deletion Sources/buildSrc/src/main/java/Consts.kt
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ object ProjectConsts {
}

object SDKConsts {
const val VERSION = "1.21.0"
const val VERSION = "1.21.1"
const val API_LEVEL = 70
const val MESSAGING_API_LEVEL = 12

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,7 @@
import com.batch.android.json.JSONException;
import com.batch.android.json.JSONObject;
import com.batch.android.post.PostDataProvider;
import com.batch.android.processor.Module;
import com.batch.android.processor.Provide;
import com.batch.android.processor.Singleton;
import com.batch.android.webservice.listener.InboxWebserviceListener;
import java.net.MalformedURLException;
import java.util.Date;
Expand All @@ -29,8 +27,6 @@
* Webservice client for the Inbox API
* Used to fetch notifications from the server
*/
@Module
@Singleton
public class InboxFetchWebserviceClient extends BatchWebservice implements TaskRunnable {

private static final String TAG = "InboxFetchWebserviceClient";
Expand All @@ -41,7 +37,7 @@ public class InboxFetchWebserviceClient extends BatchWebservice implements TaskR
private final String authentication;

@NonNull
private InboxWebserviceListener listener;
private final InboxWebserviceListener listener;

public InboxFetchWebserviceClient(
@NonNull Context context,
Expand All @@ -67,29 +63,6 @@ public InboxFetchWebserviceClient(
}
}

@Provide
public static InboxFetchWebserviceClient provide(
@NonNull Context context,
@NonNull FetcherType type,
@NonNull String identifier,
@Nullable String authentication,
@Nullable Integer limit,
@Nullable String from,
long fetcherId,
@NonNull InboxWebserviceListener listener
) throws MalformedURLException {
return new InboxFetchWebserviceClient(
context,
type,
identifier,
authentication,
limit,
from,
fetcherId,
listener
);
}

@Override
protected Map<String, String> getHeaders() {
if (authentication != null) {
Expand Down Expand Up @@ -274,8 +247,4 @@ protected String getSpecificReadTimeoutKey() {
protected String getSpecificRetryCountKey() {
return ParameterKeys.INBOX_WS_RETRYCOUNT_KEY;
}

public void setListener(@NonNull InboxWebserviceListener listener) {
this.listener = listener;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,13 @@
import android.text.TextUtils;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.annotation.VisibleForTesting;
import com.batch.android.BatchInboxFetcher;
import com.batch.android.BatchInboxNotificationContent;
import com.batch.android.PrivateNotificationContentHelper;
import com.batch.android.core.Logger;
import com.batch.android.core.NamedThreadFactory;
import com.batch.android.di.providers.InboxDatasourceProvider;
import com.batch.android.di.providers.InboxFetchWebserviceClientProvider;
import com.batch.android.di.providers.InboxFetcherInternalProvider;
import com.batch.android.di.providers.RuntimeManagerProvider;
import com.batch.android.di.providers.TrackerModuleProvider;
Expand Down Expand Up @@ -94,20 +94,6 @@ public static InboxFetcherInternal provide(@NonNull Context context, String inst
);
}

@Provide
public static InboxFetcherInternal provide(
@NonNull Context context,
String installID,
@NonNull InboxFetchWebserviceClient client
) {
return new InboxFetcherInternal(
TrackerModuleProvider.get(),
InboxDatasourceProvider.get(context),
context,
installID
);
}

/**
* Init fetcher without using cache
* Internal use only
Expand Down Expand Up @@ -412,25 +398,30 @@ private void fetch(@Nullable final String cursor, @NonNull final InboxWebservice

try {
// No need for the TaskExecutor, run the WS directly on this thread since it has to work serially
InboxFetchWebserviceClient fetchWSClient = InboxFetchWebserviceClientProvider.get(
c,
fetcherType,
identifier,
authKey,
maxPageSize,
cursor,
fetcherId,
wsClientListener
runFetchWSClient(
new InboxFetchWebserviceClient(
c,
fetcherType,
identifier,
authKey,
maxPageSize,
cursor,
fetcherId,
wsClientListener
)
);
fetchWSClient.setListener(wsClientListener);
fetchWSClient.run();
} catch (MalformedURLException e) {
Logger.internal(TAG, "Could not start inbox fetcher ws: ", e);
wsClientListener.onFailure("Internal network call error");
}
});
}

@VisibleForTesting
protected void runFetchWSClient(InboxFetchWebserviceClient client) {
client.run();
}

private boolean sync(@Nullable final String cursor, final InboxWebserviceListener wsClientListener) {
if (datasource != null && fetcherId != -1) {
List<InboxCandidateNotificationInternal> candidates = datasource.getCandidateNotifications(
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package com.batch.android.inbox;

import static android.os.Looper.getMainLooper;
import static com.batch.android.inbox.FetcherType.INSTALLATION;
import static org.mockito.Mockito.spy;
import static org.robolectric.Shadows.shadowOf;

import android.content.Context;
Expand All @@ -11,22 +11,20 @@
import androidx.test.filters.SmallTest;
import com.batch.android.BatchInboxFetcher;
import com.batch.android.BatchInboxNotificationContent;
import com.batch.android.di.DI;
import com.batch.android.di.DITest;
import com.batch.android.di.DITestUtils;
import com.batch.android.di.providers.InboxFetcherInternalProvider;
import com.batch.android.json.JSONObject;
import com.batch.android.webservice.listener.InboxWebserviceListener;
import java.util.List;
import java.util.concurrent.CountDownLatch;
import org.junit.Assert;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.mockito.Mockito;
import org.powermock.api.mockito.PowerMockito;

@RunWith(AndroidJUnit4.class)
@SmallTest
public class InboxFetcherInternalTest extends DITest {
public class InboxFetcherInternalTest {

private Context appContext;
private final String payload =
Expand All @@ -35,39 +33,23 @@ public class InboxFetcherInternalTest extends DITest {

@Before
public void setUp() {
super.setUp();
appContext = ApplicationProvider.getApplicationContext();
latch = new CountDownLatch(1);
}

@Test
public void testFetchNewNotifications() throws Exception {
InboxFetchWebserviceClient client = PowerMockito.spy(
new InboxFetchWebserviceClient(
appContext,
INSTALLATION,
"mock-id",
"test-auth",
20,
null,
-1,
new InboxWebserviceListener() {
@Override
public void onSuccess(InboxWebserviceResponse result) {}

@Override
public void onFailure(@NonNull String error) {}
}
)
);
PowerMockito.doReturn(new JSONObject(payload)).when(client, "getBasicJsonResponseBody");
DI.getInstance().addSingletonInstance(InboxFetchWebserviceClient.class, client);
InboxFetcherInternal fetcher = DITestUtils.mockSingletonDependency(
InboxFetcherInternal.class,
new Class[] { Context.class, String.class },
appContext,
"test-install-id"
);
InboxFetcherInternal fetcher = spy(InboxFetcherInternalProvider.get(appContext, "test-install-id"));
Mockito
.doAnswer(invocation -> {
InboxFetchWebserviceClient client = invocation.getArgument(0);
InboxFetchWebserviceClient spy = PowerMockito.spy(client);
PowerMockito.doReturn(new JSONObject(payload)).when(spy, "getBasicJsonResponseBody");
spy.run();
return spy;
})
.when(fetcher)
.runFetchWSClient(Mockito.any());
fetcher.fetchNewNotifications(
new BatchInboxFetcher.OnNewNotificationsFetchedListener() {
@Override
Expand All @@ -85,7 +67,6 @@ public void onFetchSuccess(
@Override
public void onFetchFailure(@NonNull String error) {
latch.countDown();
Assert.fail();
}
}
);
Expand Down
1 change: 1 addition & 0 deletions proguard-mappings/1.21.1/checksum.sha
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
261387d6e90dc20a2626dbcbfe4de528470697b7 public-sdk/Batch.aar
Loading

0 comments on commit a5468fb

Please sign in to comment.