Java tutorial
/******************************************************************************* * Copyright (c) 2014 Uimirror. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Uimirror license * which accompanies this distribution, and is available at * http://www.uimirror.com/legal * * Contributors: * Uimirror Team *******************************************************************************/ package com.uimirror.auth.otp; import static org.mockito.Mockito.when; import org.junit.runner.RunWith; import org.mockito.runners.MockitoJUnitRunner; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Value; import org.springframework.boot.test.IntegrationTest; import org.springframework.boot.test.SpringApplicationContextLoader; import org.springframework.test.context.ContextConfiguration; import org.springframework.test.context.web.WebAppConfiguration; import org.springframework.web.client.RestTemplate; import com.uimirror.auth.StartApp; import com.uimirror.auth.conf.AuthMockBeanInitializr; import com.uimirror.auth.core.SomeBean; import cucumber.api.PendingException; import cucumber.api.java.Before; import cucumber.api.java.en.Given; import cucumber.api.java.en.Then; /** * @author Jay */ @ContextConfiguration(classes = { StartApp.class, AuthMockBeanInitializr.class }, loader = SpringApplicationContextLoader.class) @RunWith(MockitoJUnitRunner.class) @WebAppConfiguration @IntegrationTest("server.port:0") public class OTPStepDef { @Before public void setUp() { //MockitoAnnotations.initMocks(this); } @Value("${local.server.port}") private int port; @Autowired private SomeBean someBean; @Given("^I have an access token \"(.*?)\"$") public void i_have_an_access_token(String arg1) throws Throwable { // Write code here that turns the phrase above into concrete actions throw new PendingException(); } @Given("^I have an OTP \"(.*?)\"$") public void i_have_an_OTP(String arg1) throws Throwable { // Write code here that turns the phrase above into concrete actions throw new PendingException(); } @Given("^access token is valid$") public void access_token_is_valid() throws Throwable { // Write code here that turns the phrase above into concrete actions throw new PendingException(); } @Given("^OTP is valid$") public void otp_is_valid() throws Throwable { // Write code here that turns the phrase above into concrete actions throw new PendingException(); } @Given("^Assume user is actieve$") public void assume_user_is_actieve() throws Throwable { // Write code here that turns the phrase above into concrete actions throw new PendingException(); } @Then("^I call the otp validation service$") public void i_call_the_otp_validation_service() throws Throwable { // Write code here that turns the phrase above into concrete actions when(someBean.test()).thenReturn("Helooooooooo done"); String res = new RestTemplate().postForObject("http://localhost:8080/uim/auth/api/auth/login", new Object(), String.class); System.out.println(res); throw new PendingException(); } @Then("^I got response code \"(.*?)\"$") public void i_got_response_code(String arg1) throws Throwable { // Write code here that turns the phrase above into concrete actions throw new PendingException(); } @Then("^token as \"(.*?)\"$") public void token_as(String arg1) throws Throwable { // Write code here that turns the phrase above into concrete actions throw new PendingException(); } @Given("^Assume user is in-actieve$") public void assume_user_is_in_actieve() throws Throwable { // Write code here that turns the phrase above into concrete actions throw new PendingException(); } @Given("^access token is in-valid$") public void access_token_is_in_valid() throws Throwable { // Write code here that turns the phrase above into concrete actions throw new PendingException(); } @Given("^access token is expired$") public void access_token_is_expired() throws Throwable { // Write code here that turns the phrase above into concrete actions throw new PendingException(); } }