@Test public void testGetZoneOperation_Null() { EasyMock.expect( computeRpcMock.getZoneOperation( ZONE_OPERATION_ID.getZone(), ZONE_OPERATION_ID.getOperation(), EMPTY_RPC_OPTIONS)) .andReturn(null); EasyMock.replay(computeRpcMock); compute = options.getService(); assertNull(compute.getOperation(ZONE_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 testGetZoneOperation() { EasyMock.expect( computeRpcMock.getZoneOperation( ZONE_OPERATION_ID.getZone(), ZONE_OPERATION_ID.getOperation(), EMPTY_RPC_OPTIONS)) .andReturn(zoneOperation.toPb()); EasyMock.replay(computeRpcMock); compute = options.getService(); Operation operation = compute.getOperation(ZONE_OPERATION_ID); assertEquals(zoneOperation, operation); }
@Test public void testGetZoneOperationWithSelectedFields() { Capture<Map<ComputeRpc.Option, Object>> capturedOptions = Capture.newInstance(); EasyMock.expect( computeRpcMock.getZoneOperation( eq(ZONE_OPERATION_ID.getZone()), eq(ZONE_OPERATION_ID.getOperation()), capture(capturedOptions))) .andReturn(zoneOperation.toPb()); EasyMock.replay(computeRpcMock); compute = options.getService(); Operation operation = compute.getOperation(ZONE_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(zoneOperation, operation); }