Skip to content

Commit

Permalink
fix test
Browse files Browse the repository at this point in the history
  • Loading branch information
cgardens committed Jun 19, 2022
1 parent bcac051 commit 1fe0074
Show file tree
Hide file tree
Showing 4 changed files with 37 additions and 10 deletions.
1 change: 1 addition & 0 deletions airbyte-api/src/main/openapi/config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3733,6 +3733,7 @@ components:
$ref: "#/components/schemas/ResetConfig"
ResetConfig:
type: object
description: contains information about how a reset was configured. only populated if the job was a reset.
properties:
streamsToReset:
type: array
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ public static JobWithAttemptsRead getJobWithAttemptsRead(final Job job) {
* @return api representation of reset config
*/
private static Optional<ResetConfig> extractResetConfigIfReset(final Job job) {
if (job.getConfigType() == ConfigType.SYNC) {
if (job.getConfigType() == ConfigType.RESET_CONNECTION) {
return Optional.ofNullable(
new ResetConfig().streamsToReset(job.getConfig().getResetConnection().getResetSourceConfiguration().getStreamsToReset()
.stream()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
import io.airbyte.api.model.generated.JobRead;
import io.airbyte.api.model.generated.JobWithAttemptsRead;
import io.airbyte.api.model.generated.LogRead;
import io.airbyte.api.model.generated.ResetConfig;
import io.airbyte.api.model.generated.SourceDefinitionRead;
import io.airbyte.api.model.generated.StreamDescriptor;
import io.airbyte.commons.enums.Enums;
Expand All @@ -37,7 +38,9 @@
import io.airbyte.config.JobConfig.ConfigType;
import io.airbyte.config.JobOutput;
import io.airbyte.config.JobOutput.OutputType;
import io.airbyte.config.JobResetConnectionConfig;
import io.airbyte.config.JobSyncConfig;
import io.airbyte.config.ResetSourceConfiguration;
import io.airbyte.config.StandardSyncOutput;
import io.airbyte.config.StandardSyncSummary;
import io.airbyte.config.StreamSyncStats;
Expand All @@ -52,6 +55,7 @@
import io.airbyte.scheduler.models.JobStatus;
import java.nio.file.Path;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.Optional;
import java.util.UUID;
Expand Down Expand Up @@ -112,9 +116,6 @@ class JobConverterTest {
.job(new JobRead()
.id(JOB_ID)
.configId(JOB_CONFIG_ID)
.streams(List.of(
new StreamDescriptor().name("users"),
new StreamDescriptor().name("accounts")))
.status(io.airbyte.api.model.generated.JobStatus.RUNNING)
.configType(JobConfigType.SYNC)
.createdAt(CREATED_AT)
Expand Down Expand Up @@ -204,31 +205,56 @@ public void setUp() {
}

@Test
public void testGetJobInfoRead() {
void testGetJobInfoRead() {
assertEquals(JOB_INFO, jobConverter.getJobInfoRead(job));
}

@Test
public void testGetDebugJobInfoRead() {
void testGetDebugJobInfoRead() {
assertEquals(JOB_DEBUG_INFO, JobConverter.getDebugJobInfoRead(JOB_INFO, sourceDefinitionRead, destinationDefinitionRead, airbyteVersion));
}

@Test
public void testGetJobWithAttemptsRead() {
void testGetJobWithAttemptsRead() {
assertEquals(JOB_WITH_ATTEMPTS_READ, JobConverter.getJobWithAttemptsRead(job));
}

@Test
public void testGetJobRead() {
void testGetJobRead() {
final JobWithAttemptsRead jobReadActual = JobConverter.getJobWithAttemptsRead(job);
assertEquals(JOB_WITH_ATTEMPTS_READ, jobReadActual);
}

@Test
public void testEnumConversion() {
void testEnumConversion() {
assertTrue(Enums.isCompatible(JobConfig.ConfigType.class, JobConfigType.class));
assertTrue(Enums.isCompatible(JobStatus.class, io.airbyte.api.model.generated.JobStatus.class));
assertTrue(Enums.isCompatible(AttemptStatus.class, io.airbyte.api.model.generated.AttemptStatus.class));
}

// this test intentionally only looks at the reset config as the rest is the same here.
@Test
void testRestIncludesResetConfig() {
final JobConfig resetConfig = new JobConfig()
.withConfigType(ConfigType.RESET_CONNECTION)
.withResetConnection(new JobResetConnectionConfig().withResetSourceConfiguration(new ResetSourceConfiguration().withStreamsToReset(List.of(
new io.airbyte.config.StreamDescriptor().withName("users"),
new io.airbyte.config.StreamDescriptor().withName("accounts")))));
final Job resetJob = new Job(
JOB_ID,
ConfigType.RESET_CONNECTION,
JOB_CONFIG_ID,
resetConfig,
Collections.emptyList(),
JobStatus.SUCCEEDED,
CREATED_AT,
CREATED_AT,
CREATED_AT);

final ResetConfig expectedResetConfig = new ResetConfig().streamsToReset(List.of(
new StreamDescriptor().name("users"),
new StreamDescriptor().name("accounts")));
assertEquals(expectedResetConfig, jobConverter.getJobInfoRead(resetJob).getJob().getResetConfig());
}

}
2 changes: 1 addition & 1 deletion docs/reference/api/generated-api-html/index.html