package de.effigenix.infrastructure.stub;

import de.effigenix.domain.usermanagement.Role;
import de.effigenix.domain.usermanagement.RoleId;
import de.effigenix.domain.usermanagement.RoleName;
import de.effigenix.domain.usermanagement.RoleRepository;
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 StubRoleRepository implements RoleRepository {

    private static final RepositoryError.DatabaseError STUB_ERROR =
            new RepositoryError.DatabaseError("Stub-Modus: keine Datenbankverbindung");

    @Override
    public Result<RepositoryError, Optional<Role>> findById(RoleId id) {
        return Result.failure(STUB_ERROR);
    }

    @Override
    public Result<RepositoryError, Optional<Role>> findByName(RoleName name) {
        return Result.failure(STUB_ERROR);
    }

    @Override
    public Result<RepositoryError, List<Role>> findAll() {
        return Result.failure(STUB_ERROR);
    }

    @Override
    public Result<RepositoryError, Void> save(Role role) {
        return Result.failure(STUB_ERROR);
    }

    @Override
    public Result<RepositoryError, Void> delete(Role role) {
        return Result.failure(STUB_ERROR);
    }

    @Override
    public Result<RepositoryError, Boolean> existsByName(RoleName name) {
        return Result.failure(STUB_ERROR);
    }
}
