@Test
  public void testJSONGroupObjectEqualsJavaGroupObject() {

    final boolean test = testGroup.toString().equals(testGroup1.toString());

    Assert.assertEquals(true, test);
  }
  @Test
  public void testIsPhoneDisabledTrue() throws JSONException {

    final boolean test = testGroup2.isPhoneDisabled(2);
    final boolean test1 = testGroup3.isPhoneDisabled(2);

    Assert.assertEquals(true, test);
    Assert.assertEquals(true, test1);
  }
  @Test
  public void testIsPhoneDisabledFalseEmptyList() {

    final boolean test = testGroup.isPhoneDisabled(1);
    final boolean test1 = testGroup1.isPhoneDisabled(1);

    Assert.assertEquals(false, test);
    Assert.assertEquals(false, test1);
  }
  @Test
  public void testIsPhoneDisabledFalseNotInList() throws JSONException {

    final boolean test = testGroup2.isPhoneDisabled(1);
    final boolean test1 = testGroup3.isPhoneDisabled(1);

    Assert.assertEquals(false, test);
    Assert.assertEquals(false, test1);
  }
  @Test
  public void testJSONNullGroupObject() throws JSONException {

    final Group nullGroup = new Group(testGroupObject);

    resultString =
        "{id=null;name=null;isCustomDirectConnect=false;directConnect=false;isCustomGreeting=false;isCustomForwarding=false;greetingId=0;disabledForwardingIds=null}";

    Assert.assertEquals(resultString, nullGroup.toString());
  }
  @Test
  public void testIsPhoneDisabledFalseNullList() throws JSONException {

    final JSONObject testJSONOb4 = new JSONObject();
    testJSONOb4.put("id", TEST_ID);
    testJSONOb4.put("name", "testName");
    testJSONOb4.put("isCustomForwarding", false);
    testJSONOb4.put("isCustomGreeting", false);
    testJSONOb4.put("isCustomDirectConnect", false);
    testJSONOb4.put("directConnect", false);
    testJSONOb4.put("greetingId", 0);

    final Group testGroup4 = new Group(testJSONOb4);

    final boolean testNullList = testGroup4.isPhoneDisabled(1);

    Assert.assertEquals(false, testNullList);
  }
  @Test
  public void testGroupsArrayToJsonObject() throws JSONException {

    resultString =
        "{\"testID\":{\"id\":\"testID\",\"greetingId\":0,\"isCustomForwarding\":false,\"isCustomGreeting\":false,\"disabledForwardingIds\":{},\"name\":\"testName\",\"isCustomDirectConnect\":false,\"directConnect\":false}}";

    final Group[] testObjectArray = {testGroup};

    Assert.assertEquals(resultString, Group.groupsArrayToJsonObject(testObjectArray).toString());
  }
  @Test
  public void testCreateArrayFromJsonObject() throws JSONException {

    testGroupObject.put(TEST_ID, testJSONOb1);

    final Group[] resultGroupArray = {testGroup};
    final Group[] testGroupArray = Group.createArrayFromJsonObject(testGroupObject);

    Assert.assertEquals(resultGroupArray[0].toString(), testGroupArray[0].toString());
  }
  @Test
  public void testListToJson() {

    testGrouplist.add(testGroup1);
    testGrouplist.add(testGroup3);

    resultString =
        "\"groups\":{\"testID\":{\"id\":\"testID\",\"greetingId\":0,\"isCustomForwarding\":false,\"isCustomGreeting\":false,\"disabledForwardingIds\":{},\"name\":\"testName\",\"isCustomDirectConnect\":false,\"directConnect\":false},\"testID1\":{\"id\":\"testID1\",\"greetingId\":0,\"isCustomForwarding\":false,\"isCustomGreeting\":false,\"disabledForwardingIds\":{\"3\":true,\"2\":true},\"name\":\"testName1\",\"isCustomDirectConnect\":false,\"directConnect\":false}}";

    Assert.assertEquals(resultString, Group.listToJson(testGrouplist).toString());
  }
Esempio n. 10
0
  @Test
  public void testCreateJSONObjectFromJsonObject() throws JSONException {

    resultString =
        "{\"testID\":\"{id=testID;name=testName;isCustomDirectConnect=false;directConnect=false;isCustomGreeting=false;isCustomForwarding=false;greetingId=0;disabledForwardingIds=[]}\"}";

    testGroupObject.put("obj1", testJSONOb1);

    final JSONObject testObject = Group.createJSONObjectFromJsonObject(testGroupObject);

    Assert.assertEquals(resultString, testObject.toString());
  }
Esempio n. 11
0
  @Test
  public void testCreateGroupSettingsFromJsonResponseEmptyDisabledForwardingID() {

    resultList.add(testGroup);

    testString =
        "\"groups\":{\"testID\":{\"id\":\"testID\",\"name\":\"testName\",\"disabledForwardingIds\":{},\"isCustomForwarding\":false,\"isCustomGreeting\":false,\"isCustomDirectConnect\":false,\"directConnect\":false,\"greetingId\":0,\"isCircle\":true,\"isCustomTranscriptionLanguage\":false,\"transcriptionLanguage\":\"\"},\"groupList\"";

    testGrouplist = Group.createGroupSettingsFromJsonResponse(testString);

    Assert.assertEquals(resultList.toString(), testGrouplist.toString());
  }
Esempio n. 12
0
  @Test
  public void testCreateGroupSettingsFromJsonResponseNullDisabledForwardingID() {

    testString =
        "\"groups\":{\"testID\":{\"id\":\"testID\",\"name\":\"testName\",\"isCustomForwarding\":false,\"isCustomGreeting\":false,\"isCustomDirectConnect\":false,\"directConnect\":false,\"greetingId\":0,\"isCircle\":true,\"isCustomTranscriptionLanguage\":false,\"transcriptionLanguage\":\"\"},\"groupList\"";

    try {
      testGrouplist = Group.createGroupSettingsFromJsonResponse(testString);
    } catch (Exception e) {
      testGrouplist = resultList;
    }
    Assert.assertEquals(resultList, testGrouplist);
  }