类com.google.gson.internal.StringMap源码实例Demo

下面列出了怎么用com.google.gson.internal.StringMap的API类实例代码及写法,或者点击链接到github查看源代码。

源代码1 项目: zeppelin   文件: HeliumRestApiTest.java
@Test
public void testGetAllEnabledPackageInfo() throws IOException {
  // No enabled packages initially
  GetMethod get1 = httpGet("/helium/enabledPackage");
  assertThat(get1, isAllowed());
  Map<String, Object> resp1 = gson.fromJson(get1.getResponseBodyAsString(),
              new TypeToken<Map<String, Object>>() { }.getType());
  List<StringMap<Object>> body1 = (List<StringMap<Object>>) resp1.get("body");
  assertEquals(body1.size(), 0);

  // Enable "name1" package
  helium.enable("name1", "artifact1");

  GetMethod get2 = httpGet("/helium/enabledPackage");
  assertThat(get2, isAllowed());
  Map<String, Object> resp2 = gson.fromJson(get2.getResponseBodyAsString(),
          new TypeToken<Map<String, Object>>() { }.getType());
  List<StringMap<Object>> body2 = (List<StringMap<Object>>) resp2.get("body");

  assertEquals(body2.size(), 1);
  StringMap<Object> pkg = (StringMap<Object>) body2.get(0).get("pkg");
  assertEquals(pkg.get("name"), "name1");
}
 
源代码2 项目: zeppelin   文件: HeliumRestApiTest.java
@Test
public void testEnableDisablePackage() throws IOException {
  String packageName = "name1";
  PostMethod post1 = httpPost("/helium/enable/" + packageName, "");
  assertThat(post1, isAllowed());
  post1.releaseConnection();

  GetMethod get1 = httpGet("/helium/package/" + packageName);
  Map<String, Object> resp1 = gson.fromJson(get1.getResponseBodyAsString(),
          new TypeToken<Map<String, Object>>() { }.getType());
  List<StringMap<Object>> body1 = (List<StringMap<Object>>) resp1.get("body");
  assertEquals(body1.get(0).get("enabled"), true);

  PostMethod post2 = httpPost("/helium/disable/" + packageName, "");
  assertThat(post2, isAllowed());
  post2.releaseConnection();

  GetMethod get2 = httpGet("/helium/package/" + packageName);
  Map<String, Object> resp2 = gson.fromJson(get2.getResponseBodyAsString(),
          new TypeToken<Map<String, Object>>() { }.getType());
  List<StringMap<Object>> body2 = (List<StringMap<Object>>) resp2.get("body");
  assertEquals(body2.get(0).get("enabled"), false);
}
 
源代码3 项目: cloud-odata-java   文件: FilterToJsonTest.java
@SuppressWarnings("unchecked")
@Test
public void testToJsonBinaryProperty() throws Exception {
  FilterExpression expression = UriParser.parseFilter(null, null, "a eq b");
  String jsonString = toJson(expression);
  Gson gsonConverter = new Gson();

  StringMap<Object> jsonMap = gsonConverter.fromJson(jsonString, StringMap.class);
  checkBinary(jsonMap, "eq", null);

  StringMap<Object> left = (StringMap<Object>) jsonMap.get(LEFT);
  checkProperty(left, null, "a");

  StringMap<Object> right = (StringMap<Object>) jsonMap.get(RIGHT);
  checkProperty(right, null, "b");
}
 
源代码4 项目: cloud-odata-java   文件: FilterToJsonTest.java
@SuppressWarnings("unchecked")
@Test
public void testToJsonBinaryLiteral() throws Exception {
  FilterExpression expression = UriParser.parseFilter(null, null, "'a' eq 'b'");
  String jsonString = toJson(expression);
  Gson gsonConverter = new Gson();

  StringMap<Object> jsonMap = gsonConverter.fromJson(jsonString, StringMap.class);
  checkBinary(jsonMap, "eq", "Edm.Boolean");

  StringMap<Object> left = (StringMap<Object>) jsonMap.get(LEFT);
  checkLiteral(left, "Edm.String", "a");

  StringMap<Object> right = (StringMap<Object>) jsonMap.get(RIGHT);
  checkLiteral(right, "Edm.String", "b");
}
 
