Ejemplo n.º 1
0
  @Test
  public void testMapToApplicationDoc() {
    String json =
        "{\"applications\":[{\"_id\":{\"$oid\":\"512102513717790d6de5b78c\"},\"applicationName\":\"FormsTracking\"},{\"_id\":{\"$oid\":\"512102513717790d6de5b78d\"},\"applicationName\":\"InsuranceNotify\"},{\"_id\":{\"$oid\":\"512102513717790d6de5b78e\"},\"applicationName\":\"TestDataApp01\"}]}";
    ApplicationDoc doc = Mapper.mapToApplicationDoc(json);

    assertNotNull(doc);
    Application[] aa = doc.getApplications();
    assertNotNull(aa);
    assertEquals(3, aa.length);
    assertEquals("FormsTracking", aa[0].getApplicationName());
  }
Ejemplo n.º 2
0
  @Test
  public void testMapToPropEnvDoc() {
    String json =
        "{\"_id\":{\"$oid\":\"50ef90623717d9bdc94d79e4\"},\"applicationName\":\"TestDataApp\",\"propEnvValues\":[{\"prop\":\"a.b.c\",\"envValues\":[{\"env\":\"dev\",\"values\":[\"1\",\"2\"]},{\"env\":\"test\",\"values\":[\"3\",\"4\"]}]},{\"prop\":\"x.y.z\",\"envValues\":[{\"env\":\"test\",\"values\":[\"q\"]},{\"env\":\"dev\",\"values\":[\"a\",\"b\"]}]}]}";
    PropEnvDoc propEnvDoc = Mapper.mapToPropEnvDoc(json);

    assertNotNull(propEnvDoc);
    MongoDBId mongoDBId = propEnvDoc.getId();
    assertEquals("50ef90623717d9bdc94d79e4", mongoDBId.getOid());
    assertEquals("TestDataApp", propEnvDoc.getApplicationName());
    PropEnvValue[] peva = propEnvDoc.getPropEnvValues();
    assertEquals(2, peva.length);
    PropEnvValue pev1 = peva[0];
    assertEquals("a.b.c", pev1.getProp());
    EnvValue[] eva1 = pev1.getEnvValues();
    assertEquals(2, eva1.length);
    EnvValue ev1 = eva1[0];
    assertEquals("dev", ev1.getEnv());
    String[] sa1 = ev1.getValues();
    assertEquals(2, sa1.length);
    assertEquals("1", sa1[0]);
    assertEquals("2", sa1[1]);
    EnvValue ev2 = eva1[1];
    assertEquals("test", ev2.getEnv());
    String[] sa2 = ev2.getValues();
    assertEquals(2, sa2.length);
    assertEquals("3", sa2[0]);
    assertEquals("4", sa2[1]);

    PropEnvValue pev2 = peva[1];
    assertEquals("x.y.z", pev2.getProp());
    EnvValue[] eva2 = pev2.getEnvValues();
    assertEquals(2, eva2.length);
    EnvValue ev3 = eva2[0];
    assertEquals("test", ev3.getEnv());
    String[] sa3 = ev3.getValues();
    assertEquals(1, sa3.length);
    assertEquals("q", sa3[0]);
    EnvValue ev4 = eva2[1];
    assertEquals("dev", ev4.getEnv());
    String[] sa4 = ev4.getValues();
    assertEquals(2, sa4.length);
    assertEquals("a", sa4[0]);
    assertEquals("b", sa4[1]);
  }