Java Code Examples for io.restassured.module.mockmvc.RestAssuredMockMvc#webAppContextSetup()

The following examples show how to use io.restassured.module.mockmvc.RestAssuredMockMvc#webAppContextSetup() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: UserServiceBase.java    From code-examples with MIT License 6 votes vote down vote up
@Before
public void setup() {
  User savedUser = new User();
  savedUser.setFirstName("Arthur");
  savedUser.setLastName("Dent");
  savedUser.setId(42L);
  when(userRepository.save(any(User.class))).thenReturn(savedUser);
  RestAssuredMockMvc.webAppContextSetup(webApplicationContext);

  when(userRepository.findById(eq(42L))).thenReturn(Optional.of(savedUser));
}
 
Example 2
Source File: UserControllerIntegrationTest.java    From java-starthere with MIT License 5 votes vote down vote up
@Before
public void setUp() throws Exception
{
    RestAssuredMockMvc.webAppContextSetup(webApplicationContext);

    mockMvc = MockMvcBuilders.webAppContextSetup(webApplicationContext)
                             .apply(SecurityMockMvcConfigurers.springSecurity())
                             .build();
}
 
Example 3
Source File: MessageControllerIntegrationTest.java    From holdmail with Apache License 2.0 5 votes vote down vote up
@Before
public void setUp() throws Exception {

    super.setUp();

    smtpClient = new TestMailClient(smtpServerPort, "localhost");
    RestAssuredMockMvc.webAppContextSetup(webAppCtx);
}
 
Example 4
Source File: UserControllerUnitTest.java    From java-starthere with MIT License 4 votes vote down vote up
@Before
public void setUp() throws Exception
{
    userList = new ArrayList<>();

    Role r1 = new Role("admin");
    r1.setRoleid(1);
    Role r2 = new Role("user");
    r2.setRoleid(2);
    Role r3 = new Role("data");
    r3.setRoleid(3);

    // admin, data, user
    ArrayList<UserRoles> admins = new ArrayList<>();
    admins.add(new UserRoles(new User(), r1));
    admins.add(new UserRoles(new User(), r2));
    admins.add(new UserRoles(new User(), r3));
    User u1 = new User("admin", "ILuvM4th!", "[email protected]", admins);

    u1.getUseremails()
      .add(new Useremail(u1, "[email protected]"));
    u1.getUseremails().get(0).setUseremailid(10);

    u1.getUseremails()
      .add(new Useremail(u1, "[email protected]"));
    u1.getUseremails().get(1).setUseremailid(11);

    u1.setUserid(101);
    userList.add(u1);

    // data, user
    ArrayList<UserRoles> datas = new ArrayList<>();
    datas.add(new UserRoles(new User(), r3));
    datas.add(new UserRoles(new User(), r2));
    User u2 = new User("cinnamon", "1234567", "[email protected]", datas);

    u2.getUseremails()
      .add(new Useremail(u2, "[email protected]"));
    u2.getUseremails().get(0).setUseremailid(20);

    u2.getUseremails()
      .add(new Useremail(u2, "[email protected]"));
    u2.getUseremails().get(1).setUseremailid(21);

    u2.getUseremails()
      .add(new Useremail(u2, "[email protected]"));
    u2.getUseremails().get(2).setUseremailid(22);

    u2.setUserid(102);
    userList.add(u2);

    // user
    ArrayList<UserRoles> users = new ArrayList<>();
    users.add(new UserRoles(new User(), r1));
    User u3 = new User("testingbarn", "ILuvM4th!", "[email protected]", users);

    u3.getUseremails()
      .add(new Useremail(u3, "[email protected]"));
    u3.getUseremails().get(0).setUseremailid(30);

    u3.setUserid(103);
    userList.add(u3);

    users = new ArrayList<>();
    users.add(new UserRoles(new User(), r2));
    User u4 = new User("testingcat", "password", "[email protected]", users);
    u4.setUserid(104);
    userList.add(u4);

    users = new ArrayList<>();
    users.add(new UserRoles(new User(), r2));
    User u5 = new User("testingdog", "password", "[email protected]", users);
    u5.setUserid(105);
    userList.add(u5);

    System.out.println("\n*** Seed Data ***");
    for (User u : userList)
    {
        System.out.println(u);
    }
    System.out.println("*** Seed Data ***\n");

    RestAssuredMockMvc.webAppContextSetup(webApplicationContext);

    mockMvc = MockMvcBuilders.webAppContextSetup(webApplicationContext)
                             .apply(SecurityMockMvcConfigurers.springSecurity())
                             .build();
}
 
Example 5
Source File: BaseApiTest.java    From ecommerce-order-service with Apache License 2.0 4 votes vote down vote up
@BeforeEach
public void init() {
    RestAssuredMockMvc.webAppContextSetup(context);
}
 
Example 6
Source File: BaseApiTest.java    From ecommerce-product-service with Apache License 2.0 4 votes vote down vote up
@BeforeEach
public void init() {
    RestAssuredMockMvc.webAppContextSetup(context);
}
 
Example 7
Source File: ContractVerifierBase.java    From friendly-id with Apache License 2.0 4 votes vote down vote up
@Before
public void setUp() {
	RestAssuredMockMvc.webAppContextSetup(context);
}
 
Example 8
Source File: BuildInfoIntegrationTest.java    From holdmail with Apache License 2.0 4 votes vote down vote up
@Before
public void setUp() throws Exception {

    super.setUp();
    RestAssuredMockMvc.webAppContextSetup(webAppCtx);
}
 
Example 9
Source File: MessagingBase.java    From spring-cloud-contract with Apache License 2.0 4 votes vote down vote up
@BeforeEach
public void setup() {
	RestAssuredMockMvc.webAppContextSetup(this.context);
}
 
Example 10
Source File: BeerIntoxicationBase.java    From spring-cloud-contract-samples with Apache License 2.0 4 votes vote down vote up
@BeforeEach
public void setup() {
	//remove::start[]
	RestAssuredMockMvc.webAppContextSetup(this.webApplicationContext);
	//remove::end[]
}
 
Example 11
Source File: BeerIntoxicationBase.java    From spring-cloud-contract-samples with Apache License 2.0 4 votes vote down vote up
@Before
public void setup() {
	//remove::start[]
	RestAssuredMockMvc.webAppContextSetup(this.webApplicationContext);
	//remove::end[]
}
 
Example 12
Source File: BeerRestBase.java    From spring-cloud-contract-samples with Apache License 2.0 4 votes vote down vote up
@Before
public void setup() {
	RestAssuredMockMvc.webAppContextSetup(this.context);
}
 
Example 13
Source File: BeerIntoxicationBase.java    From spring-cloud-contract-samples with Apache License 2.0 4 votes vote down vote up
@Before
public void setup() {
	//remove::start[]
	RestAssuredMockMvc.webAppContextSetup(this.webApplicationContext);
	//remove::end[]
}
 
Example 14
Source File: BeerIntoxicationBase.java    From spring-cloud-contract-samples with Apache License 2.0 4 votes vote down vote up
@Before
public void setup() {
	//remove::start[]
	RestAssuredMockMvc.webAppContextSetup(this.webApplicationContext);
	//remove::end[]
}
 
Example 15
Source File: CourseControllerIntegrationTest.java    From tutorials with MIT License 4 votes vote down vote up
@Before
public void initialiseRestAssuredMockMvcWebApplicationContext() {
    RestAssuredMockMvc.webAppContextSetup(webApplicationContext);
}