Search in sources :

Example 1 with OnDeviceDecisioningEvaluator

use of com.adobe.target.edge.client.ondevice.OnDeviceDecisioningEvaluator in project target-java-sdk by adobe.

the class TargetDeliveryAttributesTest method init.

@BeforeEach
@SuppressWarnings("unchecked")
void init() throws IOException, NoSuchFieldException {
    Mockito.lenient().doReturn(CompletableFuture.completedFuture(getTestDeliveryResponse())).when(defaultTargetHttpClient).executeAsync(any(Map.class), any(String.class), any(DeliveryRequest.class), any(Class.class));
    ClientConfig clientConfig = ClientConfig.builder().client("emeaprod4").organizationId(TEST_ORG_ID).build();
    VisitorProvider.init(TEST_ORG_ID);
    TelemetryService telemetryService = new TelemetryService(clientConfig);
    DefaultTargetService targetService = new DefaultTargetService(clientConfig, telemetryService);
    localService = new OnDeviceDecisioningService(clientConfig, targetService, telemetryService);
    targetJavaClient = TargetClient.create(clientConfig);
    FieldSetter.setField(targetService, targetService.getClass().getDeclaredField("targetHttpClient"), defaultTargetHttpClient);
    FieldSetter.setField(targetJavaClient, targetJavaClient.getClass().getDeclaredField("targetService"), targetService);
    FieldSetter.setField(targetJavaClient, targetJavaClient.getClass().getDeclaredField("localService"), localService);
    RuleLoader testRuleLoader = TargetTestDeliveryRequestUtils.getTestRuleLoaderFromFile("DECISIONING_PAYLOAD_ATTRIBUTES.json");
    OnDeviceDecisioningEvaluator evaluator = new OnDeviceDecisioningEvaluator(testRuleLoader);
    FieldSetter.setField(localService, localService.getClass().getDeclaredField("ruleLoader"), testRuleLoader);
    FieldSetter.setField(localService, localService.getClass().getDeclaredField("onDeviceDecisioningEvaluator"), evaluator);
    FieldSetter.setField(localService, localService.getClass().getDeclaredField("notificationService"), mock(NotificationService.class));
    FieldSetter.setField(localService, localService.getClass().getDeclaredField("clusterLocator"), mock(ClusterLocator.class));
    ObjectMapper mapper = new JacksonObjectMapper().getMapper();
    OnDeviceDecisioningDetailsExecutor decisionHandler = new OnDeviceDecisioningDetailsExecutor(clientConfig, mapper);
    FieldSetter.setField(localService, localService.getClass().getDeclaredField("decisionHandler"), decisionHandler);
    ParamsCollator specificTimeCollator = TargetTestDeliveryRequestUtils.getSpecificTimeCollator(1582818503000L);
    FieldSetter.setField(localService, localService.getClass().getDeclaredField("timeParamsCollator"), specificTimeCollator);
}
Also used : DefaultTargetService(com.adobe.target.edge.client.service.DefaultTargetService) ParamsCollator(com.adobe.target.edge.client.ondevice.collator.ParamsCollator) TargetDeliveryRequest(com.adobe.target.edge.client.model.TargetDeliveryRequest) TelemetryService(com.adobe.target.edge.client.service.TelemetryService) JacksonObjectMapper(com.adobe.target.edge.client.http.JacksonObjectMapper) OnDeviceDecisioningEvaluator(com.adobe.target.edge.client.ondevice.OnDeviceDecisioningEvaluator) OnDeviceDecisioningDetailsExecutor(com.adobe.target.edge.client.ondevice.OnDeviceDecisioningDetailsExecutor) NotificationService(com.adobe.target.edge.client.service.NotificationService) OnDeviceDecisioningService(com.adobe.target.edge.client.ondevice.OnDeviceDecisioningService) ClusterLocator(com.adobe.target.edge.client.ondevice.ClusterLocator) RuleLoader(com.adobe.target.edge.client.ondevice.RuleLoader) ClientConfig(com.adobe.target.edge.client.ClientConfig) Map(java.util.Map) JacksonObjectMapper(com.adobe.target.edge.client.http.JacksonObjectMapper) ObjectMapper(com.fasterxml.jackson.databind.ObjectMapper) BeforeEach(org.junit.jupiter.api.BeforeEach)

Example 2 with OnDeviceDecisioningEvaluator

use of com.adobe.target.edge.client.ondevice.OnDeviceDecisioningEvaluator in project target-java-sdk by adobe.

the class TargetTestDeliveryRequestUtils method fileRuleLoader.

public static void fileRuleLoader(String fileName, OnDeviceDecisioningService localService) throws IOException, NoSuchFieldException {
    RuleLoader testRuleLoader = TargetTestDeliveryRequestUtils.getTestRuleLoaderFromFile(fileName);
    OnDeviceDecisioningEvaluator evaluator = new OnDeviceDecisioningEvaluator(testRuleLoader);
    FieldSetter.setField(localService, localService.getClass().getDeclaredField("ruleLoader"), testRuleLoader);
    FieldSetter.setField(localService, localService.getClass().getDeclaredField("onDeviceDecisioningEvaluator"), evaluator);
}
Also used : RuleLoader(com.adobe.target.edge.client.ondevice.RuleLoader) OnDeviceDecisioningEvaluator(com.adobe.target.edge.client.ondevice.OnDeviceDecisioningEvaluator)

Aggregations

OnDeviceDecisioningEvaluator (com.adobe.target.edge.client.ondevice.OnDeviceDecisioningEvaluator)2 RuleLoader (com.adobe.target.edge.client.ondevice.RuleLoader)2 ClientConfig (com.adobe.target.edge.client.ClientConfig)1 JacksonObjectMapper (com.adobe.target.edge.client.http.JacksonObjectMapper)1 TargetDeliveryRequest (com.adobe.target.edge.client.model.TargetDeliveryRequest)1 ClusterLocator (com.adobe.target.edge.client.ondevice.ClusterLocator)1 OnDeviceDecisioningDetailsExecutor (com.adobe.target.edge.client.ondevice.OnDeviceDecisioningDetailsExecutor)1 OnDeviceDecisioningService (com.adobe.target.edge.client.ondevice.OnDeviceDecisioningService)1 ParamsCollator (com.adobe.target.edge.client.ondevice.collator.ParamsCollator)1 DefaultTargetService (com.adobe.target.edge.client.service.DefaultTargetService)1 NotificationService (com.adobe.target.edge.client.service.NotificationService)1 TelemetryService (com.adobe.target.edge.client.service.TelemetryService)1 ObjectMapper (com.fasterxml.jackson.databind.ObjectMapper)1 Map (java.util.Map)1 BeforeEach (org.junit.jupiter.api.BeforeEach)1