源代码5 项目: cloud-odata-java   文件: FilterToJsonTest.java
@SuppressWarnings("unchecked")
@Test
public void testToJsonMember() throws Exception {
  FilterExpression expression = UriParser.parseFilter(null, null, "Location/Country");
  String jsonString = toJson(expression);
  Gson gsonConverter = new Gson();

  StringMap<Object> jsonMap = gsonConverter.fromJson(jsonString, StringMap.class);
  checkMember(jsonMap, null);

  StringMap<Object> source = (StringMap<Object>) jsonMap.get(SOURCE);
  checkProperty(source, null, "Location");

  StringMap<Object> path = (StringMap<Object>) jsonMap.get(PATH);
  checkProperty(path, null, "Country");
}
 
源代码6 项目: cloud-odata-java   文件: FilterToJsonTest.java
@SuppressWarnings("unchecked")
@Test
public void testToJsonMember2() throws Exception {
  FilterExpression expression = UriParser.parseFilter(null, null, "Location/Country/PostalCode");
  String jsonString = toJson(expression);
  Gson gsonConverter = new Gson();

  StringMap<Object> jsonMap = gsonConverter.fromJson(jsonString, StringMap.class);
  checkMember(jsonMap, null);

  StringMap<Object> source1 = (StringMap<Object>) jsonMap.get(SOURCE);
  checkMember(source1, null);

  StringMap<Object> source2 = (StringMap<Object>) source1.get(SOURCE);
  checkProperty(source2, null, "Location");

  StringMap<Object> path1 = (StringMap<Object>) source1.get(PATH);
  checkProperty(path1, null, "Country");

  StringMap<Object> path = (StringMap<Object>) jsonMap.get(PATH);
  checkProperty(path, null, "PostalCode");
}
 
@Test
public void createThreeLevelsDeepInsert() throws Exception {
  String content = "{\"Name\" : \"Room 2\",\"nr_Building\" : {\"Name\" : \"Building 2\",\"nb_Rooms\" : {\"results\" : [{"
      + "\"nr_Employees\" : {\"__deferred\" : {\"uri\" : \"" + getEndpoint() + "Rooms('1')/nr_Employees\""
      + "}},\"nr_Building\" : {\"__deferred\" : {\"uri\" : \"" + getEndpoint() + "/Rooms('1')/nr_Building\""
      + "}}}]}}}";

  HttpResponse response = postUri("Rooms", content, HttpContentType.APPLICATION_JSON, HttpHeaders.ACCEPT, HttpContentType.APPLICATION_JSON, HttpStatusCodes.CREATED);
  checkMediaType(response, HttpContentType.APPLICATION_JSON);

  String body = getBody(response);

  //Check inline building
  StringMap<?> map = getStringMap(body);
  map = (StringMap<?>) map.get("nr_Building");
  assertNotNull(map);
  assertEquals("Building 2", map.get("Name"));

  //Check inline rooms of the inline building
  map = (StringMap<?>) map.get("nb_Rooms");
  assertNotNull(map);

  ArrayList<?> results = (ArrayList<?>) map.get("results");
  assertNotNull(results);
  assertEquals(2, results.size());
}
 
@Test
public void createEntryRoomWithInlineEmptyFeedArray() throws Exception {
  String content = "{\"d\":{\"__metadata\":{\"id\":\"" + getEndpoint() + "Rooms('1')\","
      + "\"uri\":\"" + getEndpoint() + "Rooms('1')\",\"type\":\"RefScenario.Room\","
      + "\"etag\":\"W/\\\"3\\\"\"},"
      + "\"Id\":\"1\",\"Name\":\"Room 104\",\"Seats\":4,\"Version\":2,"
      + "\"nr_Employees\":[],"
      + "\"nr_Building\":{\"__deferred\":{\"uri\":\"" + getEndpoint() + "Rooms('1')/nr_Building\"}}}}";
  HttpResponse response = postUri("Rooms", content, HttpContentType.APPLICATION_JSON, HttpHeaders.ACCEPT, HttpContentType.APPLICATION_JSON, HttpStatusCodes.CREATED);
  checkMediaType(response, HttpContentType.APPLICATION_JSON);
  checkEtag(response, "W/\"2\"");

  String body = getBody(response);
  StringMap<?> map = getStringMap(body);
  assertEquals("104", map.get("Id"));
  assertEquals("Room 104", map.get("Name"));

  @SuppressWarnings("unchecked")
  StringMap<String> metadataMap = (StringMap<String>) map.get("__metadata");
  assertNotNull(metadataMap);
  assertEquals(getEndpoint() + "Rooms('104')", metadataMap.get("id"));
  assertEquals("RefScenario.Room", metadataMap.get("type"));
  assertEquals(getEndpoint() + "Rooms('104')", metadataMap.get("uri"));
}
 
