Java tutorial
/* * Copyright (C) 2017 FormKiQ Inc. * * 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. */ package com.formkiq.web; import static org.junit.Assert.assertEquals; import static org.springframework.boot.test.context.SpringBootTest.WebEnvironment.DEFINED_PORT; import java.util.List; import org.junit.Test; import org.junit.runner.RunWith; import org.openqa.selenium.By; import org.openqa.selenium.WebDriver; import org.openqa.selenium.WebElement; import org.springframework.boot.test.context.SpringBootTest; import org.springframework.test.context.ActiveProfiles; import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; import com.google.common.base.Predicate; /** * WorkflowController Edit Integration Test. * */ @RunWith(SpringJUnit4ClassRunner.class) @SpringBootTest(classes = Application.class, webEnvironment = DEFINED_PORT) @ActiveProfiles("dev") public class OAuthClientIntegrationTest extends SeleniumTestBase { /** * testOauth01(). * save blank oauth federation * * @throws Exception Exception */ @Test public void testOauthClient01() throws Exception { // given // when login(getDefaultEmail()); getDriver().navigate().to(getDefaultHostAndPort() + "/admin/clients"); // then assertEquals("FormKiQ Server - OAuth Clients", getTitle()); waitUntil(new Predicate<WebDriver>() { @Override public boolean apply(final WebDriver d) { WebElement e = findElements(By.xpath("//table[@id='results']")).get(0); return e.getText().contains("authorization_code"); } }); int i = 0; final int elementCount = 3; List<WebElement> e = findElements(By.xpath("//table[@id='results']/tbody/tr/td")); assertEquals(elementCount, e.size()); assertEquals("formkiq", e.get(i++).getText()); assertEquals("formkiq", e.get(i++).getText()); assertEquals("authorization_code,password,refresh_token", e.get(i++).getText()); } }