Exemple #1
0
  @Test
  public void test7() {
    // Subscribers(guid1)/accounts(acc1)/subscribers(guid1)/preferences

    SIGPathSegment preferences = SIGPathSegment.newSegment("Preferences");

    GenericKey guid1 = newSubscriberKey();
    guid1.inferValues(ImmutableMap.of("guid", "guid1"));
    SIGPathSegment subscriber2 = SIGPathSegment.newSegment("Subscribers", guid1);

    GenericKey acc1 = newAccountKey();
    acc1.inferValues(ImmutableMap.of("accId", "acc1"));
    SIGPathSegment accounts = SIGPathSegment.newSegment("Accounts", acc1);

    SIGPathSegment subscriber1 = SIGPathSegment.newSegment("Subscribers", guid1);
    preferences.setPrev(subscriber2);
    subscriber2.setPrev(accounts);
    accounts.setPrev(subscriber1);

    SIGSegmentExecutor accountsExecutor = SIGSegmentExecutor.newExecutor(gateway, preferences);
    @SuppressWarnings("unchecked")
    Map<GenericKey, GenericData> result = (Map<GenericKey, GenericData>) accountsExecutor.execute();
    assertNotNull(result);
    GenericData obj = (GenericData) result.values().iterator().next();
    assertEquals("off", obj.get("pin_flag"));
  }
Exemple #2
0
 @Test
 public void test1() {
   GenericKey accountKey = newAccountKey();
   accountKey.inferValues(ImmutableMap.of("accId", "acc1"));
   // Accounts
   SIGPathSegment accounts = SIGPathSegment.newSegment("Accounts", accountKey);
   SIGSegmentExecutor accountsExecutor = SIGSegmentExecutor.newExecutor(gateway, accounts);
   GenericData result = (GenericData) accountsExecutor.execute();
   assertNotNull(result);
   assertEquals("jora", result.get("name"));
 }
Exemple #3
0
  @Test
  public void test2() {
    // Subscribers(guid1)/accounts
    SIGPathSegment accounts = SIGPathSegment.newSegment("Accounts");

    GenericKey subscriberKey = newSubscriberKey();
    subscriberKey.inferValues(ImmutableMap.of("guid", "guid1"));
    SIGPathSegment subscribers = SIGPathSegment.newSegment("Subscribers", subscriberKey);

    accounts.setPrev(subscribers);

    SIGSegmentExecutor accountsExecutor = SIGSegmentExecutor.newExecutor(gateway, accounts);
    @SuppressWarnings("unchecked")
    Map<GenericKey, GenericData> result = (Map<GenericKey, GenericData>) accountsExecutor.execute();
    assertNotNull(result);
    assertEquals(2, result.values().size());
  }
Exemple #4
0
  @Test
  public void test3() {
    // Subscribers(guid1)/accounts(acc1)
    GenericKey acc1 = newAccountKey();
    acc1.inferValues(ImmutableMap.of("accId", "acc1"));
    SIGPathSegment accounts = SIGPathSegment.newSegment("Accounts", acc1);

    GenericKey guid1 = newSubscriberKey();
    guid1.inferValues(ImmutableMap.of("guid", "guid1"));
    SIGPathSegment subscribers = SIGPathSegment.newSegment("Subscribers", guid1);

    accounts.setPrev(subscribers);

    SIGSegmentExecutor accountsExecutor = SIGSegmentExecutor.newExecutor(gateway, accounts);
    GenericData result = (GenericData) accountsExecutor.execute();
    assertNotNull(result);
    assertEquals("guid1", result.get("parent"));
  }
Exemple #5
0
  @Test
  public void test5() {
    // Subscribers(guid1)/preferences
    final String guid1value = "guid1";
    GenericKey guid1 = newSubscriberKey();
    guid1.inferValues(ImmutableMap.of("guid", guid1value));
    SIGPathSegment subscribers = SIGPathSegment.newSegment("Subscribers", guid1);

    GenericKey pref = newPreferenceKey();
    pref.inferValues(ImmutableMap.of(pref.getKeyNames().iterator().next(), guid1value));
    SIGPathSegment preferences = SIGPathSegment.newSegment("Preferences", pref);

    preferences.setPrev(subscribers);
    SIGSegmentExecutor ex = SIGSegmentExecutor.newExecutor(gateway, preferences);
    GenericData obj = (GenericData) ex.execute();
    assertNotNull(obj);
    assertEquals("off", obj.get("pin_flag"));
  }
Exemple #6
0
  @Test
  public void test6() {
    // Subscribers(guid1)/preferences
    final String guid1value = "guid1";
    GenericKey guid1 = newSubscriberKey();
    guid1.inferValues(ImmutableMap.of("guid", guid1value));
    SIGPathSegment subscribers = SIGPathSegment.newSegment("Subscribers", guid1);

    SIGPathSegment preferences = SIGPathSegment.newSegment("Preferences");

    preferences.setPrev(subscribers);
    SIGSegmentExecutor ex = SIGSegmentExecutor.newExecutor(gateway, preferences);
    @SuppressWarnings("unchecked")
    Map<GenericKey, GenericData> objMap = (Map<GenericKey, GenericData>) ex.execute();
    assertNotNull(objMap);
    GenericData obj = (GenericData) objMap.values().iterator().next();

    assertEquals("off", obj.get("pin_flag"));
  }
Exemple #7
0
  @Test
  public void test4() {
    // Subscribers(guid1)/accounts(acc1)/subscribers
    SIGPathSegment subscribers = SIGPathSegment.newSegment("Subscribers");

    GenericKey acc1 = newAccountKey();
    acc1.inferValues(ImmutableMap.of("accId", "acc1"));
    SIGPathSegment accounts = SIGPathSegment.newSegment("Accounts", acc1);

    GenericKey guid1 = newSubscriberKey();
    guid1.inferValues(ImmutableMap.of("guid", "guid1"));
    SIGPathSegment subscriber = SIGPathSegment.newSegment("Subscribers", guid1);

    subscribers.setPrev(accounts);
    accounts.setPrev(subscriber);

    SIGSegmentExecutor accountsExecutor = SIGSegmentExecutor.newExecutor(gateway, subscribers);
    @SuppressWarnings("unchecked")
    Map<GenericKey, GenericData> result = (Map<GenericKey, GenericData>) accountsExecutor.execute();
    assertNotNull(result);
    assertEquals("21", ((GenericData) result.values().iterator().next()).get("age"));
  }