HaloManagerApi extends HaloPluginApi { @Keep @NonNull @Api(2.0) @CheckResult(suggest = "You may want to call asContent() or asRaw() to get the information") public HaloSelectorFactory<List<HaloModule>, Cursor> getModules(@Data.Policy int dataMode, @NonNull HaloModuleQuery moduleQuery) { return new HaloSelectorFactory<>( halo(), new RequestModulesInteractor(mModulesRepository, moduleQuery), new Cursor2ModulesConverter(), null, dataMode, "Get modules request" ); } private  HaloManagerApi(@NonNull Halo halo); static HaloManagerApi with(Halo halo); @Keep @Api(2.0) @NonNull HaloStorageApi storage(); @Keep @NonNull @Api(2.0) @CheckResult(suggest = "You may want to call asContent() or asRaw() to get the information") HaloSelectorFactory<List<HaloModule>, Cursor> getModules(@Data.Policy int dataMode, @NonNull HaloModuleQuery moduleQuery); @Keep @NonNull @Api(2.3) ICancellable printModulesMetaData(); @Keep @Api(2.0) @NonNull @CheckResult(suggest = "You may want to call execute() to run the task") HaloInteractorExecutor<HaloServerVersion> getServerVersion(); @Keep @Api(2.0) @NonNull @CheckResult(suggest = "You may want to call execute() to run the task") HaloInteractorExecutor<Token> requestToken(@NonNull Credentials credentials); @Keep @Api(1.3) boolean isAppAuthentication(); @Keep @Api(1.3) boolean isPasswordAuthentication(); @Keep @Api(2.0) @NonNull @CheckResult(suggest = "You may want to call execute() to run the task") HaloInteractorExecutor<Device> syncDevice(); @Keep @Api(2.0) void syncDeviceWhenNetworkAvailable(@Threading.Policy final int threading); @Keep @NonNull @Api(2.0) @CheckResult(suggest = "Subscription.unsubscribe() to avoid memory leaks") ISubscription subscribeForDeviceSync(@NonNull Subscriber subscriber); @Keep @Api(2.0) @NonNull @CheckResult(suggest = "You may want to call execute() to run the task") HaloInteractorExecutor<Device> sendDevice(); @Keep @Api(2.0) @NonNull @CheckResult(suggest = "You may want to call execute() to run the task") HaloInteractorExecutor<Device> setNotificationsToken(@Nullable String notificationToken); @Keep @Api(2.0) @NonNull @CheckResult(suggest = "You may want to call execute() to run the task") HaloInteractorExecutor<Device> fetchCurrentDevice(); @Keep @Api(2.0) @NonNull @CheckResult(suggest = "You may want to call execute() to run the task") HaloInteractorExecutor<Device> addDeviceTag(@Nullable HaloSegmentationTag tag, boolean shouldSendDevice); @Keep @Api(2.33) @NonNull @CheckResult(suggest = "You may want to call execute() to run the task") HaloInteractorExecutor<Device> addDeviceTag(@Nullable HaloSegmentationTag tag, boolean shouldSendDevice, boolean shouldOverrideTags); @Keep @Api(2.0) @NonNull @CheckResult(suggest = "You may want to call execute() to run the task") HaloInteractorExecutor<Device> addDeviceTags(@Nullable List<HaloSegmentationTag> segmentationTags, boolean shouldSendDevice); @Keep @Api(2.33) @NonNull @CheckResult(suggest = "You may want to call execute() to run the task") HaloInteractorExecutor<Device> addDeviceTags(@Nullable List<HaloSegmentationTag> segmentationTags, boolean shouldSendDevice, boolean shouldOverrideTags); @Keep @Api(2.0) @NonNull @CheckResult(suggest = "You may want to call execute() to run the task") HaloInteractorExecutor<Device> removeDeviceTag(@Nullable String tagName, boolean shouldSendDevice); @Keep @Api(2.0) @NonNull @CheckResult(suggest = "You may want to call execute() to run the task") HaloInteractorExecutor<Device> removeDeviceTags(@Nullable List<String> tagNames, boolean shouldSendDevice); @Keep @Api(2.0) @Nullable Device getDevice(); @Keep @Api(2.3) @Nullable String getAppId(); @Keep @Api(2.33) @NonNull @CheckResult(suggest = "You may want to call execute() to run the task") HaloInteractorExecutor<HaloEvent> sendEvent(@NonNull HaloEvent haloEvent); static final EventId DEVICE_UPDATE_EVENT_ID; }
@Test public void thatGetModulesAsContentNetwork() throws IOException { enqueueServerFile(mMockServer, GET_MODULES); CallbackV2<List<HaloModule>> callback = givenCallbackWithGetModules(mCallbackFlag, true); HaloModuleQuery haloModuleQuery = HaloModuleQuery.builder() .serverCache(2 * 60) .withFields(false) .build(); ICancellable cancellable = mHalo.getCore().manager() .getModules(Data.NETWORK_ONLY, haloModuleQuery) .asContent() .execute(callback); assertThat(mCallbackFlag.isFlagged()).isTrue(); assertThat(cancellable).isNotNull(); }
@Test public void thatGetModulesNetworkAndStorage() throws IOException { enqueueServerFile(mMockServer, GET_MODULES); CallbackV2<List<HaloModule>> callback = givenCallbackWithGetModules(mCallbackFlag, true); HaloModuleQuery haloModuleQuery = HaloModuleQuery.builder() .serverCache(2 * 60) .withFields(false) .build(); ICancellable cancellable = mHalo.getCore().manager() .getModules(Data.NETWORK_AND_STORAGE, haloModuleQuery) .asContent() .execute(callback); assertThat(mCallbackFlag.isFlagged()).isTrue(); assertThat(cancellable).isNotNull(); }
@Test public void thatGetModulesStorage() throws IOException { CallbackV2<List<HaloModule>> callback = givenCallbackWithGetModules(mCallbackFlag, false); HaloModuleQuery haloModuleQuery = HaloModuleQuery.builder() .serverCache(2 * 60) .withFields(false) .build(); ICancellable cancellable = mHalo.getCore().manager() .getModules(Data.STORAGE_ONLY, haloModuleQuery) .asContent() .execute(callback); assertThat(mCallbackFlag.isFlagged()).isTrue(); assertThat(cancellable).isNotNull(); }
@Test public void thatGetModulesAsRawNetwork() throws IOException { enqueueServerFile(mMockServer, GET_MODULES); CallbackV2<Cursor> callback = givenCallbackWithGetModulesAsRaw(mCallbackFlag, true); HaloModuleQuery haloModuleQuery = HaloModuleQuery.builder() .serverCache(2 * 60) .withFields(false) .build(); ICancellable cancellable = mHalo.getCore().manager() .getModules(Data.NETWORK_AND_STORAGE, haloModuleQuery) .asRaw() .execute(callback); assertThat(mCallbackFlag.isFlagged()).isTrue(); assertThat(cancellable).isNotNull(); }
@Test public void thatGetModulesAsRawNetworkAndStorage() throws IOException { enqueueServerFile(mMockServer, GET_MODULES); CallbackV2<Cursor> callback = givenCallbackWithGetModulesAsRaw(mCallbackFlag, true); HaloModuleQuery haloModuleQuery = HaloModuleQuery.builder() .serverCache(2 * 60) .withFields(false) .build(); ICancellable cancellable = mHalo.getCore().manager() .getModules(Data.NETWORK_AND_STORAGE, haloModuleQuery) .asRaw() .execute(callback); assertThat(mCallbackFlag.isFlagged()).isTrue(); assertThat(cancellable).isNotNull(); }
@Test public void thatGetModulesAsRawStorage() throws IOException { CallbackV2<Cursor> callback = givenCallbackWithGetModulesAsRaw(mCallbackFlag, false); HaloModuleQuery haloModuleQuery = HaloModuleQuery.builder() .serverCache(2 * 60) .withFields(false) .build(); ICancellable cancellable = mHalo.getCore().manager() .getModules(Data.STORAGE_ONLY, haloModuleQuery) .asRaw() .execute(callback); assertThat(mCallbackFlag.isFlagged()).isTrue(); assertThat(cancellable).isNotNull(); }