Skip to content

Commit

Permalink
Google Java Format
Browse files Browse the repository at this point in the history
  • Loading branch information
github-actions authored and doks5 committed Oct 26, 2023
1 parent ccc953d commit 366c703
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 18 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -215,7 +215,9 @@ private Predicate<V2DataJob> computeSearch(
private List<V2DataJob> populateDeployments(
List<V2DataJob> allDataJob, Map<String, DataJob> dataJobs) {
Map<String, JobDeploymentStatus> deploymentStatuses =
(dataJobDeploymentPropertiesConfig.getReadDataSource().equals(ReadFrom.DB)) ? readJobDeploymentsFromDb() : readJobDeploymentsFromK8s();
(dataJobDeploymentPropertiesConfig.getReadDataSource().equals(ReadFrom.DB))
? readJobDeploymentsFromDb()
: readJobDeploymentsFromK8s();

allDataJob.forEach(
dataJob -> {
Expand All @@ -236,22 +238,22 @@ private List<V2DataJob> populateDeployments(

private Map<String, JobDeploymentStatus> readJobDeploymentsFromK8s() {
return deploymentService.readDeployments().stream()
.collect(Collectors.toMap(JobDeploymentStatus::getDataJobName, cronJob -> cronJob));
.collect(Collectors.toMap(JobDeploymentStatus::getDataJobName, cronJob -> cronJob));
}

private Map<String, JobDeploymentStatus> readJobDeploymentsFromDb() {
var deployments = StreamSupport.stream(actualJobDeploymentRepository.findAll().spliterator(), false)
.collect(Collectors.toMap(ActualDataJobDeployment::getDataJobName,
cronjob -> cronjob));
var deployments =
StreamSupport.stream(actualJobDeploymentRepository.findAll().spliterator(), false)
.collect(Collectors.toMap(ActualDataJobDeployment::getDataJobName, cronjob -> cronjob));

return deployments.entrySet().stream()
.collect(Collectors.toMap(
Map.Entry::getKey,
entry -> convertToJobDeploymentStatus(entry.getValue())
));
.collect(
Collectors.toMap(
Map.Entry::getKey, entry -> convertToJobDeploymentStatus(entry.getValue())));
}

private JobDeploymentStatus convertToJobDeploymentStatus(ActualDataJobDeployment deploymentStatus) {
private JobDeploymentStatus convertToJobDeploymentStatus(
ActualDataJobDeployment deploymentStatus) {
JobDeploymentStatus jobDeploymentStatus = new JobDeploymentStatus();
jobDeploymentStatus.setDataJobName(deploymentStatus.getDataJobName());
jobDeploymentStatus.setPythonVersion(deploymentStatus.getPythonVersion());
Expand All @@ -260,7 +262,8 @@ private JobDeploymentStatus convertToJobDeploymentStatus(ActualDataJobDeployment
jobDeploymentStatus.setLastDeployedBy(deploymentStatus.getLastDeployedBy());
jobDeploymentStatus.setLastDeployedDate(deploymentStatus.getLastDeployedDate().toString());
jobDeploymentStatus.setResources(getDataJobResources(deploymentStatus.getResources()));
// The ActualDataJobDeployment does not have a mode attribute, which is required by the JobDeploymentStatus,
// The ActualDataJobDeployment does not have a mode attribute, which is required by the
// JobDeploymentStatus,
// so we need to set something in order to avoid errors.
jobDeploymentStatus.setMode("release");

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,12 @@ public void before() {
new JobFieldStrategyFactory(collectSupportedFieldStrategies());
GraphQLDataFetchers graphQLDataFetchers =
new GraphQLDataFetchers(
strategyFactory, jobsRepository, deploymentService, executionDataFetcher, actualJobDeploymentRepository, dataJobDeploymentPropertiesConfig);
strategyFactory,
jobsRepository,
deploymentService,
executionDataFetcher,
actualJobDeploymentRepository,
dataJobDeploymentPropertiesConfig);
findDataJobs = graphQLDataFetchers.findAllAndBuildDataJobPage();
}

Expand Down Expand Up @@ -257,7 +262,7 @@ void testPopulateDeployments_readFromDB() throws Exception {
when(dataFetchingEnvironment.getArgument("pageSize")).thenReturn(100);
when(dataFetchingEnvironment.getSelectionSet()).thenReturn(dataFetchingFieldSelectionSet);
when(dataFetchingFieldSelectionSet.contains(JobFieldStrategyBy.DEPLOYMENT.getPath()))
.thenReturn(true);
.thenReturn(true);

DataJobPage dataJobPage = (DataJobPage) findDataJobs.get(dataFetchingEnvironment);

Expand All @@ -271,10 +276,10 @@ void testPopulateDeployments_readFromDB() throws Exception {
var job4 = (V2DataJob) dataJobPage.getContent().get(3);
assertThat(job4.getDeployments()).hasSize(1);
assertThat(job4.getDeployments().get(0).getLastExecutionStatus())
.isEqualTo(DataJobExecution.StatusEnum.SUCCEEDED);
.isEqualTo(DataJobExecution.StatusEnum.SUCCEEDED);
assertThat(job4.getDeployments().get(0).getLastExecutionTime())
.isEqualTo(OffsetDateTime.of(2000, 1, 1, 0, 0, 0, 0, ZoneOffset.UTC));
assertThat(job4.getDeployments().get(0).getLastExecutionDuration()).isEqualTo(1000);
.isNull();
assertThat(job4.getDeployments().get(0).getLastExecutionDuration()).isEqualTo(0);
assertThat(job4.getDeployments().get(0).getJobPythonVersion()).isEqualTo("3.9-secure");
}

Expand Down Expand Up @@ -500,12 +505,14 @@ private JobDeploymentStatus mockSampleDeployment(String jobName, boolean enabled
return status;
}

private ActualDataJobDeployment mockSampleActualJobDeployment(String jobName, boolean enabled, String pythonVersion) {
private ActualDataJobDeployment mockSampleActualJobDeployment(
String jobName, boolean enabled, String pythonVersion) {
ActualDataJobDeployment actualJobDeployment = new ActualDataJobDeployment();
actualJobDeployment.setDataJobName(jobName);
actualJobDeployment.setEnabled(enabled);
actualJobDeployment.setPythonVersion(pythonVersion);
actualJobDeployment.setLastDeployedDate(OffsetDateTime.of(2023, 10, 25, 16, 30, 42, 42, ZoneOffset.UTC));
actualJobDeployment.setLastDeployedDate(
OffsetDateTime.of(2023, 10, 25, 16, 30, 42, 42, ZoneOffset.UTC));

DataJobDeploymentResources resources = new DataJobDeploymentResources();
resources.setCpuLimitCores(1f);
Expand Down

0 comments on commit 366c703

Please sign in to comment.