@Test
public void createEntryRoomWithInlineEmptyFeedObject() throws Exception {
  String content = "{\"d\":{\"__metadata\":{\"id\":\"" + getEndpoint() + "Rooms('1')\","
      + "\"uri\":\"" + getEndpoint() + "Rooms('1')\",\"type\":\"RefScenario.Room\","
      + "\"etag\":\"W/\\\"3\\\"\"},"
      + "\"Id\":\"1\",\"Name\":\"Room 104\",\"Seats\":4,\"Version\":2,"
      + "\"nr_Employees\":{\"results\":[]},"
      + "\"nr_Building\":{\"__deferred\":{\"uri\":\"" + getEndpoint() + "Rooms('1')/nr_Building\"}}}}";
  HttpResponse response = postUri("Rooms", content, HttpContentType.APPLICATION_JSON, HttpHeaders.ACCEPT, HttpContentType.APPLICATION_JSON, HttpStatusCodes.CREATED);
  checkMediaType(response, HttpContentType.APPLICATION_JSON);
  checkEtag(response, "W/\"2\"");

  String body = getBody(response);
  StringMap<?> map = getStringMap(body);
  assertEquals("104", map.get("Id"));
  assertEquals("Room 104", map.get("Name"));

  @SuppressWarnings("unchecked")
  StringMap<String> metadataMap = (StringMap<String>) map.get("__metadata");
  assertNotNull(metadataMap);
  assertEquals(getEndpoint() + "Rooms('104')", metadataMap.get("id"));
  assertEquals("RefScenario.Room", metadataMap.get("type"));
  assertEquals(getEndpoint() + "Rooms('104')", metadataMap.get("uri"));
}
 
源代码10 项目: cloud-odata-java   文件: EntryJsonCreateTest.java
@Test
public void createEntryRoomWithLink() throws Exception {
  String content = "{\"d\":{\"__metadata\":{\"id\":\"" + getEndpoint() + "Rooms('1')\","
      + "\"uri\":\"" + getEndpoint() + "Rooms('1')\",\"type\":\"RefScenario.Room\","
      + "\"etag\":\"W/\\\"3\\\"\"},"
      + "\"Id\":\"1\",\"Name\":\"Room 104\","
      + "\"nr_Employees\":{\"__deferred\":{\"uri\":\"" + getEndpoint() + "Rooms('1')/nr_Employees\"}},"
      + "\"nr_Building\":{\"__deferred\":{\"uri\":\"" + getEndpoint() + "Rooms('1')/nr_Building\"}}}}";
  assertNotNull(content);
  HttpResponse response = postUri("Rooms", content, HttpContentType.APPLICATION_JSON, HttpHeaders.ACCEPT, HttpContentType.APPLICATION_JSON, HttpStatusCodes.CREATED);
  checkMediaType(response, HttpContentType.APPLICATION_JSON);

  String body = getBody(response);
  StringMap<?> map = getStringMap(body);
  assertEquals("104", map.get("Id"));
  assertEquals("Room 104", map.get("Name"));
  @SuppressWarnings("unchecked")
  StringMap<Object> employeesMap = (StringMap<Object>) map.get("nr_Employees");
  assertNotNull(employeesMap);
  @SuppressWarnings("unchecked")
  StringMap<String> deferredMap = (StringMap<String>) employeesMap.get("__deferred");
  assertNotNull(deferredMap);
  assertEquals(getEndpoint() + "Rooms('104')/nr_Employees", deferredMap.get("uri"));
}
 
源代码11 项目: cloud-odata-java   文件: EntryJsonCreateTest.java
@Test
public void createEntryEmployee() throws Exception {
  String content = "{iVBORw0KGgoAAAANSUhEUgAAAB4AAAAwCAIAAACJ9F2zAAAAA}";

  assertNotNull(content);
  HttpResponse response = postUri("Employees", content, HttpContentType.TEXT_PLAIN, HttpHeaders.ACCEPT, HttpContentType.APPLICATION_JSON, HttpStatusCodes.CREATED);
  checkMediaType(response, HttpContentType.APPLICATION_JSON);

  String body = getBody(response);
  StringMap<?> map = getStringMap(body);
  assertEquals("7", map.get("EmployeeId"));
  assertEquals("Employee 7", map.get("EmployeeName"));
  assertNull(map.get("EntryData"));
  response = callUri("Employees('7')/$value");
  checkMediaType(response, HttpContentType.TEXT_PLAIN);
}
 
源代码12 项目: zeppelin   文件: InterpreterSetting.java
public void setProperties(Object object) {
  if (object instanceof StringMap) {
    StringMap<String> map = (StringMap) properties;
    Properties newProperties = new Properties();
    for (String key : map.keySet()) {
      newProperties.put(key, map.get(key));
    }
    this.properties = newProperties;
  } else {
    this.properties = object;
  }
}
 
源代码13 项目: zeppelin   文件: HeliumRestApiTest.java
@Test
public void testGetSinglePackageInfo() throws IOException {
  String packageName = "name1";
  GetMethod get = httpGet("/helium/package/" + packageName);
  assertThat(get, isAllowed());
  Map<String, Object> resp = gson.fromJson(get.getResponseBodyAsString(),
          new TypeToken<Map<String, Object>>() { }.getType());
  List<StringMap<Object>> body = (List<StringMap<Object>>) resp.get("body");

  assertEquals(body.size(), 1);
  StringMap<Object> pkg = (StringMap<Object>) body.get(0).get("pkg");
  assertEquals(pkg.get("name"), "name1");
}
 
源代码14 项目: zeppelin   文件: HeliumRestApiTest.java
@Test
public void testGetAllPackageConfigs() throws IOException {
  GetMethod get = httpGet("/helium/config/");
  assertThat(get, isAllowed());
  Map<String, Object> resp = gson.fromJson(get.getResponseBodyAsString(),
          new TypeToken<Map<String, Object>>() { }.getType());
  StringMap<Object> body = (StringMap<Object>) resp.get("body");
  // ToDo: Apply config with POST command and check update
  assertEquals(body.size(), 0);
}
 
源代码15 项目: zeppelin   文件: HeliumRestApiTest.java
@Test
public void testGetPackageConfig() throws IOException {
  String packageName = "name1";
  String artifact = "artifact1";
  GetMethod get = httpGet("/helium/config/" + packageName + "/" + artifact);
  assertThat(get, isAllowed());
  Map<String, Object> resp = gson.fromJson(get.getResponseBodyAsString(),
          new TypeToken<Map<String, Object>>() { }.getType());
  StringMap<Object> body = (StringMap<Object>) resp.get("body");
  assertTrue(body.containsKey("confPersisted"));
}
 
源代码16 项目: tajo   文件: TestQueryResource.java
@Test
public void testGetAllQueries() throws Exception {
  String sessionId = generateNewSessionAndGetId();
  SubmitQueryRequest queryRequest = createNewQueryRequest("select * from lineitem");

  GetSubmitQueryResponse response = restClient.target(queriesURI)
      .request().header(tajoSessionIdHeaderName, sessionId)
      .post(Entity.entity(queryRequest, MediaType.APPLICATION_JSON),
              new GenericType<>(GetSubmitQueryResponse.class));

  assertNotNull(response);
  assertEquals(ResultCode.OK, response.getResultCode());
  String location = response.getUri().toString();
  assertTrue(location != null && !location.isEmpty());
  
  String queryId = location.lastIndexOf('/') >= 0?
	location.substring(location.lastIndexOf('/')+1):null;
      
  assertTrue(queryId != null && !queryId.isEmpty());
  
  Map<String, List<StringMap>> queriesMap = restClient.target(queriesURI)
      .request().get(new GenericType<>(Map.class));
  
  assertNotNull(queriesMap);
  
  List<StringMap> queryInfoList = queriesMap.get("queries");
  assertNotNull(queryInfoList);
  
  boolean assertQueryIdFound = false;
  for (StringMap queryInfo: queryInfoList) {
    if (queryId.equals(queryInfo.get("queryIdStr"))) {
      assertQueryIdFound = true;
    }
  }
  
  assertTrue(assertQueryIdFound);
}
 
@Test
public void testAllProductsWithApiResponse() throws Exception {
  for (StringMap productInfo : TestData.getProductsFromApi()) {
    selenium.get(TestData.getBaseUrl() + productInfo.get("url"));
    verifyProductInfo(productInfo);
  }
}
 
@Test
public void testAllProductsWithApiResponse() throws Exception {
  for (StringMap productInfo : TestData.getProductsFromApi()) {
    selenium.get(TestData.getBaseUrl() + productInfo.get("url"));
    verifyProductInfo(productInfo);
  }
}
 
源代码19 项目: cloud-odata-java   文件: FilterToJsonTest.java
@SuppressWarnings("unchecked")
@Test
public void testToJsonBinaryAdd() throws Exception {
  FilterExpression expression = UriParser.parseFilter(null, null, "1d add 2d add 3d add 4d");
  String jsonString = toJson(expression);
  Gson gsonConverter = new Gson();

  StringMap<Object> jsonMap = gsonConverter.fromJson(jsonString, StringMap.class);
  checkBinary(jsonMap, "add", "Edm.Double");

  StringMap<Object> left1 = (StringMap<Object>) jsonMap.get(LEFT);
  checkBinary(left1, "add", "Edm.Double");

  StringMap<Object> left2 = (StringMap<Object>) left1.get(LEFT);
  checkBinary(left2, "add", "Edm.Double");

  StringMap<Object> literal1 = (StringMap<Object>) left2.get(LEFT);
  checkLiteral(literal1, "Edm.Double", "1");

  StringMap<Object> literal2 = (StringMap<Object>) left2.get(RIGHT);
  checkLiteral(literal2, "Edm.Double", "2");

  StringMap<Object> literal3 = (StringMap<Object>) left1.get(RIGHT);
  checkLiteral(literal3, "Edm.Double", "3");

  StringMap<Object> right1 = (StringMap<Object>) jsonMap.get(RIGHT);
  checkLiteral(right1, "Edm.Double", "4");
}
 
源代码20 项目: cloud-odata-java   文件: FilterToJsonTest.java
@SuppressWarnings("unchecked")
@Test
public void testToJsonMethod() throws Exception {
  FilterExpression expression = UriParser.parseFilter(null, null, "concat('aa','b')");
  String jsonString = toJson(expression);
  Gson gsonConverter = new Gson();

  StringMap<Object> jsonMap = gsonConverter.fromJson(jsonString, StringMap.class);
  checkMethod(jsonMap, MethodOperator.CONCAT, "Edm.String");

  List<Object> parameter = (List<Object>) jsonMap.get(PARAMETERS);
  checkLiteral((StringMap<Object>) parameter.get(0), "Edm.String", "aa");
  checkLiteral((StringMap<Object>) parameter.get(1), "Edm.String", "b");
}
 
源代码21 项目: cloud-odata-java   文件: FilterToJsonTest.java
@SuppressWarnings("unchecked")
@Test
public void testToJsonUnary() throws Exception {
  FilterExpression expression = UriParser.parseFilter(null, null, "not 'a'");
  String jsonString = toJson(expression);

  StringMap<Object> jsonMap = new Gson().fromJson(jsonString, StringMap.class);
  checkUnary(jsonMap, UnaryOperator.NOT, null);

  StringMap<Object> operand = (StringMap<Object>) jsonMap.get(OPERAND);
  checkLiteral(operand, "Edm.String", "a");
}
 
源代码22 项目: cloud-odata-java   文件: FilterToJsonTest.java
private void checkBinary(final StringMap<Object> binary, final String expectedOperator, final String expectedType) throws Exception {
  assertEquals(ExpressionKind.BINARY.toString(), binary.get(NODETYPE));
  assertEquals(expectedOperator, binary.get(OPERATOR));
  assertEquals(expectedType, binary.get(TYPE));
  assertNotNull(binary.get(LEFT));
  assertNotNull(binary.get(RIGHT));
}
 
