Search in sources :

Example 1 with ClusterLocator

use of com.adobe.target.edge.client.ondevice.ClusterLocator 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 ClusterLocator

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

the class TargetDeliveryLocalPropertyTest method init.

@BeforeEach
@SuppressWarnings("unchecked")
void init() throws IOException, NoSuchFieldException {
    Mockito.lenient().doReturn(getTestDeliveryResponse()).when(defaultTargetHttpClient).execute(any(Map.class), any(String.class), any(DeliveryRequest.class), any(Class.class));
    ClientConfig clientConfig = ClientConfig.builder().organizationId("org").build();
    TelemetryService telemetryService = new TelemetryService(clientConfig);
    DefaultTargetService targetService = new DefaultTargetService(clientConfig, telemetryService);
    OnDeviceDecisioningService localService = new OnDeviceDecisioningService(clientConfig, targetService, telemetryService);
    ObjectMapper mapper = new JacksonObjectMapper().getMapper();
    OnDeviceDecisioningDetailsExecutor decisionHandler = new OnDeviceDecisioningDetailsExecutor(clientConfig, mapper);
    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);
    FieldSetter.setField(localService, localService.getClass().getDeclaredField("decisionHandler"), decisionHandler);
    FieldSetter.setField(localService, localService.getClass().getDeclaredField("notificationService"), mock(NotificationService.class));
    FieldSetter.setField(localService, localService.getClass().getDeclaredField("clusterLocator"), mock(ClusterLocator.class));
    fileRuleLoader(PROPERTY_TEST_FILE, localService);
}
Also used : DefaultTargetService(com.adobe.target.edge.client.service.DefaultTargetService) TargetDeliveryRequest(com.adobe.target.edge.client.model.TargetDeliveryRequest) TelemetryService(com.adobe.target.edge.client.service.TelemetryService) JacksonObjectMapper(com.adobe.target.edge.client.http.JacksonObjectMapper) 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) 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 3 with ClusterLocator

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

the class NotificationServiceTest method init.

@BeforeEach
@SuppressWarnings("unchecked")
void init() throws NoSuchFieldException {
    Mockito.lenient().doReturn(CompletableFuture.completedFuture(getTestDeliveryResponse())).when(defaultTargetHttpClient).executeAsync(any(Map.class), any(String.class), any(DeliveryRequest.class), any(Class.class));
    clientConfig = ClientConfig.builder().organizationId(TEST_ORG_ID).telemetryEnabled(false).build();
    TelemetryService telemetryService = new TelemetryService(clientConfig);
    targetService = new DefaultTargetService(clientConfig, telemetryService);
    clusterLocator = new ClusterLocator();
    notificationService = new NotificationService(targetService, clientConfig, clusterLocator);
    localService = new OnDeviceDecisioningService(clientConfig, targetService, telemetryService);
    ObjectMapper mapper = new JacksonObjectMapper().getMapper();
    OnDeviceDecisioningDetailsExecutor decisionHandler = new OnDeviceDecisioningDetailsExecutor(clientConfig, mapper);
    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);
    FieldSetter.setField(localService, localService.getClass().getDeclaredField("decisionHandler"), decisionHandler);
    FieldSetter.setField(localService, localService.getClass().getDeclaredField("notificationService"), notificationService);
    FieldSetter.setField(localService, localService.getClass().getDeclaredField("clusterLocator"), mock(ClusterLocator.class));
}
Also used : TargetDeliveryRequest(com.adobe.target.edge.client.model.TargetDeliveryRequest) JacksonObjectMapper(com.adobe.target.edge.client.http.JacksonObjectMapper) OnDeviceDecisioningDetailsExecutor(com.adobe.target.edge.client.ondevice.OnDeviceDecisioningDetailsExecutor) OnDeviceDecisioningService(com.adobe.target.edge.client.ondevice.OnDeviceDecisioningService) ClusterLocator(com.adobe.target.edge.client.ondevice.ClusterLocator) 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 4 with ClusterLocator

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

the class TelemetryServiceTest method setup.

