Пример #1
0
  public static CommandLineJobInfo createRandom() {
    CommandLineJobInfo result = new CommandLineJobInfo();
    Random random = new Random();

    String command = CommonUtils.randomString(random.nextInt(10));
    JobConfInfo jobConfInfo = JobConfInfoTest.createRandom();

    result.setCommand(command);
    result.setConf(jobConfInfo);

    return result;
  }
  @Test
  public void requestBlockLocationTest() throws Exception {
    Map<String, String> params = new HashMap<>();
    params.put("blockId", "1");
    params.put("sessionId", "1");
    params.put("initialBytes", "1");

    String blockLocation = CommonUtils.randomString(10);
    Mockito.doReturn(blockLocation)
        .when(mBlockWorker)
        .createBlock(Mockito.anyLong(), Mockito.anyLong(), Mockito.anyString(), Mockito.anyLong());

    TestCaseFactory.newWorkerTestCase(
            getEndpoint(BlockWorkerClientRestServiceHandler.REQUEST_BLOCK_LOCATION),
            params,
            "POST",
            blockLocation,
            mResource)
        .run();

    Mockito.verify(mBlockWorker)
        .createBlock(Mockito.anyLong(), Mockito.anyLong(), Mockito.anyString(), Mockito.anyLong());
  }