### Question:
GrpcStatusResponseToDatalakeDrStatusResponseConverter { public DatalakeDrStatusResponse convert(datalakeDRProto.BackupDatalakeStatusResponse response) { return new DatalakeDrStatusResponse( DatalakeDrStatusResponse.State.valueOf(response.getOverallState()), Optional.ofNullable(response.getFailureReason()) ); }  DatalakeDrStatusResponse convert(datalakeDRProto.BackupDatalakeStatusResponse response); DatalakeDrStatusResponse convert(datalakeDRProto.RestoreDatalakeStatusResponse response);  }### Answer:
@Test public void testSuccessfulBackup() { datalakeDRProto.BackupDatalakeStatusResponse.Builder builder = datalakeDRProto.BackupDatalakeStatusResponse.newBuilder() .setOverallState("SUCCESSFUL") .setFailureReason("null"); DatalakeDrStatusResponse response = underTest.convert(builder.build()); assertEquals(DatalakeDrStatusResponse.State.SUCCESSFUL, response.getState()); assertEquals(DatalakeDrStatusResponse.NO_FAILURES, response.getFailureReason()); assert response.isComplete(); }
@Test public void testInProgressBackup() { datalakeDRProto.BackupDatalakeStatusResponse.Builder builder = datalakeDRProto.BackupDatalakeStatusResponse.newBuilder() .setOverallState("IN_PROGRESS"); DatalakeDrStatusResponse response = underTest.convert(builder.build()); assertEquals(DatalakeDrStatusResponse.State.IN_PROGRESS, response.getState()); assert !response.isComplete(); }
@Test public void testFailedBackup() { datalakeDRProto.BackupDatalakeStatusResponse.Builder builder = datalakeDRProto.BackupDatalakeStatusResponse.newBuilder() .setOverallState("FAILED") .setFailureReason(FAILURE_REASON); DatalakeDrStatusResponse response = underTest.convert(builder.build()); assertEquals(DatalakeDrStatusResponse.State.FAILED, response.getState()); assertEquals(FAILURE_REASON, response.getFailureReason()); assert response.isComplete(); }
@Test public void testInvalidBackupStatus() { datalakeDRProto.BackupDatalakeStatusResponse.Builder builder = datalakeDRProto.BackupDatalakeStatusResponse.newBuilder() .setOverallState("INVALID_STAUS"); assertThrows(IllegalArgumentException.class, () -> { underTest.convert(builder.build()); }); }
@Test public void testSuccessfulRestore() { datalakeDRProto.RestoreDatalakeStatusResponse.Builder builder = datalakeDRProto.RestoreDatalakeStatusResponse.newBuilder() .setOverallState("SUCCESSFUL") .setFailureReason("null"); DatalakeDrStatusResponse response = underTest.convert(builder.build()); assertEquals(DatalakeDrStatusResponse.State.SUCCESSFUL, response.getState()); assertEquals(DatalakeDrStatusResponse.NO_FAILURES, response.getFailureReason()); assert response.isComplete(); }
@Test public void testInProgressRestore() { datalakeDRProto.RestoreDatalakeStatusResponse.Builder builder = datalakeDRProto.RestoreDatalakeStatusResponse.newBuilder() .setOverallState("IN_PROGRESS"); DatalakeDrStatusResponse response = underTest.convert(builder.build()); assertEquals(DatalakeDrStatusResponse.State.IN_PROGRESS, response.getState()); assert !response.isComplete(); }
@Test public void testFailedRestore() { datalakeDRProto.RestoreDatalakeStatusResponse.Builder builder = datalakeDRProto.RestoreDatalakeStatusResponse.newBuilder() .setOverallState("FAILED") .setFailureReason(FAILURE_REASON); DatalakeDrStatusResponse response = underTest.convert(builder.build()); assertEquals(DatalakeDrStatusResponse.State.FAILED, response.getState()); assertEquals(FAILURE_REASON, response.getFailureReason()); assert response.isComplete(); }
@Test public void testInvalidRestoreStatus() { datalakeDRProto.RestoreDatalakeStatusResponse.Builder builder = datalakeDRProto.RestoreDatalakeStatusResponse.newBuilder() .setOverallState("INVALID_STAUS"); assertThrows(IllegalArgumentException.class, () -> { underTest.convert(builder.build()); }); }