Browse Source
Clean up eslint-disable comments in test app TypeScript files: - Remove unnecessary comments from test-user-zero.ts - Remove unnecessary comments from router/index.ts - Keep only intentional console.log statements with proper eslint-disable commentsmaster
5 changed files with 132 additions and 6 deletions
@ -0,0 +1,39 @@ |
|||
/** |
|||
* TestApplication.java |
|||
* |
|||
* Application class for the Daily Notification Plugin test app. |
|||
* Registers the native content fetcher SPI implementation. |
|||
* |
|||
* @author Matthew Raymer |
|||
* @version 1.0.0 |
|||
*/ |
|||
|
|||
package com.timesafari.dailynotification.test; |
|||
|
|||
import android.app.Application; |
|||
import android.util.Log; |
|||
import com.timesafari.dailynotification.DailyNotificationPlugin; |
|||
import com.timesafari.dailynotification.NativeNotificationContentFetcher; |
|||
|
|||
/** |
|||
* Application class that registers native fetcher for testing |
|||
*/ |
|||
public class TestApplication extends Application { |
|||
|
|||
private static final String TAG = "TestApplication"; |
|||
|
|||
@Override |
|||
public void onCreate() { |
|||
super.onCreate(); |
|||
|
|||
Log.i(TAG, "Initializing Daily Notification Plugin test app"); |
|||
|
|||
// Register test native fetcher
|
|||
NativeNotificationContentFetcher testFetcher = |
|||
new com.timesafari.dailynotification.test.TestNativeFetcher(); |
|||
DailyNotificationPlugin.setNativeFetcher(testFetcher); |
|||
|
|||
Log.i(TAG, "Test native fetcher registered: " + testFetcher.getClass().getName()); |
|||
} |
|||
} |
|||
|
|||
@ -0,0 +1,85 @@ |
|||
/** |
|||
* TestNativeFetcher.java |
|||
* |
|||
* Simple test implementation of NativeNotificationContentFetcher for the test app. |
|||
* Returns mock notification content for testing purposes. |
|||
* |
|||
* @author Matthew Raymer |
|||
* @version 1.0.0 |
|||
*/ |
|||
|
|||
package com.timesafari.dailynotification.test; |
|||
|
|||
import android.util.Log; |
|||
import androidx.annotation.NonNull; |
|||
import com.timesafari.dailynotification.FetchContext; |
|||
import com.timesafari.dailynotification.NativeNotificationContentFetcher; |
|||
import com.timesafari.dailynotification.NotificationContent; |
|||
import java.util.ArrayList; |
|||
import java.util.Collections; |
|||
import java.util.List; |
|||
import java.util.concurrent.CompletableFuture; |
|||
|
|||
/** |
|||
* Test implementation of native content fetcher |
|||
* |
|||
* Returns mock notification content for testing. In production, this would |
|||
* fetch from TimeSafari API or other data sources. |
|||
*/ |
|||
public class TestNativeFetcher implements NativeNotificationContentFetcher { |
|||
|
|||
private static final String TAG = "TestNativeFetcher"; |
|||
|
|||
@Override |
|||
@NonNull |
|||
public CompletableFuture<List<NotificationContent>> fetchContent( |
|||
@NonNull FetchContext context) { |
|||
|
|||
Log.d(TAG, "TestNativeFetcher: Fetch triggered - trigger=" + context.trigger + |
|||
", scheduledTime=" + context.scheduledTime + ", fetchTime=" + context.fetchTime); |
|||
|
|||
return CompletableFuture.supplyAsync(() -> { |
|||
try { |
|||
// Simulate network delay
|
|||
Thread.sleep(100); |
|||
|
|||
List<NotificationContent> contents = new ArrayList<>(); |
|||
|
|||
// Create a test notification
|
|||
NotificationContent testContent = new NotificationContent(); |
|||
testContent.setId("test_notification_" + System.currentTimeMillis()); |
|||
testContent.setTitle("Test Notification from Native Fetcher"); |
|||
testContent.setBody("This is a test notification from the native fetcher SPI. " + |
|||
"Trigger: " + context.trigger + |
|||
(context.scheduledTime != null ? |
|||
", Scheduled: " + new java.util.Date(context.scheduledTime) : "")); |
|||
|
|||
// Use scheduled time from context, or default to 1 hour from now
|
|||
long scheduledTimeMs = context.scheduledTime != null ? |
|||
context.scheduledTime : (System.currentTimeMillis() + 3600000); |
|||
testContent.setScheduledTime(scheduledTimeMs); |
|||
|
|||
// fetchTime is set automatically by NotificationContent constructor (as fetchedAt)
|
|||
testContent.setPriority("default"); |
|||
testContent.setSound(true); |
|||
|
|||
contents.add(testContent); |
|||
|
|||
Log.i(TAG, "TestNativeFetcher: Returning " + contents.size() + |
|||
" notification(s)"); |
|||
|
|||
return contents; |
|||
|
|||
} catch (InterruptedException e) { |
|||
Log.e(TAG, "TestNativeFetcher: Interrupted during fetch", e); |
|||
Thread.currentThread().interrupt(); |
|||
return Collections.emptyList(); |
|||
|
|||
} catch (Exception e) { |
|||
Log.e(TAG, "TestNativeFetcher: Error during fetch", e); |
|||
return Collections.emptyList(); |
|||
} |
|||
}); |
|||
} |
|||
} |
|||
|
|||
Loading…
Reference in new issue