Advertisement
moreiramota

Untitled

Apr 11th, 2019
103
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 6.19 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 core.domain.RiskFactors.Metric;
  9. import core.domain.RiskFactors.RiskFactor;
  10. import core.domain.RiskFactors.STName;
  11. import core.domain.RiskFactors.SurroundingType;
  12. import core.domain.RiskMatrixs.Line;
  13. import core.domain.RiskMatrixs.MatrixBuilder;
  14. import core.persistence.CoverageRepository;
  15. import core.persistence.PersistenceContext;
  16. import core.persistence.RiskFactorRepository;
  17. import core.persistence.SurroundingTypeRepository;
  18. import domain.Coverages.Coverage;
  19. import java.io.IOException;
  20. import java.util.ArrayList;
  21. import java.util.List;
  22. import org.junit.After;
  23. import org.junit.AfterClass;
  24. import org.junit.Before;
  25. import org.junit.BeforeClass;
  26. import org.junit.Test;
  27. import static org.junit.Assert.*;
  28.  
  29. /**
  30. *
  31. * @author morei
  32. */
  33. public class FactorImportTest {
  34.  
  35. SurroundingType s1 = new SurroundingType(new STName("Bombeiros"));
  36. Metric m1 = new Metric("Distancia");
  37. RiskFactor rf1 = new RiskFactor(m1, s1.obtainSTName());
  38.  
  39. Metric m2 = new Metric("Tempo");
  40. RiskFactor rf2 = new RiskFactor(m2, s1.obtainSTName());
  41.  
  42. SurroundingType s2 = new SurroundingType(new STName("Floresta"));
  43. Metric m3 = new Metric("Area");
  44. RiskFactor rf3 = new RiskFactor(m3, s2.obtainSTName());
  45.  
  46. SurroundingType s3 = new SurroundingType(new STName("Vias Acesso"));
  47. Metric m4 = new Metric("Quantidade");
  48. RiskFactor rf4 = new RiskFactor(m4, s3.obtainSTName());
  49.  
  50. CoverageRepository coverageRepository = PersistenceContext.repositories().coverageRepository();
  51. RiskFactorRepository riskFactorRepository = PersistenceContext.repositories().riskRepository();
  52. SurroundingTypeRepository surroundingTypeRepository = PersistenceContext.repositories().surroundingRepository();
  53.  
  54.  
  55.  
  56. public FactorImportTest() {
  57. }
  58.  
  59. @BeforeClass
  60. public static void setUpClass() {
  61.  
  62. }
  63.  
  64. @AfterClass
  65. public static void tearDownClass() {
  66. }
  67.  
  68. @Before
  69. public void setUp() {
  70. surroundingTypeRepository.save(s1);
  71. surroundingTypeRepository.save(s2);
  72. surroundingTypeRepository.save(s3);
  73. }
  74.  
  75. @After
  76. public void tearDown() {
  77. }
  78.  
  79.  
  80. //
  81.  
  82. /**
  83. * Test of listRiskFactor method, of class FactorImport.
  84. */
  85. @Test
  86. public void testListRiskFactor() throws IOException {
  87. System.out.println("listRiskFactor");
  88. String[] f1 = {"", "Bombeiros", "", "Floresta", "Vias Acesso"};
  89. String[] f2 = {"", "Distancia", "Tempo", "Area", "Quantidade"};
  90. FactorImport instance = new FactorImport();
  91.  
  92. List<RiskFactor> expResult = new ArrayList<>();
  93. expResult.add(rf1);
  94. expResult.add(rf2);
  95. expResult.add(rf3);
  96. expResult.add(rf4);
  97.  
  98. List<RiskFactor> result = instance.getListRiskFactor(f1, f2);
  99. assertArrayEquals(expResult.toArray(), result.toArray());
  100. }
  101.  
  102. /**
  103. * Test of importFactorValues method, of class FactorImport.
  104. */
  105. // @Test
  106. // public void testImportFactorValues() throws Exception {
  107. // System.out.println("importFactorValues");
  108. // String fileName = "";
  109. // MatrixBuilder mb = new MatrixBuilder(MatrixBuilder.State.BASE);
  110. // FactorImport instance = new FactorImport();
  111. // List<Line> expResult = new ArrayList<>();
  112. // List<Line> result = instance.importFactorValues(fileName, mb);
  113. // assertEquals(expResult, result);
  114. // }
  115. //
  116. // /**
  117. // * Test of getRiskFactorList method, of class FactorImport.
  118. // */
  119. // @Test
  120. // public void testGetRiskFactorList() {
  121. // System.out.println("getRiskFactorList");
  122. // String[] f1 = null;
  123. // String[] f2 = null;
  124. // FactorImport instance = new FactorImport();
  125. // List<RiskFactor> expResult = null;
  126. // List<RiskFactor> result = instance.getRiskFactorList(f1, f2);
  127. // assertEquals(expResult, result);
  128. // // TODO review the generated test code and remove the default call to fail.
  129. // fail("The test case is a prototype.");
  130. // }
  131. //
  132. // /**
  133. // * Test of getLine method, of class FactorImport.
  134. // */
  135. // @Test
  136. // public void testGetLine() {
  137. // System.out.println("getLine");
  138. // Coverage c = null;
  139. // List<RiskFactor> listRisk = null;
  140. // String[] line = null;
  141. // String tipo = "";
  142. // MatrixBuilder mb = null;
  143. // FactorImport instance = new FactorImport();
  144. // Line expResult = null;
  145. // Line result = instance.getLine(c, listRisk, line, tipo, mb);
  146. // assertEquals(expResult, result);
  147. // // TODO review the generated test code and remove the default call to fail.
  148. // fail("The test case is a prototype.");
  149. // }
  150. //
  151. // /**
  152. // * Test of importMeaningfulFactors method, of class FactorImport.
  153. // */
  154. // @Test
  155. // public void testImportMeaningfulFactors() throws Exception {
  156. // System.out.println("importMeaningfulFactors");
  157. // String fileName = "";
  158. // MatrixBuilder mb = null;
  159. // FactorImport instance = new FactorImport();
  160. // boolean expResult = false;
  161. // boolean result = instance.importMeaningfulFactors(fileName, mb);
  162. // assertEquals(expResult, result);
  163. // // TODO review the generated test code and remove the default call to fail.
  164. // fail("The test case is a prototype.");
  165. // }
  166. //
  167. // /**
  168. // * Test of imporBaseRiskMatrix method, of class FactorImport.
  169. // */
  170. // @Test
  171. // public void testImporBaseRiskMatrix() throws Exception {
  172. // System.out.println("imporBaseRiskMatrix");
  173. // String fileName = "";
  174. // MatrixBuilder matrixBuilder = null;
  175. // FactorImport instance = new FactorImport();
  176. // boolean expResult = false;
  177. // boolean result = instance.imporBaseRiskMatrix(fileName, matrixBuilder);
  178. // assertEquals(expResult, result);
  179. // // TODO review the generated test code and remove the default call to fail.
  180. // fail("The test case is a prototype.");
  181. // }
  182. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement