Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*
- * To change this license header, choose License Headers in Project Properties.
- * To change this template file, choose Tools | Templates
- * and open the template in the editor.
- */
- package utils;
- import java.io.FileNotFoundException;
- import java.util.HashMap;
- import java.util.HashSet;
- import java.util.Map;
- import java.util.Set;
- import org.junit.Test;
- import static org.junit.Assert.*;
- import projetoesinf.Cidadao;
- import projetoesinf.Financas;
- import projetoesinf.Reparticao;
- import projetoesinf.Senha;
- /**
- *
- * @author João
- */
- public class ReadFileIT {
- public ReadFileIT() {
- }
- @Test
- public void testReadFileReparticoes() throws Exception {
- System.out.println("readFileReparticoes");
- ReadFile instance = new ReadFile();
- DoublyLinkedList<Reparticao> result = instance.readFileReparticoes("fx_repartições");
- DoublyLinkedList<Reparticao> expResult = new DoublyLinkedList<>();
- String[] listaServicos1 = {"A", "C", "D"};
- expResult.addLast(new Reparticao("Porto", 1234, "4200", listaServicos1));
- String[] listaServicos2 = {"A", "B"};
- expResult.addLast(new Reparticao("Maia", 1235, "4470", listaServicos2));
- assertEquals(expResult, result);
- }
- @Test
- public void testReadFileCidadaos() throws Exception {
- System.out.println("readFileCidadaos");
- ReadFile instance = new ReadFile();
- Map<Reparticao, Set<Cidadao>> map = new HashMap<>();
- DoublyLinkedList<Reparticao> dll = instance.readFileReparticoes("fx_repartições");
- Map<Reparticao, Set<Cidadao>> result = instance.readFileCidadaos(map, dll, "fx_cidadaos");
- Map<Reparticao, Set<Cidadao>> expResult = new HashMap<>();
- String[] listaServicos1 = {"A", "C", "D"};
- Reparticao rep1 = new Reparticao("Porto", 1234, "4200", listaServicos1);
- String[] listaServicos2 = {"A", "B"};
- Reparticao rep2 = new Reparticao("Maia", 1235, "4470", listaServicos2);
- Cidadao cid1 = new Cidadao("Ana", "ana@gmail.com", 111222333, "4200-072", 1234);
- Cidadao cid2 = new Cidadao("Berta", "berta@gmail.com", 223344, "4200-071", 1234);
- Cidadao cid3 = new Cidadao("Manuel", "manuel@gmail.com", 584769, "4715-357", 5762);
- Set<Cidadao> set1 = new HashSet<>();
- set1.add(cid1);
- set1.add(cid2);
- Set<Cidadao> set2 = new HashSet<>();
- set2.add(cid3);
- expResult.put(rep1, set1);
- expResult.put(rep2, set2);
- assertTrue("O teste falhou", expResult.equals(result));
- }
- @Test
- public void testReadFileSenhas() throws Exception {
- System.out.println("readFileSenhas");
- ReadFile instance = new ReadFile();
- Map<Reparticao, Set<Cidadao>> map1 = new HashMap<>();
- Map<Cidadao, Set<Senha>> map2 = new HashMap<>();
- DoublyLinkedList<Reparticao> dll = instance.readFileReparticoes("fx_repartições");
- Map<Reparticao, Set<Cidadao>> map3 = instance.readFileCidadaos(map1, dll, "fx_cidadaos");
- Map<Cidadao, Set<Senha>> result = instance.readFileSenhas(map2, map3, dll, "fx_senhas");
- Map<Cidadao, Set<Senha>> expResult = new HashMap<>();
- Cidadao cid1 = new Cidadao("Ana", "ana@gmail.com", 111222333, "4200-072", 1234);
- Cidadao cid2 = new Cidadao("Berta", "berta@gmail.com", 223344, "4200-071", 1234);
- Cidadao cid3 = new Cidadao("Manuel", "manuel@gmail.com", 584769, "4715-357", 5762);
- Set<Senha> set1 = new HashSet<>();
- set1.add(new Senha("A", 1));
- set1.add(new Senha("C", 2));
- Set<Senha> set2 = new HashSet<>();
- set2.add(new Senha("A", 2));
- set2.add(new Senha("C", 1));
- set2.add(new Senha("D", 1));
- Set<Senha> set3 = new HashSet<>();
- set3.add(new Senha("A", 1));
- set3.add(new Senha("B", 1));
- expResult.put(cid1, set1);
- expResult.put(cid2, set2);
- expResult.put(cid3, set3);
- assertTrue("O teste falhou", expResult.equals(result));
- }
- @Test
- public void testRepMaisProx() throws Exception {
- System.out.println("repMaisProx");
- ReadFile rf = new ReadFile();
- DoublyLinkedList<Reparticao> dll = rf.readFileReparticoes("fx_repartições");
- Reparticao result = rf.repMaisProx(4470, dll);
- String[] listaServicos = {"A", "B"};
- Reparticao expResult = new Reparticao("Maia", 1235, "4470", listaServicos);
- assertTrue("O teste falhou", expResult.equals(result));
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement