Package org.json.simple

Examples of org.json.simple.JSONObject.containsKey()


        } else {
            JSONObject attributes = getValue();
            if (pAttribute == null) {
                throw new IllegalArgumentException("Cannot use null-attribute name to fetch a value from a multi-attribute request");
            }
            if (!attributes.containsKey(pAttribute)) {
                throw new IllegalArgumentException("No such key " + pAttribute + " in the set of returned attribute values");
            }
            return (V) attributes.get(pAttribute);
        }
    }
View Full Code Here


    Assert.assertEquals("-useHCatalog", do_stream.toString());
    Assert.assertEquals(201, response.getStatus());

    JSONObject obj = (JSONObject)response.getEntity();
    Assert.assertTrue(obj.containsKey("job"));
    Assert.assertNotNull(((PigJob) obj.get("job")).getId());
    Assert.assertFalse(((PigJob) obj.get("job")).getId().isEmpty());
    Assert.assertTrue(((PigJob) obj.get("job")).getStatusDir().startsWith("/tmp/.pigjobs/ambari-qa/test"));

    PigJob job = ((PigJob) obj.get("job"));
View Full Code Here

    replay(api);

    properties.put("dataworker.username", "luke");
    Response response = doCreateJob("Test", "/tmp/script.pig", "-useHCatalog");
    JSONObject obj = (JSONObject)response.getEntity();
    Assert.assertTrue(obj.containsKey("job"));
    Assert.assertTrue(((PigJob) obj.get("job")).getStatusDir().startsWith("/tmp/.pigjobs/luke/test"));
  }

  @Test
  public void testSubmitJobNoArguments() throws Exception {
View Full Code Here

    Assert.assertEquals("", do_stream.toString());
    Assert.assertEquals(201, response.getStatus());

    JSONObject obj = (JSONObject)response.getEntity();
    Assert.assertTrue(obj.containsKey("job"));
    Assert.assertNotNull(((PigJob) obj.get("job")).getId());
    Assert.assertFalse(((PigJob) obj.get("job")).getId().isEmpty());
    Assert.assertTrue(((PigJob) obj.get("job")).getStatusDir().startsWith("/tmp/.pigjobs/ambari-qa/test"));

    PigJob job = ((PigJob) obj.get("job"));
View Full Code Here

    public void createScript() {
        Response response = doCreateScript();
        Assert.assertEquals(201, response.getStatus());

        JSONObject obj = (JSONObject)response.getEntity();
        Assert.assertTrue(obj.containsKey("script"));
        Assert.assertNotNull(((PigScript) obj.get("script")).getId());
        Assert.assertFalse(((PigScript) obj.get("script")).getId().isEmpty());
    }

    @Test
View Full Code Here

    public void createScriptAutoCreate() {
        Response response = doCreateScript("Test", null);
        Assert.assertEquals(201, response.getStatus());

        JSONObject obj = (JSONObject)response.getEntity();
        Assert.assertTrue(obj.containsKey("script"));
        Assert.assertNotNull(((PigScript) obj.get("script")).getId());
        Assert.assertFalse(((PigScript) obj.get("script")).getId().isEmpty());
        Assert.assertFalse(((PigScript) obj.get("script")).getPigScript().isEmpty());
    }
View Full Code Here

        Response response2 = scriptService.getScript(createdScriptId);
        Assert.assertEquals(200, response2.getStatus());

        JSONObject obj = ((JSONObject) response2.getEntity());
        Assert.assertTrue(obj.containsKey("script"));
        Assert.assertEquals(((PigScript) obj.get("script")).getTitle(), request.script.getTitle());
    }

    @Test
    public void deleteScript() {
View Full Code Here

        Response response = scriptService.getScriptList();
        Assert.assertEquals(200, response.getStatus());

        JSONObject obj = (JSONObject) response.getEntity();
        Assert.assertTrue(obj.containsKey("scripts"));
        List<PigScript> scripts = (List<PigScript>) obj.get("scripts");
        boolean containsTitle = false;
        for(PigScript script : scripts)
            containsTitle = containsTitle || script.getTitle().compareTo("Title 1") == 0;
        Assert.assertTrue(containsTitle);
View Full Code Here

    Response response2 = fileService.getFile(filePath, 0L);
    Assert.assertEquals(200, response2.getStatus());

    JSONObject obj = ((JSONObject) response2.getEntity());
    Assert.assertTrue(obj.containsKey("file"));
    Assert.assertEquals("1234", ((FileResource) obj.get("file")).getFileContent());
  }

  @Test
  public void testPagination() throws Exception {
View Full Code Here

    Response response = fileService.getFile(filePath, 0L);
    Assert.assertEquals(200, response.getStatus());

    JSONObject obj = ((JSONObject) response.getEntity());
    Assert.assertTrue(obj.containsKey("file"));
    Assert.assertEquals("1234", ((FileResource) obj.get("file")).getFileContent());
    Assert.assertEquals(3, ((FileResource) obj.get("file")).getPageCount());
    Assert.assertEquals(0, ((FileResource) obj.get("file")).getPage());
    Assert.assertTrue(((FileResource) obj.get("file")).isHasNext());
    Assert.assertEquals(filePath, ((FileResource) obj.get("file")).getFilePath());
View Full Code Here

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.