Advertisement
Guest User

Untitled

a guest
Oct 15th, 2017
85
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.52 KB | None | 0 0
  1. /*
  2. * To change this license header, choose License Headers in Project Properties.
  3. * To change this template file, choose Tools | Templates
  4. * and open the template in the editor.
  5. */
  6. package utils;
  7.  
  8. import java.io.FileNotFoundException;
  9. import java.util.HashMap;
  10. import java.util.HashSet;
  11. import java.util.Map;
  12. import java.util.Set;
  13. import org.junit.Test;
  14. import static org.junit.Assert.*;
  15. import projetoesinf.Cidadao;
  16. import projetoesinf.Financas;
  17. import projetoesinf.Reparticao;
  18. import projetoesinf.Senha;
  19.  
  20. /**
  21. *
  22. * @author João
  23. */
  24. public class ReadFileIT {
  25.  
  26. public ReadFileIT() {
  27. }
  28.  
  29. @Test
  30. public void testReadFileReparticoes() throws Exception {
  31. System.out.println("readFileReparticoes");
  32. ReadFile instance = new ReadFile();
  33. DoublyLinkedList<Reparticao> result = instance.readFileReparticoes("fx_repartições");
  34. DoublyLinkedList<Reparticao> expResult = new DoublyLinkedList<>();
  35. String[] listaServicos1 = {"A", "C", "D"};
  36. expResult.addLast(new Reparticao("Porto", 1234, "4200", listaServicos1));
  37. String[] listaServicos2 = {"A", "B"};
  38. expResult.addLast(new Reparticao("Maia", 1235, "4470", listaServicos2));
  39. assertEquals(expResult, result);
  40.  
  41. }
  42.  
  43. @Test
  44. public void testReadFileCidadaos() throws Exception {
  45. System.out.println("readFileCidadaos");
  46. ReadFile instance = new ReadFile();
  47. Map<Reparticao, Set<Cidadao>> map = new HashMap<>();
  48. DoublyLinkedList<Reparticao> dll = instance.readFileReparticoes("fx_repartições");
  49. Map<Reparticao, Set<Cidadao>> result = instance.readFileCidadaos(map, dll, "fx_cidadaos");
  50. Map<Reparticao, Set<Cidadao>> expResult = new HashMap<>();
  51. String[] listaServicos1 = {"A", "C", "D"};
  52. Reparticao rep1 = new Reparticao("Porto", 1234, "4200", listaServicos1);
  53. String[] listaServicos2 = {"A", "B"};
  54. Reparticao rep2 = new Reparticao("Maia", 1235, "4470", listaServicos2);
  55. Cidadao cid1 = new Cidadao("Ana", "ana@gmail.com", 111222333, "4200-072", 1234);
  56. Cidadao cid2 = new Cidadao("Berta", "berta@gmail.com", 223344, "4200-071", 1234);
  57. Cidadao cid3 = new Cidadao("Manuel", "manuel@gmail.com", 584769, "4715-357", 5762);
  58. Set<Cidadao> set1 = new HashSet<>();
  59. set1.add(cid1);
  60. set1.add(cid2);
  61. Set<Cidadao> set2 = new HashSet<>();
  62. set2.add(cid3);
  63. expResult.put(rep1, set1);
  64. expResult.put(rep2, set2);
  65. assertTrue("O teste falhou", expResult.equals(result));
  66. }
  67.  
  68. @Test
  69. public void testReadFileSenhas() throws Exception {
  70. System.out.println("readFileSenhas");
  71. ReadFile instance = new ReadFile();
  72. Map<Reparticao, Set<Cidadao>> map1 = new HashMap<>();
  73. Map<Cidadao, Set<Senha>> map2 = new HashMap<>();
  74. DoublyLinkedList<Reparticao> dll = instance.readFileReparticoes("fx_repartições");
  75. Map<Reparticao, Set<Cidadao>> map3 = instance.readFileCidadaos(map1, dll, "fx_cidadaos");
  76. Map<Cidadao, Set<Senha>> result = instance.readFileSenhas(map2, map3, dll, "fx_senhas");
  77. Map<Cidadao, Set<Senha>> expResult = new HashMap<>();
  78. Cidadao cid1 = new Cidadao("Ana", "ana@gmail.com", 111222333, "4200-072", 1234);
  79. Cidadao cid2 = new Cidadao("Berta", "berta@gmail.com", 223344, "4200-071", 1234);
  80. Cidadao cid3 = new Cidadao("Manuel", "manuel@gmail.com", 584769, "4715-357", 5762);
  81. Set<Senha> set1 = new HashSet<>();
  82. set1.add(new Senha("A", 1));
  83. set1.add(new Senha("C", 2));
  84. Set<Senha> set2 = new HashSet<>();
  85. set2.add(new Senha("A", 2));
  86. set2.add(new Senha("C", 1));
  87. set2.add(new Senha("D", 1));
  88. Set<Senha> set3 = new HashSet<>();
  89. set3.add(new Senha("A", 1));
  90. set3.add(new Senha("B", 1));
  91. expResult.put(cid1, set1);
  92. expResult.put(cid2, set2);
  93. expResult.put(cid3, set3);
  94. assertTrue("O teste falhou", expResult.equals(result));
  95. }
  96.  
  97. @Test
  98. public void testRepMaisProx() throws Exception {
  99. System.out.println("repMaisProx");
  100. ReadFile rf = new ReadFile();
  101. DoublyLinkedList<Reparticao> dll = rf.readFileReparticoes("fx_repartições");
  102. Reparticao result = rf.repMaisProx(4470, dll);
  103. String[] listaServicos = {"A", "B"};
  104. Reparticao expResult = new Reparticao("Maia", 1235, "4470", listaServicos);
  105. assertTrue("O teste falhou", expResult.equals(result));
  106. }
  107.  
  108. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement