Skip to content

Commit

Permalink
Bump to version 7.0.0.0 (#67)
Browse files Browse the repository at this point in the history
* Bump to version 7.0.0.0
  • Loading branch information
vitaliy-pavlenko authored Sep 11, 2024
1 parent 0df60fd commit 5b758dc
Show file tree
Hide file tree
Showing 8 changed files with 104 additions and 8 deletions.
10 changes: 8 additions & 2 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ jobs:
path: "**/build/reports/tests"

android-tests:
runs-on: macos-latest
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
Expand All @@ -62,6 +62,12 @@ jobs:
- name: Checkout
uses: actions/checkout@v3

- name: Enable KVM group perms
run: |
echo 'KERNEL=="kvm", GROUP="kvm", MODE="0666", OPTIONS+="static_node=kvm"' | sudo tee /etc/udev/rules.d/99-kvm4all.rules
sudo udevadm control --reload-rules
sudo udevadm trigger --name-match=kvm
- name: Setup Java 11
uses: actions/setup-java@v3
with:
Expand All @@ -75,7 +81,7 @@ jobs:
target: ${{ matrix.tag }}
arch: ${{ matrix.abi }}
force-avd-creation: false
emulator-options: -no-snapshot-save -noaudio -no-boot-anim -skin 360x640
emulator-options: -no-window -no-snapshot-save -noaudio -no-boot-anim -skin 360x640
disable-animations: true
script: |
adb logcat -c # clear logs
Expand Down
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@ Note that all version `X.Y.Z.T` of this adapter have been tested against the mat

## Next

## Version 7.0.0.0
* Add inventoryGroupId parameter

## Version 6.0.0.0
* Add support of Android 14 (API level 34)

Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ allprojects {
Then, in your app's module *build.gradle* file, add the following implementation configuration to the *dependencies* section:

```kotlin
implementation 'com.criteo.mediation.google:criteo-adapter:6.0.0.0'
implementation 'com.criteo.mediation.google:criteo-adapter:7.0.0.0'
```

# License
Expand Down
4 changes: 1 addition & 3 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,6 @@ allprojects {
repositories {
google()
mavenCentral()
maven { url "https://s3.amazonaws.com/moat-sdk-builds" }
mavenLocal()
maven {
setUrl("https://oss.sonatype.org/content/repositories/snapshots/")
}
Expand All @@ -60,7 +58,7 @@ ext {
* deployed as well with version A.B.C.0. If fixes, or updates are required on the adapter without updating
* the SDK, then the last digit is incremented to produce A.B.C.1, then A.B.C.2, ...
*/
adapter_version = "6.0.0.0"
adapter_version = "7.0.0.0"
isSnapshot = properties["isRelease"] != "true"

def timestamp = new Date().format("yyyyMMdd.HHmm")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@

import static com.criteo.mediation.google.CriteoAdapter.SERVER_PARAMETER_KEY;
import static com.criteo.publisher.CriteoUtil.TEST_CP_ID;
import static com.criteo.publisher.CriteoUtil.TEST_INVENTORY_GROUP_ID;
import static com.criteo.publisher.concurrent.ThreadingUtil.runOnMainThreadAndWait;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.when;
Expand Down Expand Up @@ -138,6 +139,7 @@ private static String getServerParameters(AdUnit adUnit) {
try {
JSONObject serverParams = new JSONObject();
serverParams.put("cpId", TEST_CP_ID);
serverParams.put("inventoryGroupId", TEST_INVENTORY_GROUP_ID);
serverParams.put("adUnitId", adUnit.getAdUnitId());
return serverParams.toString();
} catch (JSONException e) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,13 @@
import static org.mockito.ArgumentMatchers.argThat;
import static org.mockito.Mockito.inOrder;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.never;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;

import com.criteo.publisher.mock.MockedDependenciesRule;
import com.criteo.publisher.model.AdSize;
import com.google.android.gms.ads.AdError;
import com.google.android.gms.ads.mediation.MediationAdLoadCallback;
import com.google.android.gms.ads.mediation.MediationBannerAd;
import com.google.android.gms.ads.mediation.MediationBannerAdCallback;
Expand Down Expand Up @@ -105,6 +107,32 @@ public void requestNativeAd_GivenServerParameterWithoutAdUnit_NotifyForError() t
verify(nativeCallback).onFailure(argThat(new IsEqualToOtherAdError(AdErrorKt.readingServerParameterError())));
}

@Test
public void requestNativeAd_GivenServerParameterWithInventoryGroupIdEqualsNull_NotifyForError() throws Exception {
JSONObject serverParams = new JSONObject();
serverParams.put("cpId", TEST_CP_ID);
serverParams.put("inventoryGroupId", JSONObject.NULL);
serverParams.put("adUnitId", BANNER_320_50.getAdUnitId());
String serverParameter = serverParams.toString();

adapterHelper.loadNativeAd(serverParameter, nativeCallback);

verify(nativeCallback).onFailure(argThat(new IsEqualToOtherAdError(AdErrorKt.noFillError())));
}

@Test
public void requestNativeAd_GivenServerParameterWithInventoryGroupId_NotifyForError() throws Exception {
JSONObject serverParams = new JSONObject();
serverParams.put("cpId", TEST_CP_ID);
serverParams.put("inventoryGroupId", "myInventoryId");
serverParams.put("adUnitId", BANNER_320_50.getAdUnitId());
String serverParameter = serverParams.toString();

adapterHelper.loadNativeAd(serverParameter, nativeCallback);

verify(nativeCallback).onFailure(argThat(new IsEqualToOtherAdError(AdErrorKt.noFillError())));
}

@Test
public void requestBannerAd_GivenEmptyServerParameter_NotifyForInvalidRequest() throws Exception {
String serverParameter = "";
Expand Down Expand Up @@ -136,6 +164,32 @@ public void requestBannerAd_GivenServerParameterWithoutAdUnit_NotifyForError() t
verify(bannerCallback).onFailure(argThat(new IsEqualToOtherAdError(AdErrorKt.readingServerParameterError())));
}

@Test
public void requestBannerAd_GivenServerParameterWithInventoryGroupIdEqualsNull_NotifyForError() throws Exception {
JSONObject serverParams = new JSONObject();
serverParams.put("cpId", TEST_CP_ID);
serverParams.put("inventoryGroupId", JSONObject.NULL);
serverParams.put("adUnitId", BANNER_320_50.getAdUnitId());
String serverParameter = serverParams.toString();

adapterHelper.loadBannerAd(serverParameter, new AdSize(320, 50), bannerCallback);

verify(bannerCallback).onFailure(argThat(new IsEqualToOtherAdError(AdErrorKt.noFillError())));
}

@Test
public void requestBannerAd_GivenServerParameterWithInventoryGroupId_NotifyForError() throws Exception {
JSONObject serverParams = new JSONObject();
serverParams.put("cpId", TEST_CP_ID);
serverParams.put("inventoryGroupId", "myInventoryId");
serverParams.put("adUnitId", BANNER_320_50.getAdUnitId());
String serverParameter = serverParams.toString();

adapterHelper.loadBannerAd(serverParameter, new AdSize(320, 50), bannerCallback);

verify(bannerCallback).onFailure(argThat(new IsEqualToOtherAdError(AdErrorKt.noFillError())));
}

@Test
public void requestInterstitialAd_GivenEmptyServerParameter_NotifyForInvalidRequest() throws Exception {
String serverParameter = "";
Expand Down Expand Up @@ -167,6 +221,32 @@ public void requestInterstitialAd_GivenServerParameterWithoutAdUnit_NotifyForErr
verify(interstitialCallback).onFailure(argThat(new IsEqualToOtherAdError(AdErrorKt.readingServerParameterError())));
}

@Test
public void requestInterstitialAd_GivenServerParameterWithInventoryGroupIdEqualsNull_NotifyForError() throws Exception {
JSONObject serverParams = new JSONObject();
serverParams.put("cpId", TEST_CP_ID);
serverParams.put("inventoryGroupId", JSONObject.NULL);
serverParams.put("adUnitId", BANNER_320_50.getAdUnitId());
String serverParameter = serverParams.toString();

adapterHelper.loadInterstitialAd(serverParameter, interstitialCallback);

verify(interstitialCallback).onFailure(argThat(new IsEqualToOtherAdError(AdErrorKt.noFillError())));
}

@Test
public void requestInterstitialAd_GivenServerParameterWithInventoryGroupId_NotifyForError() throws Exception {
JSONObject serverParams = new JSONObject();
serverParams.put("cpId", TEST_CP_ID);
serverParams.put("inventoryGroupId", "myInventoryId");
serverParams.put("adUnitId", BANNER_320_50.getAdUnitId());
String serverParameter = serverParams.toString();

adapterHelper.loadInterstitialAd(serverParameter, interstitialCallback);

verify(interstitialCallback).onFailure(argThat(new IsEqualToOtherAdError(AdErrorKt.noFillError())));
}

@Test
public void givenNotInitializedCriteo_WhenLoadingNativeTwice_MissFirstOpportunityBecauseOfBidCachingAndSucceedOnNextOne()
throws Exception {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ import com.google.android.gms.ads.nativead.NativeAd
import com.google.android.gms.ads.nativead.NativeAdView
import org.assertj.core.api.Assertions.assertThat
import org.junit.Before
import org.junit.Ignore
import org.junit.Rule
import org.junit.Test
import org.mockito.AdditionalAnswers.delegatesTo
Expand Down Expand Up @@ -123,7 +124,8 @@ class CriteoNativeAdapterTest {
.build())
}

@Test
// @todo: enable when update google mobile ads sdk
@Ignore @Test
fun loadNativeAd_GivenValidBid_RenderAllNativePayload() {
val expectedAssets = StubConstants.STUB_NATIVE_ASSETS
val expectedProduct = expectedAssets.product
Expand Down Expand Up @@ -190,7 +192,8 @@ class CriteoNativeAdapterTest {
}
}

@Test
// @todo: enable when update google mobile ads sdk
@Ignore @Test
fun loadNativeAd_GivenInvalidBid_NotifyAdMobForFailure() {
val adUnit = TestAdUnits.NATIVE_UNKNOWN
lateinit var nativeAd: NativeAd
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -164,10 +164,12 @@ class CriteoAdapter : Adapter() {
}

val criteoPublisherId: String
val inventoryGroupId: String?
val adUnitId: String
try {
val parameters = JSONObject(serverParameter)
criteoPublisherId = parameters.getString(CRITEO_PUBLISHER_ID)
inventoryGroupId = parameters.optString(INVENTORY_GROUP_ID) ?: null
adUnitId = parameters.getString(AD_UNIT_ID)
} catch (e: JSONException) {
val error = readingServerParameterError()
Expand All @@ -192,6 +194,7 @@ class CriteoAdapter : Adapter() {
)
// TODO: move AdUnit creation to separate loaders when prefetch feature is removed
.adUnits(listOf(adUnit))
.inventoryGroupId(inventoryGroupId)
.tagForChildDirectedTreatment(tagForChildDirectedTreatment)
.init()
} catch (e: CriteoInitException) {
Expand Down Expand Up @@ -244,6 +247,7 @@ class CriteoAdapter : Adapter() {
internal val DEFAULT_VERSION_INFO = VersionInfo(0, 0, 0)

private const val CRITEO_PUBLISHER_ID = "cpId"
private const val INVENTORY_GROUP_ID = "inventoryGroupId"
private const val AD_UNIT_ID = "adUnitId"
}

Expand Down

0 comments on commit 5b758dc

Please sign in to comment.