use of com.adobe.target.edge.client.Attributes in project target-java-sdk by adobe.
the class TargetDeliveryAttributesTest method testTargetDeliveryAttributesAllMatches.
@Test
@SuppressWarnings("unchecked")
void testTargetDeliveryAttributesAllMatches() throws IOException, NoSuchFieldException {
String mbox = "allmatches";
ArrayList<String> mboxes = new ArrayList<String>() {
{
add(mbox);
}
};
ClientConfig clientConfig = ClientConfig.builder().client("targettesting").organizationId(TEST_ORG_ID).onDeviceEnvironment("test").defaultDecisioningMethod(DecisioningMethod.ON_DEVICE).onDeviceAllMatchingRulesMboxes(mboxes).build();
TelemetryService telemetryService = new TelemetryService(clientConfig);
DefaultTargetService targetService = new DefaultTargetService(clientConfig, telemetryService);
localService = new OnDeviceDecisioningService(clientConfig, targetService, telemetryService);
fileRuleLoader("DECISIONING_PAYLOAD_ALL_MATCHES.json", localService);
FieldSetter.setField(targetJavaClient, targetJavaClient.getClass().getDeclaredField("localService"), localService);
FieldSetter.setField(targetService, targetService.getClass().getDeclaredField("targetHttpClient"), defaultTargetHttpClient);
FieldSetter.setField(targetJavaClient, targetJavaClient.getClass().getDeclaredField("targetService"), targetService);
Context context = getLocalContext();
PrefetchRequest prefetchRequest = getMboxPrefetchLocalRequest(mbox);
VisitorId visitorId = new VisitorId().tntId("38734fba-262c-4722-b4a3-ac0a93916873");
TargetDeliveryRequest targetDeliveryRequest = TargetDeliveryRequest.builder().context(context).prefetch(prefetchRequest).id(visitorId).decisioningMethod(DecisioningMethod.ON_DEVICE).build();
Attributes attrs = targetJavaClient.getAttributes(targetDeliveryRequest, mbox);
assertNotNull(attrs);
assertNotNull(attrs.getResponse());
assertEquals(200, attrs.getResponse().getStatus());
verify(defaultTargetHttpClient, atMostOnce()).execute(any(Map.class), any(String.class), any(TargetDeliveryRequest.class), any(Class.class));
assertEquals(2, attrs.getInteger(mbox, "allmatches", 0));
assertEquals("a", attrs.getString(mbox, "allmatches1_exp"));
assertEquals("a", attrs.getString(mbox, "allmatches2_exp"));
}
use of com.adobe.target.edge.client.Attributes in project target-java-sdk by adobe.
the class TargetDeliveryAttributesTest method testTargetDeliveryAttributesNoRequest.
@Test
@SuppressWarnings("unchecked")
void testTargetDeliveryAttributesNoRequest() {
Attributes attrs = targetJavaClient.getAttributes(null, "testoffer", "testoffer2");
assertNotNull(attrs);
assertNotNull(attrs.getResponse());
assertEquals(200, attrs.getResponse().getStatus());
verify(defaultTargetHttpClient, atMostOnce()).execute(any(Map.class), any(String.class), any(TargetDeliveryRequest.class), any(Class.class));
assertTrue(attrs.getBoolean("testoffer", "test", false));
assertTrue(attrs.toMboxMap("testoffer").containsKey("experience"));
assertTrue(attrs.toMboxMap("testoffer").containsKey("price"));
assertTrue(attrs.toMboxMap("testoffer2").containsKey("offer"));
}
use of com.adobe.target.edge.client.Attributes in project target-java-sdk by adobe.
the class TargetDeliveryAttributesTest method testTargetDeliveryAttributesPageload.
@Test
void testTargetDeliveryAttributesPageload() {
TargetDeliveryRequest targetDeliveryRequest = localDeliveryRequest("38734fba-262c-4722-b4a3-ac0a93916874");
DeliveryRequest deliveryRequest = targetDeliveryRequest.getDeliveryRequest();
deliveryRequest.getPrefetch().setPageLoad(new RequestDetails());
deliveryRequest.getPrefetch().setMboxes(Collections.emptyList());
deliveryRequest.setExecute(null);
Attributes attrs = targetJavaClient.getAttributes(targetDeliveryRequest);
validateInitialResponse(targetDeliveryRequest, attrs);
assertTrue(attrs.getBoolean("target-global-mbox", "test", false));
assertEquals("a", attrs.getString("target-global-mbox", "experience"));
assertEquals(12.99, attrs.getDouble("target-global-mbox", "price", 0d), 0.0001);
assertEquals("a", attrs.toMboxMap("target-global-mbox").get("experience"));
assertEquals("a", attrs.toMap().get("target-global-mbox").get("experience"));
}
use of com.adobe.target.edge.client.Attributes in project target-java-sdk by adobe.
the class TargetDeliveryAttributesTest method testTargetDeliveryAttributesVisitor1.
@Test
void testTargetDeliveryAttributesVisitor1() {
TargetDeliveryRequest targetDeliveryRequest = localDeliveryRequest("38734fba-262c-4722-b4a3-ac0a93916874");
Attributes attrs = targetJavaClient.getAttributes(targetDeliveryRequest, "testoffer", "testoffer2");
validateInitialResponse(targetDeliveryRequest, attrs);
validateResultA(attrs);
}
use of com.adobe.target.edge.client.Attributes in project target-java-sdk by adobe.
the class TargetDeliveryAttributesTest method testTargetDeliveryAttributesVisitor2.
@Test
void testTargetDeliveryAttributesVisitor2() {
TargetDeliveryRequest targetDeliveryRequest = localDeliveryRequest("38734fba-262c-4722-b4a3-ac0a93916873");
Attributes attrs = targetJavaClient.getAttributes(targetDeliveryRequest, "testoffer", "testoffer2");
validateInitialResponse(targetDeliveryRequest, attrs);
assertTrue(attrs.getBoolean("testoffer", "test", false));
assertEquals("b", attrs.getString("testoffer", "experience"));
assertEquals(9.99, attrs.getDouble("testoffer", "price", 0d), 0.0001);
assertEquals("b", attrs.toMboxMap("testoffer").get("experience"));
assertEquals("b", attrs.toMap().get("testoffer").get("experience"));
assertEquals(2, attrs.getInteger("testoffer2", "offer", 0));
}
Aggregations