mirror of
https://github.com/signalapp/Signal-Android.git
synced 2026-04-21 17:29:32 +01:00
Convert JobManager tests to kotlin.
This commit is contained in:
@@ -1,51 +0,0 @@
|
||||
package org.thoughtcrime.securesms.jobmanager.persistence;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
|
||||
import java.util.Locale;
|
||||
import java.util.Objects;
|
||||
|
||||
public final class ConstraintSpec {
|
||||
|
||||
private final String jobSpecId;
|
||||
private final String factoryKey;
|
||||
private final boolean memoryOnly;
|
||||
|
||||
public ConstraintSpec(@NonNull String jobSpecId, @NonNull String factoryKey, boolean memoryOnly) {
|
||||
this.jobSpecId = jobSpecId;
|
||||
this.factoryKey = factoryKey;
|
||||
this.memoryOnly = memoryOnly;
|
||||
}
|
||||
|
||||
public String getJobSpecId() {
|
||||
return jobSpecId;
|
||||
}
|
||||
|
||||
public String getFactoryKey() {
|
||||
return factoryKey;
|
||||
}
|
||||
|
||||
public boolean isMemoryOnly() {
|
||||
return memoryOnly;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
if (this == o) return true;
|
||||
if (o == null || getClass() != o.getClass()) return false;
|
||||
ConstraintSpec that = (ConstraintSpec) o;
|
||||
return Objects.equals(jobSpecId, that.jobSpecId) &&
|
||||
Objects.equals(factoryKey, that.factoryKey) &&
|
||||
memoryOnly == that.memoryOnly;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return Objects.hash(jobSpecId, factoryKey, memoryOnly);
|
||||
}
|
||||
|
||||
@Override
|
||||
public @NonNull String toString() {
|
||||
return String.format(Locale.US, "jobSpecId: JOB::%s | factoryKey: %s | memoryOnly: %b", jobSpecId, factoryKey, memoryOnly);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
package org.thoughtcrime.securesms.jobmanager.persistence
|
||||
|
||||
data class ConstraintSpec(
|
||||
val jobSpecId: String,
|
||||
val factoryKey: String,
|
||||
val isMemoryOnly: Boolean
|
||||
) {
|
||||
override fun toString(): String {
|
||||
return "jobSpecId: JOB::$jobSpecId | factoryKey: $factoryKey | memoryOnly: $isMemoryOnly"
|
||||
}
|
||||
}
|
||||
@@ -2,7 +2,7 @@ package org.thoughtcrime.securesms.jobmanager.persistence
|
||||
|
||||
import java.util.Locale
|
||||
|
||||
class DependencySpec(
|
||||
data class DependencySpec(
|
||||
val jobId: String,
|
||||
val dependsOnJobId: String,
|
||||
val isMemoryOnly: Boolean
|
||||
|
||||
@@ -1,53 +0,0 @@
|
||||
package org.thoughtcrime.securesms.jobmanager.persistence;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
|
||||
public final class FullSpec {
|
||||
|
||||
private final JobSpec jobSpec;
|
||||
private final List<ConstraintSpec> constraintSpecs;
|
||||
private final List<DependencySpec> dependencySpecs;
|
||||
|
||||
public FullSpec(@NonNull JobSpec jobSpec,
|
||||
@NonNull List<ConstraintSpec> constraintSpecs,
|
||||
@NonNull List<DependencySpec> dependencySpecs)
|
||||
{
|
||||
this.jobSpec = jobSpec;
|
||||
this.constraintSpecs = constraintSpecs;
|
||||
this.dependencySpecs = dependencySpecs;
|
||||
}
|
||||
|
||||
public @NonNull JobSpec getJobSpec() {
|
||||
return jobSpec;
|
||||
}
|
||||
|
||||
public @NonNull List<ConstraintSpec> getConstraintSpecs() {
|
||||
return constraintSpecs;
|
||||
}
|
||||
|
||||
public @NonNull List<DependencySpec> getDependencySpecs() {
|
||||
return dependencySpecs;
|
||||
}
|
||||
|
||||
public boolean isMemoryOnly() {
|
||||
return jobSpec.isMemoryOnly();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
if (this == o) return true;
|
||||
if (o == null || getClass() != o.getClass()) return false;
|
||||
FullSpec fullSpec = (FullSpec) o;
|
||||
return Objects.equals(jobSpec, fullSpec.jobSpec) &&
|
||||
Objects.equals(constraintSpecs, fullSpec.constraintSpecs) &&
|
||||
Objects.equals(dependencySpecs, fullSpec.dependencySpecs);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return Objects.hash(jobSpec, constraintSpecs, dependencySpecs);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
package org.thoughtcrime.securesms.jobmanager.persistence
|
||||
|
||||
data class FullSpec(
|
||||
val jobSpec: JobSpec,
|
||||
val constraintSpecs: List<ConstraintSpec>,
|
||||
val dependencySpecs: List<DependencySpec>
|
||||
) {
|
||||
val isMemoryOnly: Boolean
|
||||
get() = jobSpec.isMemoryOnly
|
||||
}
|
||||
@@ -39,8 +39,8 @@ class FastJobStorage(private val jobDatabase: JobDatabase) : JobStorage {
|
||||
|
||||
for (fullSpec in fullSpecs) {
|
||||
jobs += fullSpec.jobSpec
|
||||
constraintsByJobId[fullSpec.jobSpec.id] = fullSpec.constraintSpecs
|
||||
dependenciesByJobId[fullSpec.jobSpec.id] = fullSpec.dependencySpecs
|
||||
constraintsByJobId[fullSpec.jobSpec.id] = fullSpec.constraintSpecs.toMutableList()
|
||||
dependenciesByJobId[fullSpec.jobSpec.id] = fullSpec.dependencySpecs.toMutableList()
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user