源代码23 项目: cloud-odata-java   文件: AbstractRefJsonTest.java
public StringMap<?> getStringMap(final String body) {
  Gson gson = new Gson();
  final StringMap<?> map = gson.fromJson(body, new TypeToken<StringMap<?>>() {}.getType());
  if (map.get("d") instanceof StringMap<?>) {
    return (StringMap<?>) map.get("d");
  } else {
    return map;
  }
}
 
@Test
public void createEntryRoomWithInlineFeedEmployee() throws Exception {
  String content = "{\"d\":{\"__metadata\":{\"id\":\"" + getEndpoint() + "Rooms('1')\","
      + "\"uri\":\"" + getEndpoint() + "Rooms('1')\",\"type\":\"RefScenario.Room\","
      + "\"etag\":\"W/\\\"3\\\"\"},"
      + "\"Id\":\"1\",\"Name\":\"Room 104\",\"Seats\":4,\"Version\":2,"
      + "\"nr_Employees\":{\"results\":[{"
      + "\"__metadata\":{"
      + "\"id\":\"" + getEndpoint() + "Employees('1')\","
      + "\"type\":\"RefScenario.Employee\","
      + "\"content_type\":\"image/jpeg\","
      + "\"media_src\":\"" + getEndpoint() + "Employees('1')/$value\","
      + "\"edit_media\":\"" + getEndpoint() + "Employees('1')/$value\"},"
      + " \"EmployeeName\": \"Walter Winter\","
      + "\"ManagerId\": \"1\","
      + "\"RoomId\": \"1\","
      + "\"TeamId\": \"1\","
      + "\"Age\": 52,"
      + "\"Location\":{\"City\":{\"PostalCode\":\"69124\",\"CityName\":\"Heidelberg\"},"
      + "              \"Country\":\"Germany\"},"
      + "\"ImageUrl\": \"" + getEndpoint() + "Employees('1')/$value\"}]},"
      + "\"nr_Building\":{\"__deferred\":{\"uri\":\"" + getEndpoint() + "Rooms('1')/nr_Building\"}}}}";

  HttpResponse response = postUri("Rooms", content, HttpContentType.APPLICATION_JSON, HttpHeaders.ACCEPT, HttpContentType.APPLICATION_JSON, HttpStatusCodes.CREATED);
  checkMediaType(response, HttpContentType.APPLICATION_JSON);

  String body = getBody(response);
  StringMap<?> map = getStringMap(body);
  assertEquals("104", map.get("Id"));
  assertEquals("Room 104", map.get("Name"));

  @SuppressWarnings("unchecked")
  StringMap<String> metadataMap = (StringMap<String>) map.get("__metadata");
  assertNotNull(metadataMap);
  assertEquals(getEndpoint() + "Rooms('104')", metadataMap.get("id"));
  assertEquals("RefScenario.Room", metadataMap.get("type"));
  assertEquals(getEndpoint() + "Rooms('104')", metadataMap.get("uri"));
}
 
源代码25 项目: cloud-odata-java   文件: EntryJsonCreateTest.java
@Test
public void createEntryRoom() throws Exception {
  String content = "{\"d\":{\"__metadata\":{\"id\":\"" + getEndpoint() + "Rooms('1')\","
      + "\"uri\":\"" + getEndpoint() + "Rooms('1')\",\"type\":\"RefScenario.Room\","
      + "\"etag\":\"W/\\\"3\\\"\"},"
      + "\"Id\":\"1\",\"Name\":\"Room 104\",\"Seats\":4,\"Version\":2,"
      + "\"nr_Employees\":{\"__deferred\":{\"uri\":\"" + getEndpoint() + "Rooms('1')/nr_Employees\"}},"
      + "\"nr_Building\":{\"__deferred\":{\"uri\":\"" + getEndpoint() + "Rooms('1')/nr_Building\"}}}}";
  assertNotNull(content);
  HttpResponse response = postUri("Rooms", content, HttpContentType.APPLICATION_JSON, HttpHeaders.ACCEPT, HttpContentType.APPLICATION_JSON, HttpStatusCodes.CREATED);
  checkMediaType(response, HttpContentType.APPLICATION_JSON);

  String body = getBody(response);
  StringMap<?> map = getStringMap(body);
  assertEquals("104", map.get("Id"));
  assertEquals("Room 104", map.get("Name"));
  @SuppressWarnings("unchecked")
  StringMap<String> metadataMap = (StringMap<String>) map.get("__metadata");
  assertNotNull(metadataMap);
  assertEquals(getEndpoint() + "Rooms('104')", metadataMap.get("id"));
  assertEquals("RefScenario.Room", metadataMap.get("type"));
  assertEquals(getEndpoint() + "Rooms('104')", metadataMap.get("uri"));

  response = callUri("Rooms('104')/Seats/$value");
  body = getBody(response);
  assertEquals("4", body);
}
 
