Search in sources :

Example 1 with JSONBoolean

use of com.google.gwt.json.client.JSONBoolean in project gwt-test-utils by gwt-test-utils.

the class JSONArrayTest method addElements.

@Test
public void addElements() {
    // Given
    JSONArray jsonArray = new JSONArray();
    JSONString string = new JSONString("myString");
    JSONBoolean bool = JSONBoolean.getInstance(true);
    // Preconditions
    assertThat(jsonArray.size()).isEqualTo(0);
    // When
    jsonArray.set(0, string);
    jsonArray.set(1, bool);
    // Then
    assertThat(jsonArray.size()).isEqualTo(2);
    assertThat(jsonArray.get(0)).isEqualTo(string);
    assertThat(jsonArray.get(1)).isEqualTo(bool);
    assertThat(jsonArray.get(2)).isNull();
    assertThat(jsonArray.get(-1)).isNull();
}
Also used : JSONArray(com.google.gwt.json.client.JSONArray) JSONBoolean(com.google.gwt.json.client.JSONBoolean) JSONString(com.google.gwt.json.client.JSONString) GwtTestTest(com.googlecode.gwt.test.GwtTestTest) Test(org.junit.Test)

Example 2 with JSONBoolean

use of com.google.gwt.json.client.JSONBoolean in project gwt-test-utils by gwt-test-utils.

the class JSONArrayTest method addElements_unbounded.

@Test
public void addElements_unbounded() {
    // Given
    JSONArray jsonArray = new JSONArray();
    JSONString string = new JSONString("myString");
    JSONBoolean bool = JSONBoolean.getInstance(true);
    // Preconditions
    assertThat(jsonArray.size()).isEqualTo(0);
    // When
    jsonArray.set(0, string);
    jsonArray.set(2, bool);
    // Then
    assertThat(jsonArray.size()).isEqualTo(3);
    assertThat(jsonArray.get(0)).isEqualTo(string);
    assertThat(jsonArray.get(1)).isNull();
    assertThat(jsonArray.get(2)).isEqualTo(bool);
    assertThat(jsonArray.get(3)).isNull();
}
Also used : JSONArray(com.google.gwt.json.client.JSONArray) JSONBoolean(com.google.gwt.json.client.JSONBoolean) JSONString(com.google.gwt.json.client.JSONString) GwtTestTest(com.googlecode.gwt.test.GwtTestTest) Test(org.junit.Test)

Example 3 with JSONBoolean

use of com.google.gwt.json.client.JSONBoolean in project perun by CESNET.

the class IsLoginAvailable method generateFinalResponse.

/**
	 * Generates the final response in format {value: true} or {value: false}
	 * @return
	 */
protected JavaScriptObject generateFinalResponse() {
    JSONBoolean response = JSONBoolean.getInstance(isAvailable);
    JSONObject json = new JSONObject();
    json.put("value", response);
    return json.getJavaScriptObject();
}
Also used : JSONObject(com.google.gwt.json.client.JSONObject) JSONBoolean(com.google.gwt.json.client.JSONBoolean)

Aggregations

JSONBoolean (com.google.gwt.json.client.JSONBoolean)3 JSONArray (com.google.gwt.json.client.JSONArray)2 JSONString (com.google.gwt.json.client.JSONString)2 GwtTestTest (com.googlecode.gwt.test.GwtTestTest)2 Test (org.junit.Test)2 JSONObject (com.google.gwt.json.client.JSONObject)1