Search in sources :

Example 16 with ClientConfig

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

the class TargetTestDeliveryRequestUtils method getTestRuleLoader.

public static RuleLoader getTestRuleLoader(final String ruleSet) {
    return new RuleLoader() {

        @Override
        public void start(ClientConfig clientConfig, TelemetryService telemetryService) {
        }

        @Override
        public void stop() {
        }

        @Override
        public void refresh() {
        }

        @Override
        public OnDeviceDecisioningRuleSet getLatestRules() {
            if (ruleSet == null) {
                return null;
            }
            ObjectMapper mapper = new ObjectMapper();
            mapper.setSerializationInclusion(JsonInclude.Include.NON_NULL);
            mapper.configure(JsonGenerator.Feature.IGNORE_UNKNOWN, true);
            mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
            mapper.configure(DeserializationFeature.READ_ENUMS_USING_TO_STRING, true);
            try {
                return mapper.readValue(ruleSet, new TypeReference<OnDeviceDecisioningRuleSet>() {
                });
            } catch (IOException e) {
                throw new RuntimeException(e);
            }
        }

        @Override
        public long getPollingInterval() {
            return 0;
        }

        @Override
        public int getNumFetches() {
            return 0;
        }

        @Override
        public Date getLastFetch() {
            return null;
        }

        @Override
        public String getLocation() {
            return null;
        }
    };
}
Also used : RuleLoader(com.adobe.target.edge.client.ondevice.RuleLoader) TelemetryService(com.adobe.target.edge.client.service.TelemetryService) IOException(java.io.IOException) ClientConfig(com.adobe.target.edge.client.ClientConfig) ObjectMapper(com.fasterxml.jackson.databind.ObjectMapper) OnDeviceDecisioningRuleSet(com.adobe.target.edge.client.model.ondevice.OnDeviceDecisioningRuleSet)

Example 17 with ClientConfig

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

the class TargetDeliveryLocalGeoTest 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().client("adobesummit2018").organizationId("org").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);
    FieldSetter.setField(localService, localService.getClass().getDeclaredField("notificationService"), mock(NotificationService.class));
    FieldSetter.setField(localService, localService.getClass().getDeclaredField("clusterLocator"), mock(ClusterLocator.class));
    fileRuleLoader(GEO_TEST_FILE, localService);
    Geo geoResult = new Geo().city("san francisco").stateCode("ca").countryCode("us").latitude(37.74f).longitude(-122.24f);
    mockGeoClient = Mockito.spy(new GeoClient() {

        @Override
        public void start(ClientConfig clientConfig) {
        }

        @Override
        public Geo lookupGeo(String ip) {
            return geoResult;
        }

        @Override
        public void close() {
        }
    });
    FieldSetter.setField(localService, localService.getClass().getDeclaredField("geoClient"), mockGeoClient);
}
Also used : DefaultTargetService(com.adobe.target.edge.client.service.DefaultTargetService) GeoClient(com.adobe.target.edge.client.ondevice.client.geo.GeoClient) 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 18 with ClientConfig

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

the class TargetDeliveryRequestLocalMboxTest 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

ClientConfig (com.adobe.target.edge.client.ClientConfig)18 TelemetryService (com.adobe.target.edge.client.service.TelemetryService)9 Test (org.junit.jupiter.api.Test)9 TargetDeliveryRequest (com.adobe.target.edge.client.model.TargetDeliveryRequest)8 DefaultTargetService (com.adobe.target.edge.client.service.DefaultTargetService)8 BeforeEach (org.junit.jupiter.api.BeforeEach)7 OnDeviceDecisioningService (com.adobe.target.edge.client.ondevice.OnDeviceDecisioningService)6 ObjectMapper (com.fasterxml.jackson.databind.ObjectMapper)6 JacksonObjectMapper (com.adobe.target.edge.client.http.JacksonObjectMapper)5 ClusterLocator (com.adobe.target.edge.client.ondevice.ClusterLocator)5 OnDeviceDecisioningDetailsExecutor (com.adobe.target.edge.client.ondevice.OnDeviceDecisioningDetailsExecutor)5 NotificationService (com.adobe.target.edge.client.service.NotificationService)5 Map (java.util.Map)5 UnirestInstance (kong.unirest.UnirestInstance)5 DeliveryRequest (com.adobe.target.delivery.v1.model.DeliveryRequest)3 OnDeviceDecisioningRuleSet (com.adobe.target.edge.client.model.ondevice.OnDeviceDecisioningRuleSet)3 ParamsCollator (com.adobe.target.edge.client.ondevice.collator.ParamsCollator)3 Proxy (kong.unirest.Proxy)3 ClientProxyConfig (com.adobe.target.edge.client.ClientProxyConfig)2 TargetClientException (com.adobe.target.edge.client.exception.TargetClientException)2