mirror of
https://github.com/cryptomator/cryptomator.git
synced 2026-05-18 10:41:26 +00:00
enrich DummyChecks with some mock results
This commit is contained in:
@@ -6,6 +6,7 @@ import org.cryptomator.cryptofs.health.api.HealthCheck;
|
||||
import org.cryptomator.cryptolib.api.Cryptor;
|
||||
import org.cryptomator.cryptolib.api.Masterkey;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.nio.file.Path;
|
||||
import java.util.function.Consumer;
|
||||
|
||||
@@ -19,6 +20,12 @@ public class DummyHealthChecks {
|
||||
@Override
|
||||
public void check(Path path, VaultConfig vaultConfig, Masterkey masterkey, Cryptor cryptor, Consumer<DiagnosticResult> consumer) {
|
||||
// no-op
|
||||
try {
|
||||
Thread.sleep(3000);
|
||||
} catch (InterruptedException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
consumer.accept(() -> DiagnosticResult.Severity.GOOD);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -27,6 +34,7 @@ public class DummyHealthChecks {
|
||||
@Override
|
||||
public void check(Path path, VaultConfig vaultConfig, Masterkey masterkey, Cryptor cryptor, Consumer<DiagnosticResult> consumer) {
|
||||
// no-op
|
||||
throw new RuntimeException("asd");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -35,6 +43,35 @@ public class DummyHealthChecks {
|
||||
@Override
|
||||
public void check(Path path, VaultConfig vaultConfig, Masterkey masterkey, Cryptor cryptor, Consumer<DiagnosticResult> consumer) {
|
||||
// no-op
|
||||
consumer.accept(() -> DiagnosticResult.Severity.GOOD);
|
||||
consumer.accept(() -> DiagnosticResult.Severity.CRITICAL);
|
||||
consumer.accept(() -> DiagnosticResult.Severity.INFO);
|
||||
consumer.accept(new DiagnosticResult() {
|
||||
@Override
|
||||
public Severity getSeverity() {
|
||||
return Severity.WARN;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void fix(Path pathToVault, VaultConfig config, Masterkey masterkey, Cryptor cryptor) throws IOException {
|
||||
try {
|
||||
Thread.sleep(3000);
|
||||
} catch (InterruptedException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
});
|
||||
consumer.accept(new DiagnosticResult() {
|
||||
@Override
|
||||
public Severity getSeverity() {
|
||||
return Severity.WARN;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void fix(Path pathToVault, VaultConfig config, Masterkey masterkey, Cryptor cryptor) throws IOException {
|
||||
throw new IOException("asd");
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -27,6 +27,7 @@ import javafx.scene.Scene;
|
||||
import javafx.stage.Modality;
|
||||
import javafx.stage.Stage;
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Optional;
|
||||
@@ -68,7 +69,13 @@ abstract class HealthCheckModule {
|
||||
@Provides
|
||||
@HealthCheckScoped
|
||||
static List<Check> provideAvailableChecks() {
|
||||
return HealthCheck.allChecks().stream().map(Check::new).toList();
|
||||
//return HealthCheck.allChecks().stream().map(Check::new).toList();
|
||||
//TODO: remove below lines and uncomment above one
|
||||
var realChecks = HealthCheck.allChecks().stream().map(Check::new).toList();
|
||||
var tmp = new ArrayList<>(realChecks);
|
||||
var tmp2 = List.of(new DummyHealthChecks.DummyCheck1(), new DummyHealthChecks.DummyCheck2(), new DummyHealthChecks.DummyCheck3()).stream().map(Check::new).toList();
|
||||
tmp.addAll(tmp2);
|
||||
return tmp;
|
||||
}
|
||||
|
||||
@Provides
|
||||
|
||||
Reference in New Issue
Block a user