@SuppressWarnings("unchecked")
void setup(boolean telemetryEnabled, DecisioningMethod decisioningMethod, String clientName) throws NoSuchFieldException {
    VisitorProvider.init(TEST_ORG_ID);
    clientConfig = ClientConfig.builder().client(clientName).organizationId(TEST_ORG_ID).defaultDecisioningMethod(decisioningMethod).telemetryEnabled(telemetryEnabled).build();
    telemetryServiceSpy = spy(new TelemetryService(clientConfig));
    DefaultTargetService targetService = new DefaultTargetService(clientConfig, telemetryServiceSpy);
    clusterLocator = new ClusterLocator();
    NotificationService notificationService = new NotificationService(targetService, clientConfig, clusterLocator);
    FieldSetter.setField(targetService, targetService.getClass().getDeclaredField("targetHttpClient"), defaultTargetHttpClient);
    Mockito.lenient().doReturn(CompletableFuture.completedFuture(getTestDeliveryResponse())).when(defaultTargetHttpClient).executeAsync(any(Map.class), any(String.class), any(DeliveryRequest.class), any(Class.class));
    Mockito.lenient().doReturn(getTestDeliveryResponse()).when(defaultTargetHttpClient).execute(any(Map.class), any(String.class), any(DeliveryRequest.class), any(Class.class));
    localService = new OnDeviceDecisioningService(clientConfig, targetService, telemetryServiceSpy);
    ObjectMapper mapper = new JacksonObjectMapper().getMapper();
    OnDeviceDecisioningDetailsExecutor decisionHandler = new OnDeviceDecisioningDetailsExecutor(clientConfig, mapper);
    targetJavaClient = TargetClient.create(clientConfig);
    FieldSetter.setField(targetJavaClient, targetJavaClient.getClass().getDeclaredField("targetService"), targetService);
    FieldSetter.setField(targetJavaClient, targetJavaClient.getClass().getDeclaredField("localService"), localService);
    FieldSetter.setField(localService, localService.getClass().getDeclaredField("decisionHandler"), decisionHandler);
    FieldSetter.setField(localService, localService.getClass().getDeclaredField("notificationService"), notificationService);
    FieldSetter.setField(localService, localService.getClass().getDeclaredField("clusterLocator"), mock(ClusterLocator.class));
}
Also used : TargetDeliveryRequest(com.adobe.target.edge.client.model.TargetDeliveryRequest) DeliveryRequest(com.adobe.target.delivery.v1.model.DeliveryRequest) JacksonObjectMapper(com.adobe.target.edge.client.http.JacksonObjectMapper) OnDeviceDecisioningDetailsExecutor(com.adobe.target.edge.client.ondevice.OnDeviceDecisioningDetailsExecutor) OnDeviceDecisioningService(com.adobe.target.edge.client.ondevice.OnDeviceDecisioningService) ClusterLocator(com.adobe.target.edge.client.ondevice.ClusterLocator) Map(java.util.Map) JacksonObjectMapper(com.adobe.target.edge.client.http.JacksonObjectMapper) ObjectMapper(com.fasterxml.jackson.databind.ObjectMapper)

Example 5 with ClusterLocator

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

the class TargetDeliveryRequestLocalViewTest method init.

@BeforeEach
@SuppressWarnings("unchecked")
void init() throws NoSuchFieldException {
    Mockito.lenient().doReturn(getTestDeliveryResponse()).when(defaultTargetHttpClient).execute(any(Map.class), any(String.class), any(DeliveryRequest.class), any(Class.class));
    ClientConfig clientConfig = ClientConfig.builder().client("emeaprod4").organizationId(TEST_ORG_ID).build();
    TelemetryService telemetryService = new TelemetryService(clientConfig);
    DefaultTargetService targetService = new DefaultTargetService(clientConfig, telemetryService);
    localService = new OnDeviceDecisioningService(clientConfig, targetService, telemetryService);
    ObjectMapper mapper = new JacksonObjectMapper().getMapper();
    OnDeviceDecisioningDetailsExecutor decisionHandler = new OnDeviceDecisioningDetailsExecutor(clientConfig, mapper);
    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);
    FieldSetter.setField(localService, localService.getClass().getDeclaredField("decisionHandler"), decisionHandler);
    ParamsCollator specificTimeCollator = TargetTestDeliveryRequestUtils.getSpecificTimeCollator(1582818503000L);
    FieldSetter.setField(localService, localService.getClass().getDeclaredField("timeParamsCollator"), specificTimeCollator);
    FieldSetter.setField(localService, localService.getClass().getDeclaredField("notificationService"), mock(NotificationService.class));
    FieldSetter.setField(localService, localService.getClass().getDeclaredField("clusterLocator"), mock(ClusterLocator.class));
}
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) 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) ClientConfig(com.adobe.target.edge.client.ClientConfig) JacksonObjectMapper(com.adobe.target.edge.client.http.JacksonObjectMapper) ObjectMapper(com.fasterxml.jackson.databind.ObjectMapper) BeforeEach(org.junit.jupiter.api.BeforeEach)

Aggregations

JacksonObjectMapper (com.adobe.target.edge.client.http.JacksonObjectMapper)7 TargetDeliveryRequest (com.adobe.target.edge.client.model.TargetDeliveryRequest)7 ClusterLocator (com.adobe.target.edge.client.ondevice.ClusterLocator)7 OnDeviceDecisioningDetailsExecutor (com.adobe.target.edge.client.ondevice.OnDeviceDecisioningDetailsExecutor)7 OnDeviceDecisioningService (com.adobe.target.edge.client.ondevice.OnDeviceDecisioningService)7 ObjectMapper (com.fasterxml.jackson.databind.ObjectMapper)7 BeforeEach (org.junit.jupiter.api.BeforeEach)6 ClientConfig (com.adobe.target.edge.client.ClientConfig)5 DefaultTargetService (com.adobe.target.edge.client.service.DefaultTargetService)5 NotificationService (com.adobe.target.edge.client.service.NotificationService)5 TelemetryService (com.adobe.target.edge.client.service.TelemetryService)5 Map (java.util.Map)5 ParamsCollator (com.adobe.target.edge.client.ondevice.collator.ParamsCollator)3 DeliveryRequest (com.adobe.target.delivery.v1.model.DeliveryRequest)1 OnDeviceDecisioningEvaluator (com.adobe.target.edge.client.ondevice.OnDeviceDecisioningEvaluator)1 RuleLoader (com.adobe.target.edge.client.ondevice.RuleLoader)1 GeoClient (com.adobe.target.edge.client.ondevice.client.geo.GeoClient)1