@Test
  public void testCallBridgeSuccess() throws Exception {
    String bridgeURL = "bridge-url";
    String history = "history";
    Date historyDate = new Date();

    SnapshotHistoryItem historyItem = new SnapshotHistoryItem();
    historyItem.setHistory(history);
    historyItem.setHistoryDate(historyDate);
    List<SnapshotHistoryItem> historyItems = new ArrayList<>();
    historyItems.add(historyItem);
    GetSnapshotHistoryBridgeResult bridgeResult = new GetSnapshotHistoryBridgeResult();
    bridgeResult.setHistoryItems(historyItems);

    InputStream resultStream = IOUtil.writeStringToStream(bridgeResult.serialize());

    RestHttpHelper.HttpResponse response =
        RestHttpHelper.HttpResponse.buildMock(200, null, resultStream);
    EasyMock.expect(restHelper.get(bridgeURL)).andReturn(response);

    replayMocks();

    String callResult = taskRunner.callBridge(restHelper, bridgeURL);

    GetSnapshotHistoryBridgeResult taskResult =
        GetSnapshotHistoryBridgeResult.deserialize(callResult);
    SnapshotHistoryItem item = taskResult.getHistoryItems().get(0);
    assertEquals(history, item.getHistory());
    assertEquals(historyDate, item.getHistoryDate());
  }
  @Test
  public void testCallBridgeFailure() throws Exception {
    String bridgeURL = "bridge-url";

    InputStream resultStream = IOUtil.writeStringToStream("Error");
    RestHttpHelper.HttpResponse response =
        RestHttpHelper.HttpResponse.buildMock(500, null, resultStream);
    EasyMock.expect(restHelper.get(bridgeURL)).andReturn(response);

    replayMocks();

    try {
      taskRunner.callBridge(restHelper, bridgeURL);
      fail("Exception expected on 500 response");
    } catch (TaskException e) {
    }
  }
Ejemplo n.º 3
0
 public static HttpResponse deleteSpace(String spaceID, String storeID) throws Exception {
   String url = getBaseUrl() + "/" + spaceID + "?storeID=" + storeID;
   return restHelper.delete(url);
 }
Ejemplo n.º 4
0
 private static HttpResponse addSpaceWithHeaders(String url) throws Exception {
   Map<String, String> headers = new HashMap<String, String>();
   headers.put(PROPERTIES_NAME, PROPERTIES_VALUE);
   return restHelper.put(url, null, headers);
 }