Skip to content

Instantly share code, notes, and snippets.

@armed
Created December 7, 2010 03:49
Show Gist options
  • Save armed/731425 to your computer and use it in GitHub Desktop.
Save armed/731425 to your computer and use it in GitHub Desktop.
package integration.tests;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertTrue;
import java.util.List;
import javax.xml.bind.JAXBElement;
import org.junit.Before;
import org.junit.Ignore;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
import org.springframework.test.context.transaction.TransactionConfiguration;
import com.agtsoft.integration.ctis.generated.Device;
import com.agtsoft.integration.ctis.generated.DeviceList;
import com.agtsoft.integration.ctis.generated.Equipment;
import com.agtsoft.integration.ctis.generated.EquipmentList;
import com.agtsoft.integration.ctis.generated.ObjectFactory;
import com.agtsoft.integration.ctis.generated.TownCode;
import com.agtsoft.integration.ctis.generated.TownEquipment;
import com.agtsoft.integration.ctis.ws.CtisEndpoint;
/**
* Интеграционный тест, предназначенный для проверки конфигурации контекста
* и сервиса предоставления информации по оборудованию. Тест жестко завязан на тестовые данные
* в файле src/test/resources/import.sql.
*
* Проводится тестирование всех десяти методов получения данных по оборудованию. Конфигурация филиалов
* и их удаленных сервисов находится в import.sql.
* @author Artem Medeu
*
*/
@Ignore
@RunWith(SpringJUnit4ClassRunner.class)
@ContextConfiguration({"classpath:test-context.xml"})
@TransactionConfiguration(defaultRollback=true)
public class CtisEndpointShould {
@Autowired
CtisEndpoint ctis;
ObjectFactory of;
TownCode tarazCode;
TownCode testTarazCode;
@Before
public void setUp() {
of = new ObjectFactory();
tarazCode = new TownCode();
tarazCode.setCode("7262");
testTarazCode = new TownCode();
testTarazCode.setCode("07262");
}
private TownEquipment createEquipment(String id) {
Equipment eq = new Equipment();
eq.setId(id);
TownEquipment te = new TownEquipment();
te.setEquipment(eq);
te.setTownCode(tarazCode);
return te;
}
private TownEquipment createEquipmentTestCode(String id) {
Equipment eq = new Equipment();
eq.setId(id);
TownEquipment te = new TownEquipment();
te.setEquipment(eq);
te.setTownCode(testTarazCode);
return te;
}
@Test
public void returnListOfCrossesByTownCode7262() {
System.out.println("Кроссы по коду города 7262: ");
JAXBElement<EquipmentList> jaxbElem = ctis.getCrossList(of.createGetCrossListRequest(tarazCode));
assertNotNull(jaxbElem);
List<Equipment> eqList = jaxbElem.getValue().getList();
assertNotNull(eqList);
for (Equipment equipment : eqList) {
System.out.println(equipment.getName() + "; id=" + equipment.getId());
}
System.out.println();
}
@Test
public void returnListOfCrossesByTownCode07262() {
System.out.println("Кроссы по коду города 07262: ");
JAXBElement<EquipmentList> jaxbElem = ctis.getCrossList(of.createGetCrossListRequest(testTarazCode));
assertNotNull(jaxbElem);
List<Equipment> eqList = jaxbElem.getValue().getList();
assertNotNull(eqList);
assertTrue(eqList.size() > 0);
for (Equipment equipment : eqList) {
System.out.println(equipment.getName() + "; id=" + equipment.getId());
}
System.out.println();
}
@Test
public void returnListOfThunderBandsByCrossId172527() {
System.out.println("Громполосы по кроссу ID = 172527:");
JAXBElement<EquipmentList> jaxbElem = ctis.getThunderbandList(
of.createGetThunderbandListByCrossRequest(createEquipment("172527")));
assertNotNull(jaxbElem);
List<Equipment> eqList = jaxbElem.getValue().getList();
assertNotNull(eqList);
for (Equipment equipment : eqList) {
System.out.println(equipment.getName() + "; id=" + equipment.getId());
}
System.out.println();
}
@Test
public void returnListOfThunderBandsByCrossId172527TestCode() {
System.out.println("Громполосы по кроссу ID = 172527:");
JAXBElement<EquipmentList> jaxbElem = ctis.getThunderbandList(
of.createGetThunderbandListByCrossRequest(createEquipmentTestCode("172527")));
assertNotNull(jaxbElem);
List<Equipment> eqList = jaxbElem.getValue().getList();
assertNotNull(eqList);
assertTrue(eqList.size() > 0);
for (Equipment equipment : eqList) {
System.out.println(equipment.getName() + "; id=" + equipment.getId());
}
System.out.println();
}
@Test
public void returnListOfCardsByThunderbandId7364176() {
System.out.println("Платы по громполосе ID = 7364176:");
JAXBElement<EquipmentList> jaxbElem = ctis.getCardList(
of.createGetCardListByThunderbandRequest(createEquipment("7364176")));
assertNotNull(jaxbElem);
List<Equipment> eqList = jaxbElem.getValue().getList();
assertNotNull(eqList);
assertTrue(eqList.size() > 0);
for (Equipment equipment : eqList) {
System.out.println(equipment.getName() + "; id=" + equipment.getId());
}
System.out.println();
}
@Test
public void returnListOfCardsByThunderbandId7364176TestCode() {
System.out.println("Платы по громполосе ID = 7364176:");
JAXBElement<EquipmentList> jaxbElem = ctis.getCardList(
of.createGetCardListByThunderbandRequest(createEquipmentTestCode("7364176")));
assertNotNull(jaxbElem);
List<Equipment> eqList = jaxbElem.getValue().getList();
assertNotNull(eqList);
assertTrue(eqList.size() > 0);
for (Equipment equipment : eqList) {
System.out.println(equipment.getName() + "; id=" + equipment.getId());
}
System.out.println();
}
@Test
public void returnListOfDevicesByCardId7381798() {
System.out.println("Оборудование по плате ID = 7381798:");
JAXBElement<DeviceList> jaxbElem = ctis.getDeviceListByCard(
of.createGetDeviceListByCardRequest(createEquipment("7381798")));
assertNotNull(jaxbElem);
List<Device> eqList = jaxbElem.getValue().getDevices();
assertNotNull(eqList);
assertTrue(eqList.size() > 0);
for (Device equipment : eqList) {
System.out.println(equipment.getPhoneNumber() + "; " + equipment.getLinearData());
}
System.out.println();
}
@Test
public void returnListOfDevicesByCardId7381798TestCode() {
System.out.println("Оборудование по плате ID = 7381798:");
JAXBElement<DeviceList> jaxbElem = ctis.getDeviceListByCard(
of.createGetDeviceListByCardRequest(createEquipmentTestCode("7381798")));
assertNotNull(jaxbElem);
List<Device> eqList = jaxbElem.getValue().getDevices();
assertNotNull(eqList);
assertTrue(eqList.size() > 0);
for (Device equipment : eqList) {
System.out.println(equipment.getPhoneNumber() + "; " + equipment.getLinearData());
}
System.out.println();
}
@Test
public void returnListOfTerminalEnclosuresByCrossId172527() {
System.out.println("РШ по кроссу ID = 172527:");
JAXBElement<EquipmentList> jaxbElem = ctis.getTerminalEnclosureList(
of.createGetTerminalEnclosureListByCrossRequest(createEquipment("172527")));
assertNotNull(jaxbElem);
List<Equipment> eqList = jaxbElem.getValue().getList();
assertNotNull(eqList);
assertTrue(eqList.size() > 0);
for (Equipment equipment : eqList) {
System.out.println(equipment.getName() + "; id=" + equipment.getId());
}
System.out.println();
}
@Test
public void returnListOfDistributionCabinetsByTerminalEnclosureId4092874() {
System.out.println("Боксы по РШ ID = 4092874:");
JAXBElement<EquipmentList> jaxbElem = ctis.getDistributionCabinetList(
of.createGetDistributionCabinetListByTerminalEnclosureRequest(createEquipment("4092874")));
assertNotNull(jaxbElem);
List<Equipment> eqList = jaxbElem.getValue().getList();
assertNotNull(eqList);
assertTrue(eqList.size() > 0);
for (Equipment equipment : eqList) {
System.out.println(equipment.getName() + "; id=" + equipment.getId());
}
System.out.println();
}
@Test
public void returnListOfDistributionBoxesByDistributionCabinetId9961537() {
System.out.println("РК по боксам РШ ID = 9961537:");
JAXBElement<EquipmentList> jaxbElem = ctis.getDistributionBoxList(
of.createGetDistributionBoxListByDistributionCabinetRequest(createEquipment("9961537")));
assertNotNull(jaxbElem);
List<Equipment> eqList = jaxbElem.getValue().getList();
assertNotNull(eqList);
assertTrue(eqList.size() > 0);
for (Equipment equipment : eqList) {
System.out.println(equipment.getName() + "; id=" + equipment.getId());
}
System.out.println();
}
@Test
public void returnListOfDevicesByDistributionBoxId10044774() {
System.out.println("Оборудование по РК ID = 10044774:");
JAXBElement<DeviceList> jaxbElem = ctis.getDeviceListByDistributionBox(
of.createGetDeviceListByDistributionBoxRequest(createEquipment("10044774")));
assertNotNull(jaxbElem);
List<Device> eqList = jaxbElem.getValue().getDevices();
assertNotNull(eqList);
assertTrue(eqList.size() > 0);
for (Device equipment : eqList) {
System.out.println(equipment.getPhoneNumber() + "; " + equipment.getLinearData());
}
System.out.println();
}
@Test
public void returnListOfDirectSupplyBoxesByCrossId172527() {
System.out.println("РКпп по кроссу ID = 172527:");
JAXBElement<EquipmentList> jaxbElem = ctis.getDirectSupplyBoxList(
of.createGetDirectSupplyBoxListByCrossRequest(createEquipment("172527")));
assertNotNull(jaxbElem);
List<Equipment> eqList = jaxbElem.getValue().getList();
assertNotNull(eqList);
assertTrue(eqList.size() > 0);
for (Equipment equipment : eqList) {
System.out.println(equipment.getName() + "; id=" + equipment.getId());
}
System.out.println();
}
@Test
public void returnListOfDevicesByDirectSupplyBoxIdId5642772() {
System.out.println("Оборудование по плате ID = 5642772:");
JAXBElement<DeviceList> jaxbElem = ctis.getDeviceListByDirectSupplyBox(
of.createGetDeviceListByDirectSupplyBoxRequest(createEquipment("5642772")));
assertNotNull(jaxbElem);
List<Device> eqList = jaxbElem.getValue().getDevices();
assertNotNull(eqList);
assertTrue(eqList.size() > 0);
for (Device equipment : eqList) {
System.out.println(equipment.getPhoneNumber() + "; " + equipment.getLinearData());
}
System.out.println();
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment