<commit_before>package de.fau.amos.virtualledger.server.banking.adorsys.api.bankAccountEndpoint;

import java.util.*;

import javax.enterprise.context.ApplicationScoped;
import javax.inject.Inject;

import de.fau.amos.virtualledger.dtos.BankAccountBookings;
import de.fau.amos.virtualledger.server.banking.adorsys.api.BankingApiDummy;
import de.fau.amos.virtualledger.server.banking.adorsys.api.bankAccessEndpoint.DummyBankAccessEndpoint;
import de.fau.amos.virtualledger.server.banking.model.BankAccountBalanceBankingModel;
import de.fau.amos.virtualledger.server.banking.model.BankAccountBankingModel;
import de.fau.amos.virtualledger.server.banking.model.BankingException;
import de.fau.amos.virtualledger.server.banking.model.BookingModel;

/**
 * Created by Georg on 18.05.2017.
 */
@ApplicationScoped
@BankingApiDummy
public class DummyBankAccountEndpoint implements BankAccountEndpoint {

    DummyBankAccessEndpoint dummyBankAccessEndpoint;

    Map<String, List<BankAccountBankingModel>> bankAccountMap = new HashMap<String, List<BankAccountBankingModel>>();
    int numberBankAccount = 0;

    Map<BankAccountBankingModel, List<BookingModel>> bankBookingMap = new HashMap<BankAccountBankingModel, List<BookingModel>>();

    Random randomGenerator = new Random(System.nanoTime());

    @Inject
    public DummyBankAccountEndpoint(@BankingApiDummy DummyBankAccessEndpoint dummyBankAccessEndpoint)
    {
        this.dummyBankAccessEndpoint = dummyBankAccessEndpoint;
    }
    protected DummyBankAccountEndpoint()    { }


    @Override
    public List<BankAccountBankingModel> getBankAccounts(String userId, String bankingAccessId) throws BankingException {
        if(!dummyBankAccessEndpoint.existsBankAccess(bankingAccessId))
        {
            // throw new BankingException("Dummy found no existing BankAccess for Operation getBankAccounts!");
            // inconsistency -> on app can be accesses persisted that are not in local storage of server
            return new ArrayList<BankAccountBankingModel>(); // TODO? better solution?
        }
        if(!bankAccountMap.containsKey(bankingAccessId))
        {
            this.generateDummyBankAccountModels(bankingAccessId);<commit_msg>- made bookings generation in dummy on server more predictable by setting random seed to 0<commit_after>package de.fau.amos.virtualledger.server.banking.adorsys.api.bankAccountEndpoint;

import java.util.*;

import javax.enterprise.context.ApplicationScoped;
import javax.inject.Inject;

import de.fau.amos.virtualledger.dtos.BankAccountBookings;
import de.fau.amos.virtualledger.server.banking.adorsys.api.BankingApiDummy;
import de.fau.amos.virtualledger.server.banking.adorsys.api.bankAccessEndpoint.DummyBankAccessEndpoint;
import de.fau.amos.virtualledger.server.banking.model.BankAccountBalanceBankingModel;
import de.fau.amos.virtualledger.server.banking.model.BankAccountBankingModel;
import de.fau.amos.virtualledger.server.banking.model.BankingException;
import de.fau.amos.virtualledger.server.banking.model.BookingModel;

/**
 * Created by Georg on 18.05.2017.
 */
@ApplicationScoped
@BankingApiDummy
public class DummyBankAccountEndpoint implements BankAccountEndpoint {

    DummyBankAccessEndpoint dummyBankAccessEndpoint;

    Map<String, List<BankAccountBankingModel>> bankAccountMap = new HashMap<String, List<BankAccountBankingModel>>();
    int numberBankAccount = 0;

    Map<BankAccountBankingModel, List<BookingModel>> bankBookingMap = new HashMap<BankAccountBankingModel, List<BookingModel>>();

    // Seed "0" for predictability
    Random randomGenerator = new Random(0);

    @Inject
    public DummyBankAccountEndpoint(@BankingApiDummy DummyBankAccessEndpoint dummyBankAccessEndpoint)
    {
        this.dummyBankAccessEndpoint = dummyBankAccessEndpoint;
    }
    protected DummyBankAccountEndpoint()    { }


    @Override
    public List<BankAccountBankingModel> getBankAccounts(String userId, String bankingAccessId) throws BankingException {
        if(!dummyBankAccessEndpoint.existsBankAccess(bankingAccessId))
        {
            // throw new BankingException("Dummy found no existing BankAccess for Operation getBankAccounts!");
            // inconsistency -> on app can be accesses persisted that are not in local storage of server
            return new ArrayList<BankAccountBankingModel>(); // TODO? better solution?
        }
        if(!bankAccountMap.containsKey(bankingAccessId))
        {
            this.generateDummyBankAccountModels(bankingAccessId);
{'fraction_non_alphanumeric': 0.08470066518847007, 'fraction_numerical': 0.004656319290465632, 'mean_word_length': 4.896732026143791, 'pattern_counts': {'":': 0, '<': 23, '<?xml version=': 0, '>': 25, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4160465', 'n_tokens_mistral': 1298, 'n_tokens_neox': 1261, 'n_words': 232}