MonitoringUtil { public static State toState(String stateName) { return MoreObjects.firstNonNull(DATAFLOW_STATE_TO_JOB_STATE.get(stateName), State.UNRECOGNIZED); } MonitoringUtil(DataflowClient dataflowClient); List<JobMessage> getJobMessages(String jobId, long startTimestampMs); @Deprecated static String getJobMonitoringPageURL(String projectName, String jobId); static String getJobMonitoringPageURL(String projectName, String regionId, String jobId); static String getGcloudCancelCommand(DataflowPipelineOptions options, String jobId); static State toState(String stateName);  }
@Test public void testToStateNormal() { assertEquals(State.UNKNOWN, MonitoringUtil.toState("JOB_STATE_UNKNOWN")); assertEquals(State.STOPPED, MonitoringUtil.toState("JOB_STATE_STOPPED")); assertEquals(State.RUNNING, MonitoringUtil.toState("JOB_STATE_RUNNING")); assertEquals(State.DONE, MonitoringUtil.toState("JOB_STATE_DONE")); assertEquals(State.FAILED, MonitoringUtil.toState("JOB_STATE_FAILED")); assertEquals(State.CANCELLED, MonitoringUtil.toState("JOB_STATE_CANCELLED")); assertEquals(State.UPDATED, MonitoringUtil.toState("JOB_STATE_UPDATED")); assertEquals(State.RUNNING, MonitoringUtil.toState("JOB_STATE_DRAINING")); assertEquals(State.DONE, MonitoringUtil.toState("JOB_STATE_DRAINED")); }
@Test public void testToStateWithNullReturnsUnrecognized() { assertEquals(State.UNRECOGNIZED, MonitoringUtil.toState(null)); }
@Test public void testToStateWithOtherValueReturnsUnknown() { assertEquals(State.UNRECOGNIZED, MonitoringUtil.toState("FOO_BAR_BAZ")); }