源代码26 项目: zeppelin   文件: NotebookRestApiTest.java
@Test
public void testRunParagraphSynchronously() throws IOException {
  LOG.info("Running testRunParagraphSynchronously");
  Note note1 = null;
  try {
    note1 = TestUtils.getInstance(Notebook.class).createNote("note1", anonymous);
    note1.addNewParagraph(AuthenticationInfo.ANONYMOUS);

    Paragraph p = note1.addNewParagraph(AuthenticationInfo.ANONYMOUS);

    // run non-blank paragraph
    String title = "title";
    String text = "%sh\n sleep 1";
    p.setTitle(title);
    p.setText(text);

    PostMethod post = httpPost("/notebook/run/" + note1.getId() + "/" + p.getId(), "");
    assertThat(post, isAllowed());
    Map<String, Object> resp = gson.fromJson(post.getResponseBodyAsString(),
        new TypeToken<Map<String, Object>>() {}.getType());
    assertEquals(resp.get("status"), "OK");
    post.releaseConnection();
    assertNotEquals(p.getStatus(), Job.Status.READY);

    // Check if the paragraph is emptied
    assertEquals(title, p.getTitle());
    assertEquals(text, p.getText());

    // run invalid code
    text = "%sh\n invalid_cmd";
    p.setTitle(title);
    p.setText(text);

    post = httpPost("/notebook/run/" + note1.getId() + "/" + p.getId(), "");
    assertEquals(500, post.getStatusCode());
    resp = gson.fromJson(post.getResponseBodyAsString(),
            new TypeToken<Map<String, Object>>() {}.getType());
    assertEquals("INTERNAL_SERVER_ERROR", resp.get("status"));
    StringMap stringMap = (StringMap) resp.get("body");
    assertEquals("ERROR", stringMap.get("code"));
    List<StringMap> interpreterResults = (List<StringMap>) stringMap.get("msg");
    assertTrue(interpreterResults.get(0).toString(),
            interpreterResults.get(0).get("data").toString().contains("invalid_cmd: command not found"));
    post.releaseConnection();
    assertNotEquals(p.getStatus(), Job.Status.READY);

    // Check if the paragraph is emptied
    assertEquals(title, p.getTitle());
    assertEquals(text, p.getText());
  } finally {
    // cleanup
    if (null != note1) {
      TestUtils.getInstance(Notebook.class).removeNote(note1, anonymous);
    }
  }
}
 
源代码27 项目: SeleniumBestPracticesBook   文件: TestData.java
public static List<StringMap> getProductsFromApi(){
  return JSONFixtures.parseJsonFixtures();
}
 
源代码28 项目: SeleniumBestPracticesBook   文件: JSONFixtures.java
public static List<StringMap> parseJsonFixtures(){
  return ((List<StringMap>) new Gson().fromJson(json, LinkedList.class));
}
 
源代码29 项目: SeleniumBestPracticesBook   文件: TestData.java
public static List<StringMap> getProductsFromApi(){
  return JSONFixtures.parseJsonFixtures();
}
 
源代码30 项目: SeleniumBestPracticesBook   文件: JSONFixtures.java
public static List<StringMap> parseJsonFixtures(){
  return ((List<StringMap>) new Gson().fromJson(json, LinkedList.class));
}
 
 类所在包
 类方法
 同包方法