mirror of
https://github.com/s-frick/effigenix.git
synced 2026-03-28 14:09:34 +01:00
feat: Stub-Repositories für no-db Profil (Recipe, StorageLocation)
This commit is contained in:
parent
a132211a74
commit
7079f12475
2 changed files with 102 additions and 0 deletions
|
|
@ -0,0 +1,45 @@
|
||||||
|
package de.effigenix.infrastructure.stub;
|
||||||
|
|
||||||
|
import de.effigenix.domain.production.Recipe;
|
||||||
|
import de.effigenix.domain.production.RecipeId;
|
||||||
|
import de.effigenix.domain.production.RecipeRepository;
|
||||||
|
import de.effigenix.shared.common.RepositoryError;
|
||||||
|
import de.effigenix.shared.common.Result;
|
||||||
|
import org.springframework.context.annotation.Profile;
|
||||||
|
import org.springframework.stereotype.Repository;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Optional;
|
||||||
|
|
||||||
|
@Repository
|
||||||
|
@Profile("no-db")
|
||||||
|
public class StubRecipeRepository implements RecipeRepository {
|
||||||
|
|
||||||
|
private static final RepositoryError.DatabaseError STUB_ERROR =
|
||||||
|
new RepositoryError.DatabaseError("Stub-Modus: keine Datenbankverbindung");
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Result<RepositoryError, Optional<Recipe>> findById(RecipeId id) {
|
||||||
|
return Result.failure(STUB_ERROR);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Result<RepositoryError, List<Recipe>> findAll() {
|
||||||
|
return Result.failure(STUB_ERROR);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Result<RepositoryError, Void> save(Recipe recipe) {
|
||||||
|
return Result.failure(STUB_ERROR);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Result<RepositoryError, Void> delete(Recipe recipe) {
|
||||||
|
return Result.failure(STUB_ERROR);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Result<RepositoryError, Boolean> existsByNameAndVersion(String name, int version) {
|
||||||
|
return Result.failure(STUB_ERROR);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,57 @@
|
||||||
|
package de.effigenix.infrastructure.stub;
|
||||||
|
|
||||||
|
import de.effigenix.domain.inventory.StorageLocation;
|
||||||
|
import de.effigenix.domain.inventory.StorageLocationId;
|
||||||
|
import de.effigenix.domain.inventory.StorageLocationName;
|
||||||
|
import de.effigenix.domain.inventory.StorageLocationRepository;
|
||||||
|
import de.effigenix.domain.inventory.StorageType;
|
||||||
|
import de.effigenix.shared.common.RepositoryError;
|
||||||
|
import de.effigenix.shared.common.Result;
|
||||||
|
import org.springframework.context.annotation.Profile;
|
||||||
|
import org.springframework.stereotype.Repository;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Optional;
|
||||||
|
|
||||||
|
@Repository
|
||||||
|
@Profile("no-db")
|
||||||
|
public class StubStorageLocationRepository implements StorageLocationRepository {
|
||||||
|
|
||||||
|
private static final RepositoryError.DatabaseError STUB_ERROR =
|
||||||
|
new RepositoryError.DatabaseError("Stub-Modus: keine Datenbankverbindung");
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Result<RepositoryError, Optional<StorageLocation>> findById(StorageLocationId id) {
|
||||||
|
return Result.failure(STUB_ERROR);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Result<RepositoryError, List<StorageLocation>> findAll() {
|
||||||
|
return Result.failure(STUB_ERROR);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Result<RepositoryError, List<StorageLocation>> findByStorageType(StorageType storageType) {
|
||||||
|
return Result.failure(STUB_ERROR);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Result<RepositoryError, List<StorageLocation>> findActive() {
|
||||||
|
return Result.failure(STUB_ERROR);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Result<RepositoryError, Boolean> existsByName(StorageLocationName name) {
|
||||||
|
return Result.failure(STUB_ERROR);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Result<RepositoryError, Boolean> existsByNameAndIdNot(StorageLocationName name, StorageLocationId id) {
|
||||||
|
return Result.failure(STUB_ERROR);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Result<RepositoryError, Void> save(StorageLocation location) {
|
||||||
|
return Result.failure(STUB_ERROR);
|
||||||
|
}
|
||||||
|
}
|
||||||
Loading…
Add table
Add a link
Reference in a new issue