@Test public void testGetGlobalOperation_Null() { EasyMock.expect( computeRpcMock.getGlobalOperation( GLOBAL_OPERATION_ID.getOperation(), EMPTY_RPC_OPTIONS)) .andReturn(null); EasyMock.replay(computeRpcMock); compute = options.getService(); assertNull(compute.getOperation(GLOBAL_OPERATION_ID)); }
@Test public void testGetGlobalOperation() { EasyMock.expect( computeRpcMock.getGlobalOperation( GLOBAL_OPERATION_ID.getOperation(), EMPTY_RPC_OPTIONS)) .andReturn(globalOperation.toPb()); EasyMock.replay(computeRpcMock); compute = options.getService(); assertEquals(globalOperation, compute.getOperation(GLOBAL_OPERATION_ID)); }
@Override public com.google.api.services.compute.model.Operation call() { switch (operationId.getType()) { case REGION: RegionOperationId regionOperationId = (RegionOperationId) operationId; return computeRpc.getRegionOperation( regionOperationId.getRegion(), regionOperationId.getOperation(), optionsMap); case ZONE: ZoneOperationId zoneOperationId = (ZoneOperationId) operationId; return computeRpc.getZoneOperation( zoneOperationId.getZone(), zoneOperationId.getOperation(), optionsMap); case GLOBAL: return computeRpc.getGlobalOperation(operationId.getOperation(), optionsMap); default: throw new IllegalArgumentException("Unexpected operation identity type"); } } },
@Test public void testGetGlobalOperationWithSelectedFields() { Capture<Map<ComputeRpc.Option, Object>> capturedOptions = Capture.newInstance(); EasyMock.expect( computeRpcMock.getGlobalOperation( eq(GLOBAL_OPERATION_ID.getOperation()), capture(capturedOptions))) .andReturn(globalOperation.toPb()); EasyMock.replay(computeRpcMock); compute = options.getService(); Operation operation = compute.getOperation(GLOBAL_OPERATION_ID, OPERATION_OPTION_FIELDS); String selector = (String) capturedOptions.getValue().get(OPERATION_OPTION_FIELDS.getRpcOption()); assertTrue(selector.contains("selfLink")); assertTrue(selector.contains("id")); assertTrue(selector.contains("description")); assertEquals(23, selector.length()); assertEquals(globalOperation, operation); }