Skip to content

Commit

Permalink
add some tests
Browse files Browse the repository at this point in the history
  • Loading branch information
ricardoc-db committed Jul 29, 2024
1 parent c7f2582 commit af7f3cf
Showing 1 changed file with 110 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,12 @@
import static org.junit.jupiter.api.Assertions.*;

import com.databricks.sdk.WorkspaceClient;
import com.databricks.sdk.core.error.platform.InvalidParameterValue;
import com.databricks.sdk.core.error.platform.ResourceDoesNotExist;
import com.databricks.sdk.integration.framework.CollectionUtils;
import com.databricks.sdk.integration.framework.EnvContext;
import com.databricks.sdk.integration.framework.EnvTest;
import com.databricks.sdk.service.jobs.BaseJob;
import com.databricks.sdk.service.jobs.ListJobsRequest;
import com.databricks.sdk.service.jobs.*;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.ExtendWith;

Expand All @@ -32,4 +32,112 @@ void getNonExistingJob(WorkspaceClient w) {
w.jobs().get(123456789);
});
}

@Test
void deleteNonExistingJob(WorkspaceClient w) {
assertThrowsExactly(
InvalidParameterValue.class,
() -> {
w.jobs().delete(123456789);
});
}

@Test
void resetNonExistingJob(WorkspaceClient w) {
assertThrowsExactly(
InvalidParameterValue.class,
() -> {
w.jobs().reset(123456789, new JobSettings());
});
}

@Test
void updateNonExistingJob(WorkspaceClient w) {
assertThrowsExactly(
InvalidParameterValue.class,
() -> {
w.jobs().update(123456789);
});
}

@Test
void runNonExistingJob(WorkspaceClient w) {
assertThrowsExactly(
InvalidParameterValue.class,
() -> {
w.jobs().runNow(123456789);
});
}

@Test
void listsRuns(WorkspaceClient w) {
Iterable<BaseRun> list = w.jobs().listRuns(new ListRunsRequest());

java.util.List<BaseRun> all = CollectionUtils.asList(list);

CollectionUtils.assertUnique(all);
}

@Test
void getNonExistingRun(WorkspaceClient w) {
assertThrowsExactly(
InvalidParameterValue.class,
() -> {
w.jobs().getRun(123456789);
});
}

@Test
void getOutputOfNonExistingRun(WorkspaceClient w) {
assertThrowsExactly(
InvalidParameterValue.class,
() -> {
w.jobs().getRunOutput(123456789);
});
}

@Test
void deleteNonExistingRun(WorkspaceClient w) {
assertThrowsExactly(
InvalidParameterValue.class,
() -> {
w.jobs().deleteRun(123456789);
});
}

@Test
void exportNonExistingRun(WorkspaceClient w) {
assertThrowsExactly(
InvalidParameterValue.class,
() -> {
w.jobs().exportRun(123456789);
});
}

@Test
void cancelingNonExistingRun(WorkspaceClient w) {
assertThrowsExactly(
InvalidParameterValue.class,
() -> {
w.jobs().cancelRun(123456789);
});
}

@Test
void cancelingAllRunsFromNonExistingJob(WorkspaceClient w) {
assertThrowsExactly(
InvalidParameterValue.class,
() -> {
w.jobs().cancelAllRuns(new CancelAllRuns().setJobId(123456789L));
});
}

@Test
void repairingANonExistingRun(WorkspaceClient w) {
assertThrowsExactly(
InvalidParameterValue.class,
() -> {
w.jobs().repairRun(123456789);
});
}
}

0 comments on commit af7f3cf

Please sign in to comment.