Skip to content

Commit

Permalink
Mobile 928 (#640)
Browse files Browse the repository at this point in the history
* [MOBILE-928] Allow disabling airship channel

* Clean up unit test
  • Loading branch information
rlepinski authored Dec 18, 2019
1 parent c3c3d1d commit 3510492
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,9 @@ static Collection<? extends AirshipComponent> findAirshipComponents(@NonNull Str

case Modules.NAMED_USER_MODULE:
return Collections.singletonList(UAirship.shared().getNamedUser());

case Modules.CHANNEL_MODULE:
return Collections.singletonList(UAirship.shared().getChannel());
}

Logger.verbose("ModuleAdapter - Unknown module: %s", module);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,12 @@ interface Modules {
*/
String LOCATION_MODULE = "location";

List<String> ALL_MODULES = Arrays.asList(PUSH_MODULE, ANALYTICS_MODULE,
MESSAGE_CENTER, IN_APP_MODULE, AUTOMATION_MODULE, NAMED_USER_MODULE, LOCATION_MODULE);
/**
* Channel module
*/
String CHANNEL_MODULE = "channel";

List<String> ALL_MODULES = Arrays.asList(PUSH_MODULE, ANALYTICS_MODULE, MESSAGE_CENTER,
IN_APP_MODULE, AUTOMATION_MODULE, NAMED_USER_MODULE, LOCATION_MODULE, CHANNEL_MODULE);

}
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ protected void init() {
@Override
public JsonMap apply(@NonNull Collection<RemoteDataPayload> remoteDataPayloads) {
// sort the payloads, common first followed by platform-specific
List<RemoteDataPayload> remoteDataPayloadList = new ArrayList<RemoteDataPayload>(remoteDataPayloads);
List<RemoteDataPayload> remoteDataPayloadList = new ArrayList<>(remoteDataPayloads);
Collections.sort(remoteDataPayloadList, COMPARE_BY_PAYLOAD_TYPE);

// combine the payloads, overwriting common config with platform-specific config
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -94,25 +94,25 @@ public void testRemoteDataForegroundRefreshInterval() {

@Test
public void testRemoteConfig() {
JsonMap module_one_config_common = JsonMap.newBuilder()
JsonMap fooConfig = JsonMap.newBuilder()
.put("some_config_name", "some_config_value")
.build();

JsonMap module_two_config_common = JsonMap.newBuilder()
JsonMap barConfig = JsonMap.newBuilder()
.put("some_other_config_name", "some_other_config_value")
.build();

JsonMap commonData = JsonMap.newBuilder()
.put("module_one", module_one_config_common)
.put("module_two", module_two_config_common)
.put("foo", fooConfig)
.put("bar", barConfig)
.build();

JsonMap module_one_config_platform_specific = JsonMap.newBuilder()
JsonMap androidFooOverrideConfig = JsonMap.newBuilder()
.put("some_other_config_name", "some_other_config_value")
.build();

JsonMap androidData = JsonMap.newBuilder()
.put("module_one", module_one_config_platform_specific)
.put("foo", androidFooOverrideConfig)
.build();

RemoteDataPayload common = createRemoteDataPayload("app_config", System.currentTimeMillis(), commonData);
Expand All @@ -125,9 +125,9 @@ public void testRemoteConfig() {

assertEquals((2 + Modules.ALL_MODULES.size()), config.size());

assertEquals(module_one_config_platform_specific, config.get("module_one"));
assertEquals(androidFooOverrideConfig, config.get("foo"));

assertEquals(module_two_config_common, config.get("module_two"));
assertEquals(barConfig, config.get("bar"));

// All modules without config payloads should be called with a null config
for (String module : Modules.ALL_MODULES) {
Expand Down

0 comments on commit 3510492

Please sign in to comment.