Advertisement
Guest User

Untitled

a guest
Jun 22nd, 2017
55
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 5 8.11 KB | None | 0 0
  1. package integration.tests;
  2.  
  3. import static org.junit.Assert.assertNotNull;
  4. import static org.junit.Assert.assertTrue;
  5.  
  6. import java.util.List;
  7.  
  8. import javax.xml.bind.JAXBElement;
  9.  
  10. import org.junit.Before;
  11. import org.junit.Test;
  12. import org.junit.runner.RunWith;
  13. import org.springframework.beans.factory.annotation.Autowired;
  14. import org.springframework.test.context.ContextConfiguration;
  15. import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
  16. import org.springframework.test.context.transaction.TransactionConfiguration;
  17.  
  18. import com.agtsoft.integration.ctis.generated.Device;
  19. import com.agtsoft.integration.ctis.generated.DeviceList;
  20. import com.agtsoft.integration.ctis.generated.Equipment;
  21. import com.agtsoft.integration.ctis.generated.EquipmentList;
  22. import com.agtsoft.integration.ctis.generated.ObjectFactory;
  23. import com.agtsoft.integration.ctis.generated.TownCode;
  24. import com.agtsoft.integration.ctis.generated.TownEquipment;
  25. import com.agtsoft.integration.ctis.ws.CtisEndpoint;
  26.  
  27. /**
  28.  * Интеграционный тест, предназначенный для проверки конфигурации контекста
  29.  * и сервиса предоставления информации по оборудованию. Тест жестко завязан на тестовые данные
  30.  * в файле src/test/resources/import.sql.
  31.  *
  32.  * Проводится тестирование всех десяти методов получения данных по оборудованию. Конфигурация филиалов
  33.  * и их удаленных сервисов находится в import.sql.
  34.  * @author Artem Medeu
  35.  *
  36.  */
  37. @RunWith(SpringJUnit4ClassRunner.class)
  38. @ContextConfiguration({"classpath:test-context.xml"})
  39. @TransactionConfiguration(defaultRollback=true)
  40. public class CtisEndpointShould {
  41.  
  42.     @Autowired
  43.     CtisEndpoint ctis;
  44.    
  45.     ObjectFactory of;
  46.    
  47.     TownCode tarazCode;
  48.    
  49.     @Before
  50.     public void setUp() {
  51.         of = new ObjectFactory();
  52.         tarazCode = new TownCode();
  53.         tarazCode.setCode("7262");
  54.     }
  55.    
  56.     private TownEquipment createEquipment(String id) {
  57.         Equipment eq = new Equipment();
  58.         eq.setId(id);
  59.        
  60.         TownEquipment te = new TownEquipment();
  61.         te.setEquipment(eq);
  62.         te.setTownCode(tarazCode);
  63.        
  64.         return te;
  65.     }
  66.    
  67.     @Test
  68.     public void returnListOfCrossesByTownCode7262() {
  69.         System.out.println("Кроссы по коду города 7262: ");
  70.         JAXBElement<EquipmentList> jaxbElem = ctis.getCrossList(of.createGetCrossListRequest(tarazCode));
  71.        
  72.         assertNotNull(jaxbElem);
  73.        
  74.         List<Equipment> eqList = jaxbElem.getValue().getList();
  75.        
  76.         assertNotNull(eqList);
  77.        
  78.         for (Equipment equipment : eqList) {
  79.             System.out.println(equipment.getName() + "; id=" + equipment.getId());
  80.         }
  81.         System.out.println();
  82.     }
  83.    
  84.     @Test
  85.     public void returnListOfThunderBandsByCrossId172527() {
  86.         System.out.println("Громполосы по кроссу ID = 172527:");
  87.                
  88.         JAXBElement<EquipmentList> jaxbElem = ctis.getThunderbandList(
  89.                 of.createGetThunderbandListByCrossRequest(createEquipment("172527")));
  90.  
  91.        
  92.         assertNotNull(jaxbElem);
  93.        
  94.         List<Equipment> eqList = jaxbElem.getValue().getList();
  95.        
  96.         assertNotNull(eqList);
  97.        
  98.         for (Equipment equipment : eqList) {
  99.             System.out.println(equipment.getName() + "; id=" + equipment.getId());
  100.         }
  101.         System.out.println();
  102.     }
  103.    
  104.     @Test
  105.     public void returnListOfCardsByThunderbandId7364176() {
  106.         System.out.println("Платы по громполосе ID = 7364176:");
  107.                
  108.         JAXBElement<EquipmentList> jaxbElem = ctis.getCardList(
  109.                 of.createGetCardListByThunderbandRequest(createEquipment("7364176")));
  110.  
  111.        
  112.         assertNotNull(jaxbElem);
  113.        
  114.         List<Equipment> eqList = jaxbElem.getValue().getList();
  115.        
  116.         assertNotNull(eqList);
  117.         assertTrue(eqList.size() > 0);
  118.        
  119.         for (Equipment equipment : eqList) {
  120.             System.out.println(equipment.getName() + "; id=" + equipment.getId());
  121.         }
  122.         System.out.println();
  123.     }
  124.    
  125.     @Test
  126.     public void returnListOfDevicesByCardId7381798() {
  127.         System.out.println("Оборудование по плате ID = 7381798:");
  128.                
  129.         JAXBElement<DeviceList> jaxbElem = ctis.getDeviceListByCard(
  130.                 of.createGetDeviceListByCardRequest(createEquipment("7381798")));
  131.  
  132.        
  133.         assertNotNull(jaxbElem);
  134.        
  135.         List<Device> eqList = jaxbElem.getValue().getDevices();
  136.        
  137.         assertNotNull(eqList);
  138.         assertTrue(eqList.size() > 0);
  139.        
  140.         for (Device equipment : eqList) {
  141.             System.out.println(equipment.getLinearData());
  142.         }
  143.         System.out.println();
  144.     }
  145.    
  146.     @Test
  147.     public void returnListOfTerminalEnclosuresByCrossId172527() {
  148.         System.out.println("РШ по кроссу ID = 172527:");
  149.                
  150.         JAXBElement<EquipmentList> jaxbElem = ctis.getTerminalEnclosureList(
  151.                 of.createGetTerminalEnclosureListByCrossRequest(createEquipment("172527")));
  152.  
  153.        
  154.         assertNotNull(jaxbElem);
  155.        
  156.         List<Equipment> eqList = jaxbElem.getValue().getList();
  157.        
  158.         assertNotNull(eqList);
  159.         assertTrue(eqList.size() > 0);
  160.        
  161.         for (Equipment equipment : eqList) {
  162.             System.out.println(equipment.getName() + "; id=" + equipment.getId());
  163.         }
  164.         System.out.println();
  165.     }
  166.    
  167.     @Test
  168.     public void returnListOfDistributionCabinetsByTerminalEnclosureId4092874() {
  169.         System.out.println("Боксы по РШ ID = 4092874:");
  170.                
  171.         JAXBElement<EquipmentList> jaxbElem = ctis.getDistributionCabinetList(
  172.                 of.createGetDistributionCabinetListByTerminalEnclosureRequest(createEquipment("4092874")));
  173.  
  174.        
  175.         assertNotNull(jaxbElem);
  176.        
  177.         List<Equipment> eqList = jaxbElem.getValue().getList();
  178.        
  179.         assertNotNull(eqList);
  180.         assertTrue(eqList.size() > 0);
  181.        
  182.         for (Equipment equipment : eqList) {
  183.             System.out.println(equipment.getName() + "; id=" + equipment.getId());
  184.         }
  185.         System.out.println();
  186.     }
  187.    
  188.     @Test
  189.     public void returnListOfDistributionBoxesByDistributionCabinetId9961537() {
  190.         System.out.println("РК по боксам РШ ID = 9961537:");
  191.                
  192.         JAXBElement<EquipmentList> jaxbElem = ctis.getDistributionBoxList(
  193.                 of.createGetDistributionBoxListByDistributionCabinetRequest(createEquipment("9961537")));
  194.  
  195.        
  196.         assertNotNull(jaxbElem);
  197.        
  198.         List<Equipment> eqList = jaxbElem.getValue().getList();
  199.        
  200.         assertNotNull(eqList);
  201.         assertTrue(eqList.size() > 0);
  202.        
  203.         for (Equipment equipment : eqList) {
  204.             System.out.println(equipment.getName() + "; id=" + equipment.getId());
  205.         }
  206.         System.out.println();
  207.     }
  208.    
  209.     @Test
  210.     public void returnListOfDevicesByDistributionBoxId10044774() {
  211.         System.out.println("Оборудование по РК ID = 10044774:");
  212.                
  213.         JAXBElement<DeviceList> jaxbElem = ctis.getDeviceListByDistributionBox(
  214.                 of.createGetDeviceListByDistributionBoxRequest(createEquipment("10044774")));
  215.  
  216.        
  217.         assertNotNull(jaxbElem);
  218.        
  219.         List<Device> eqList = jaxbElem.getValue().getDevices();
  220.        
  221.         assertNotNull(eqList);
  222.         assertTrue(eqList.size() > 0);
  223.        
  224.         for (Device equipment : eqList) {
  225.             System.out.println(equipment.getLinearData());
  226.         }
  227.         System.out.println();
  228.     }
  229.    
  230.     @Test
  231.     public void returnListOfDirectSupplyBoxesByCrossId172527() {
  232.         System.out.println("РКпп по кроссу ID = 172527:");
  233.                
  234.         JAXBElement<EquipmentList> jaxbElem = ctis.getDirectSupplyBoxList(
  235.                 of.createGetDirectSupplyBoxListByCrossRequest(createEquipment("172527")));
  236.  
  237.         assertNotNull(jaxbElem);
  238.        
  239.         List<Equipment> eqList = jaxbElem.getValue().getList();
  240.        
  241.         assertNotNull(eqList);
  242.         assertTrue(eqList.size() > 0);
  243.        
  244.         for (Equipment equipment : eqList) {
  245.             System.out.println(equipment.getName() + "; id=" + equipment.getId());
  246.         }
  247.         System.out.println();
  248.     }
  249.  
  250.     @Test
  251.     public void returnListOfDevicesByDirectSupplyBoxIdId5642772() {
  252.         System.out.println("Оборудование по плате ID = 5642772:");
  253.        
  254.         JAXBElement<DeviceList> jaxbElem = ctis.getDeviceListByDirectSupplyBox(
  255.                 of.createGetDeviceListByDirectSupplyBoxRequest(createEquipment("5642772")));
  256.  
  257.        
  258.         assertNotNull(jaxbElem);
  259.        
  260.         List<Device> eqList = jaxbElem.getValue().getDevices();
  261.        
  262.         assertNotNull(eqList);
  263.         assertTrue(eqList.size() > 0);
  264.        
  265.         for (Device equipment : eqList) {
  266.             System.out.println(equipment.getLinearData());
  267.         }
  268.         System.out.println();
  269.     }
  270. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement