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 Model;
- import DoublyLinkedList.DoublyLinkedList;
- import java.io.File;
- import java.util.HashSet;
- import java.util.Set;
- import org.junit.After;
- import org.junit.AfterClass;
- import org.junit.Before;
- import org.junit.BeforeClass;
- import org.junit.Test;
- import static org.junit.Assert.*;
- /**
- *
- * @author Pedro Quinta
- */
- public class FileReaderTest {
- public FileReaderTest() {
- }
- @BeforeClass
- public static void setUpClass() {
- }
- @AfterClass
- public static void tearDownClass() {
- }
- @Before
- public void setUp() {
- }
- @After
- public void tearDown() {
- }
- /**
- * Test of readFileCidadao method, of class FileReader.
- */
- @Test
- public void testReadFileCidadao() {
- System.out.println("readFileCidadao");
- FileReader instance = new FileReader();
- GestaoReparticao reparticao = new GestaoReparticao();
- Set<Cidadao> cidadaos = reparticao.getSetCidadao();
- Cidadao cid = new Cidadao("Ana", 111222333, "ana@gmail.com", "4200-072", 1234);
- Cidadao cid1 = new Cidadao("Berta", 223344, "berta@gmail.com", "4200-071", 1234);
- Cidadao cid2 = new Cidadao("Manuel", 584769, "manuel@gmail.com", "4715-357", 5762);
- Cidadao cid3 = new Cidadao("Pedro", 53263622, "pedro@gmail.com", "4400-321", 3421);
- Cidadao cid4 = new Cidadao("Beatriz", 3121121, "beatriz@gmail.com", "4400-123", 2543);
- Cidadao cid5 = new Cidadao("Joao", 2311212, "joao@gmail.com", "4450-321", 1243);
- cidadaos.add(cid);
- cidadaos.add(cid1);
- cidadaos.add(cid2);
- cidadaos.add(cid3);
- cidadaos.add(cid4);
- cidadaos.add(cid5);
- Set<Cidadao> expResult = cidadaos;
- instance.readFileCidadao();
- Set<Cidadao> result = instance.getCidadaos();
- assertEquals(expResult, result);
- }
- /**
- * Test of readFileReparticao method, of class FileReader.
- */
- @Test
- public void testReadFileReparticao() {
- System.out.println("readFileReparticao");
- FileReader instance = new FileReader();
- GestaoReparticao reparticao = new GestaoReparticao();
- DoublyLinkedList<Reparticao> reparticoes = reparticao.getListaReparticoes();
- Set<String> setServicos = new HashSet<>();
- setServicos.add("A");
- setServicos.add("C");
- setServicos.add("D");
- Reparticao rep = new Reparticao("Porto", 1234, 4200, setServicos);
- Set<String> setServicos1 = new HashSet<>();
- setServicos1.add("A");
- setServicos1.add("B");
- Reparticao rep1 = new Reparticao("Maia", 1235, 4470, setServicos1);
- Set<String> setServicos2 = new HashSet<>();
- setServicos2.add("C");
- setServicos2.add("D");
- Reparticao rep2 = new Reparticao("Lisboa", 1256, 4300, setServicos2);
- Set<String> setServicos3 = new HashSet<>();
- setServicos3.add("A");
- setServicos3.add("C");
- Reparticao rep3 = new Reparticao("Coimbra", 1289, 4120, setServicos3);
- Set<String> setServicos4 = new HashSet<>();
- setServicos1.add("B");
- setServicos1.add("D");
- Reparticao rep4 = new Reparticao("Braga", 1254, 4250, setServicos4);
- Set<String> setServicos5 = new HashSet<>();
- setServicos5.add("B");
- setServicos5.add("A");
- Reparticao rep5 = new Reparticao("Algarve", 5637, 1287, setServicos5);
- reparticoes.addFirst(rep);
- reparticoes.addLast(rep1);
- reparticoes.addLast(rep2);
- reparticoes.addLast(rep3);
- reparticoes.addLast(rep4);
- reparticoes.addLast(rep5);
- DoublyLinkedList<Reparticao> expResult = reparticoes;
- Reparticao h = expResult.first();
- Reparticao t = expResult.last();
- int L = expResult.size();
- instance.readFileReparticao();
- DoublyLinkedList<Reparticao> result = instance.getReparticoes();
- Reparticao h1 = result.first();
- Reparticao t1 = result.last();
- int L1 = result.size();
- assertEquals(h, h1);
- assertEquals(t, t1);
- assertEquals(L, L1);
- }
- /**
- * Test of readFileSenha method, of class FileReader.
- */
- @Test
- public void testReadFileSenha() {
- System.out.println("readFileSenha");
- FileReader instance = new FileReader();
- GestaoReparticao reparticao = new GestaoReparticao();
- Set<Senha> senhas = reparticao.getSetSenha();
- Senha sen = new Senha(111222333, 'A', 1);
- Senha sen1 = new Senha(111222333, 'C', 1);
- Senha sen2 = new Senha(222333444, 'A', 2);
- Senha sen3 = new Senha(333444555, 'A', 3);
- Senha sen4 = new Senha(152626121, 'C', 2);
- Senha sen5 = new Senha(153632887, 'D', 1);
- Senha sen6 = new Senha(167788289, 'B', 1);
- Senha sen7 = new Senha(124536373, 'B', 2);
- senhas.add(sen);
- senhas.add(sen1);
- senhas.add(sen2);
- senhas.add(sen3);
- senhas.add(sen4);
- senhas.add(sen5);
- senhas.add(sen6);
- senhas.add(sen7);
- Set<Senha> expResult = senhas;
- instance.readFileSenha();
- Set<Senha> result = instance.getSenhas();
- assertEquals(expResult, result);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement