/*
 * #%L
 * wcm.io
 * %%
 * Copyright (C) 2017 wcm.io
 * %%
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 * #L%
 */
package io.wcm.qa.galenium.example;

import static io.wcm.qa.galenium.galen.GalenLayoutChecker.checkLayout;

import org.testng.annotations.Factory;
import org.testng.annotations.Test;

import io.wcm.qa.galenium.device.TestDevice;
import io.wcm.qa.galenium.providers.TestDeviceProvider;
import io.wcm.qa.galenium.util.GaleniumConfiguration;

/**
 * Example of how to easily integrate Galen specs into Selenium based test.
 */
public class GalenSpecTestIT extends AbstractExampleBase {

  private static final String SPEC_PATH_FOR_CONFERENCE_PAGE = GaleniumConfiguration.getGalenSpecPath()
      + "/conference.gspec";
  private static final String SPEC_PATH_FOR_HOMEPAGE = GaleniumConfiguration.getGalenSpecPath() + "/homepage.gspec";

  @Factory(dataProviderClass = TestDeviceProvider.class, dataProvider = TestDeviceProvider.GALENIUM_TEST_DEVICES)
  public GalenSpecTestIT(TestDevice testDevice) {
    super(testDevice);
  }

  @Test
  public void checkConferencePageWithNavigationAndGalenSpec() {
    getLogger().info("Testing Conference Page");
    loadStartUrl();
    openNav();
    clickConferenceNavLink();
    checkLayout("Conference Page", SPEC_PATH_FOR_CONFERENCE_PAGE);
  }

  @Test
  public void checkHomepageWithGalenSpec() {
    getLogger().info("Testing Homepage");
    loadStartUrl();
    checkLayout("Homepage", SPEC_PATH_FOR_HOMEPAGE);
  }

  @Override
  protected String getRelativePath() {
    return PATH_TO_HOMEPAGE;
  }

}

@@ -662,80 +662,8 @@
 e;%0A%0A
-import static io.wcm.qa.galenium.galen.GalenLayoutChecker.checkLayout;%0A%0A
 impo
@@ -697,16 +697,16 @@
 actory;%0A
+
 import o
@@ -865,34 +865,66 @@
 ium.
-util.GaleniumConfiguration
+specs.Conference;%0Aimport io.wcm.qa.galenium.specs.Homepage
 ;%0A%0A/
@@ -1070,258 +1070,8 @@
  %7B%0A%0A
-  private static final String SPEC_PATH_FOR_CONFERENCE_PAGE = GaleniumConfiguration.getGalenSpecPath()%0A      + %22/conference.gspec%22;%0A  private static final String SPEC_PATH_FOR_HOMEPAGE = GaleniumConfiguration.getGalenSpecPath() + %22/homepage.gspec%22;%0A%0A
   @F
@@ -1452,68 +1452,25 @@
     
-checkLayout(%22Conference Page%22, SPEC_PATH_FOR_CONFERENCE_PAGE
+Conference.check(
 );%0A 
@@ -1596,54 +1596,23 @@
     
-checkLayout(%22Homepage%22, SPEC_PATH_FOR_HOMEPAGE
+Homepage.check(
 );%0A 

switch to generated spec classes