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

import de.fau.amos.virtualledger.server.banking.adorsys.api.BankingApiDummy;
import de.fau.amos.virtualledger.server.banking.model.BankAccessBankingModel;
import de.fau.amos.virtualledger.server.banking.model.BankingException;

import javax.enterprise.context.RequestScoped;
import java.util.ArrayList;
import java.util.List;

/**
 * Created by Georg on 18.05.2017.
 */
@RequestScoped @BankingApiDummy
public class DummyBankAccessEndpoint implements BankAccessEndpoint {


    @Override
    public List<BankAccessBankingModel> getBankAccesses(String userId) throws BankingException {
        List<BankAccessBankingModel> dummyData = new ArrayList<BankAccessBankingModel>();
        dummyData.add(this.generateDummyBankAccessModel(1));
        dummyData.add(this.generateDummyBankAccessModel(2));
        return dummyData;
    }

    @Override
    public void addBankAccess(String userId, BankAccessBankingModel bankAccess)  throws BankingException {
        return;
    }

    /**
     * generates a BankAccessBankingModel with dummy data
     * @param id that makes multiple dummies different via a postfix in every attribute
     * @return
     */
    private BankAccessBankingModel generateDummyBankAccessModel(int id)
    {
        BankAccessBankingModel dummyModel = new BankAccessBankingModel();
        dummyModel.setBankName("Dummy Bank " + id);
        dummyModel.setBankLogin("Dummy login " + id);
        dummyModel.setBankCode("Dummy code " + id);
        dummyModel.setPassportState("Dummy passport state " + id);
        dummyModel.setId("Dummy1 " + id);
        dummyModel.setUserId("DummyUser " + id);
        return dummyModel;<commit_msg>- refactored DummyBankAccessEndpoint to store transient the bankAccesses; is deleted after server restart<commit_after>package de.fau.amos.virtualledger.server.banking.adorsys.api.bankAccessEndpoint;

import de.fau.amos.virtualledger.server.banking.adorsys.api.BankingApiDummy;
import de.fau.amos.virtualledger.server.banking.model.BankAccessBankingModel;
import de.fau.amos.virtualledger.server.banking.model.BankingException;

import javax.enterprise.context.ApplicationScoped;
import javax.enterprise.context.RequestScoped;
import java.util.ArrayList;
import java.util.List;

/**
 * Created by Georg on 18.05.2017.
 */
@ApplicationScoped
@BankingApiDummy
public class DummyBankAccessEndpoint implements BankAccessEndpoint {

    private List<BankAccessBankingModel> bankingModels = new ArrayList<BankAccessBankingModel>();
    private int number = 0;

    @Override
    public List<BankAccessBankingModel> getBankAccesses(String userId) throws BankingException {
        return bankingModels;
    }

    @Override
    public void addBankAccess(String userId, BankAccessBankingModel bankAccess)  throws BankingException {

        BankAccessBankingModel bankAccessBankingModel = new BankAccessBankingModel();
        bankAccessBankingModel.setId("DummyID" + number + "_" + System.nanoTime());
        bankAccessBankingModel.setBankLogin(bankAccess.getBankLogin());
        bankAccessBankingModel.setBankCode(bankAccess.getBankCode());
        bankAccessBankingModel.setUserId(userId);
        bankAccessBankingModel.setBankName("TestBank" + number);
        bankAccessBankingModel.setPin(null);
        bankAccessBankingModel.setPassportState("dummyPassportState");

        this.bankingModels.add(bankAccessBankingModel);
        number ++;
{'fraction_non_alphanumeric': 0.08724256292906178, 'fraction_numerical': 0.005720823798627002, 'mean_word_length': 4.524486571879937, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 9, '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': '146776', 'n_tokens_mistral': 1022, 'n_tokens_neox': 998, 'n_words': 180}