1 / 7

Enterprise System Integration

Enterprise System Integration. Practical Session 3. Manuel Camargo manuel.camargo@ut.ee. Source code. https://bitbucket.org/orlenyslp/esi-2019/src/master /. http://kodu.ut.ee/~chavez85/esi/. Practice aim. BDD / cucumber ( acceptance testing ) Gherkin --Specification language.

tdeleon
Download Presentation

Enterprise System Integration

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Enterprise System Integration PracticalSession 3 Manuel Camargo manuel.camargo@ut.ee

  2. Sourcecode https://bitbucket.org/orlenyslp/esi-2019/src/master/ http://kodu.ut.ee/~chavez85/esi/

  3. Practice aim • BDD / cucumber (acceptance testing) • Gherkin --Specification language Web UI adaptor on top of a domain model using Spring Boot

  4. Test structure \features/sales/creation_of_purchase_order.feature User story com/example/demo/sales/CreationOfPurchaseOrderSteps.java CreationOfPurchaseOrderSteps.java @ContextConfiguration(classes = DemoApplication.class) @WebAppConfiguration public class CreationOfPurchaseOrderSteps { @Autowired private WebApplicationContextwac; private WebClientcustomerBrowser; HtmlPagecustomerPage; @Autowired PlantInventoryEntryRepositoryplantInventoryEntryRepository; @Autowired PlantInventoryItemRepositoryplantInventoryItemRepository; @Autowired PurchaseOrderRepositoryPurchaseOrderRepository; @Before // Use `Before` from Cucumber library public void setUp() { … Implementationsteps

  5. Test structure public class CreationOfPurchaseOrderSteps {@Autowiredprivate WebApplicationContextwac;private WebClientcustomerBrowser;HtmlPagecustomerPage;@AutowiredPlantInventoryEntryRepositoryplantInventoryEntryRepository;@AutowiredPlantInventoryItemRepositoryplantInventoryItemRepository;@AutowiredPurchaseOrderRepositorypurchaseOrderRepository;@Before // Use `Before` from Cucumber librarypublic void setUp() {customerBrowser= MockMvcWebClientBuilder.webAppContextSetup(wac).build(); }@After // Use `After` from Cucumber librarypublic void tearOff() {purchaseOrderRepository.deleteAll();plantInventoryItemRepository.deleteAll();plantInventoryEntryRepository.deleteAll(); } Setup Creation of relationships Customerbrowsercreation Cleansingafter test execution

  6. Test structure Setup @Given("^the following plant catalog$")public void the_following_plant_catalog(List<PlantInventoryEntry> entries) throws Throwable {plantInventoryEntryRepository.saveAll(entries);}@Given("^the following inventory$")public void the_following_inventory(DataTable table) throws Throwable {for (Map<String, String> row: table.asMaps(String.class, String.class))plantInventoryItemRepository.save(PlantInventoryItem.of(Long.parseLong(row.get("id")),row.get("serialNumber"),EquipmentCondition.valueOf(row.get("equipmentCondition")),plantInventoryEntryRepository.findById(Long.parseLong(row.get("plantInfo"))).orElse(null) ) );}@Given("^a customer is in the \"([^\"]*)\" web page$")public void a_customer_is_in_the_web_page(String arg1) throws Throwable {customerPage= customerBrowser.getPage("http://localhost/dashboard/catalog/form");}@Given("^no purchase order exists in the system$")public void no_purchase_order_exists_in_the_system() throws Throwable {assertThat(purchaseOrderRepository.findAll().size()).isZero();} Tablespopulation Simulatethecustomer interaction with the application Validation of no order existance

  7. Test structure Scenarios @When("^the customer queries the plant catalog for an \"([^\"]*)\" available from \"([^\"]*)\" to \"([^\"]*)\"$")public void the_customer_queries_the_plant_catalog_for_an_available_from_to(String plantName, String startDate, String endDate) throws Throwable {// The following elements are selected by their identifierHtmlTextInputnameInput = (HtmlTextInput)customerPage.getElementById("name");HtmlDateInputstartDateInput = (HtmlDateInput)customerPage.getElementById("rental-start-date");HtmlDateInputendDateInput = (HtmlDateInput)customerPage.getElementById("rental-end-date");HtmlButton submit = (HtmlButton)customerPage.getElementById("submit-button");nameInput.setValueAttribute(plantName);startDateInput.setValueAttribute(startDate);endDateInput.setValueAttribute(endDate);customerPage= submit.click();}@Then("^(\\d+) plants are shown$")public void plants_are_shown(int arg1) throws Throwable { List<?> rows = customerPage.getByXPath("//tr[contains(@class, 'table-row')]");assertThat(rows.size()).isEqualTo(arg1);}

More Related