Example usage for org.apache.commons.lang RandomStringUtils randomAlphabetic

List of usage examples for org.apache.commons.lang RandomStringUtils randomAlphabetic

Introduction

In this page you can find the example usage for org.apache.commons.lang RandomStringUtils randomAlphabetic.

Prototype

public static String randomAlphabetic(int count) 

Source Link

Document

Creates a random string whose length is the number of characters specified.

Characters will be chosen from the set of alphabetic characters.

Usage

From source file:org.craftercms.studio.controller.services.rest.RepositoryControllerTest.java

@Test
public void testMove() throws Exception {
    doAnswer(new Answer<Void>() {

        @Override/*from  w ww.  ja  va 2  s  .com*/
        public Void answer(InvocationOnMock invocationOnMock) throws Throwable {
            Object[] args = invocationOnMock.getArguments();
            return null;
        }
    }).when(this.contentManagerMock).move(Mockito.any(Context.class), Mockito.anyListOf(Item.class),
            Mockito.anyString());

    String itemsJSONList = generateRequestBody(generateItemListMock());
    this.mockMvc.perform(post("/api/1/content/move/site").accept(MediaType.ALL)
            .param("destinationPath", RandomStringUtils.randomAlphabetic(10)).content(itemsJSONList.getBytes()))
            .andExpect(status().isOk());

    verify(this.contentManagerMock, times(1)).move(Mockito.any(Context.class), Mockito.anyListOf(Item.class),
            Mockito.anyString());
}

From source file:org.craftercms.studio.controller.services.rest.RepositoryControllerTest.java

@Test
public void testMoveMissingItems() throws Exception {
    doAnswer(new Answer<Void>() {

        @Override/*w w  w .j av a2 s. c o m*/
        public Void answer(InvocationOnMock invocationOnMock) throws Throwable {
            Object[] args = invocationOnMock.getArguments();
            return null;
        }
    }).when(this.contentManagerMock).move(Mockito.any(Context.class), Mockito.anyListOf(Item.class),
            Mockito.anyString());

    this.mockMvc.perform(post("/api/1/content/move/site").accept(MediaType.ALL)
            .param("destinationPath", RandomStringUtils.randomAlphabetic(10))
            .content(StringUtils.EMPTY.getBytes())).andExpect(status().isBadRequest());

    verify(this.contentManagerMock, times(0)).move(Mockito.any(Context.class), Mockito.anyListOf(Item.class),
            Mockito.anyString());
}

From source file:org.craftercms.studio.controller.services.rest.SecurityControllerTest.java

@Test
public void testLogin() throws Exception {
    when(this.securityServiceMock.login(Mockito.any(URL.class), Mockito.anyString(), Mockito.anyString()))
            .thenReturn(null);/*from   w ww .  ja  va  2s.  c o m*/

    mockMvc.perform(post("/api/1/security/login").param("username", RandomStringUtils.randomAlphabetic(10))
            .param("password", RandomStringUtils.randomAlphanumeric(10)).accept(MediaType.ALL))
            .andExpect(status().isOk());

    verify(this.securityServiceMock, times(1)).login(Mockito.any(URL.class), Mockito.anyString(),
            Mockito.anyString());
}

From source file:org.craftercms.studio.controller.services.rest.SecurityControllerTest.java

@Test
public void testLoginMissingPassword() throws Exception {
    when(this.securityServiceMock.login(Mockito.any(URL.class), Mockito.anyString(), Mockito.anyString()))
            .thenReturn(null);/* w  ww.ja  v a  2  s.  co  m*/

    mockMvc.perform(post("/api/1/security/login").param("username", RandomStringUtils.randomAlphabetic(10))
            .accept(MediaType.ALL)).andExpect(status().isBadRequest());

    verify(this.securityServiceMock, times(0)).login(Mockito.any(URL.class), Mockito.anyString(),
            Mockito.anyString());
}

From source file:org.craftercms.studio.controller.services.rest.SecurityControllerTest.java

@Test
public void testUsers() throws Exception {
    when(this.securityServiceMock.getUsers(Mockito.any(Context.class), Mockito.anyString()))
            .thenReturn(generateListOfUsersMock());

    mockMvc.perform(get("/api/1/security/users").param("site", RandomStringUtils.randomAlphabetic(10))
            .accept(MediaType.ALL)).andExpect(status().isOk());

    verify(this.securityServiceMock, times(1)).getUsers(Mockito.any(Context.class), Mockito.anyString());
}

From source file:org.craftercms.studio.controller.services.rest.SecurityControllerTest.java

@Test
public void testRemoveUser() throws Exception {
    doAnswer(new Answer<Void>() {

        @Override/*from ww w .  j a v  a  2s  .  c o m*/
        public Void answer(InvocationOnMock invocationOnMock) throws Throwable {
            Object[] args = invocationOnMock.getArguments();
            return null;
        }
    }).when(this.securityServiceMock).removeUser(Mockito.any(Context.class), Mockito.anyString());

    mockMvc.perform(post("/api/1/security/remove_user").param("user", RandomStringUtils.randomAlphabetic(10))
            .accept(MediaType.ALL)).andExpect(status().isOk());

    verify(this.securityServiceMock, times(1)).removeUser(Mockito.any(Context.class), Mockito.anyString());
}

From source file:org.craftercms.studio.controller.services.rest.SecurityControllerTest.java

@Test
public void testPermissions() throws Exception {
    when(this.securityServiceMock.getPermissions(Mockito.any(Context.class), Mockito.anyString(),
            Mockito.anyString())).thenReturn(generateListOfPermissionsMock());

    mockMvc.perform(get("/api/1/security/permissions").param("site", RandomStringUtils.randomAlphabetic(10))
            .param("itemId", UUID.randomUUID().toString()).accept(MediaType.ALL)).andExpect(status().isOk());

    verify(this.securityServiceMock, times(1)).getPermissions(Mockito.any(Context.class), Mockito.anyString(),
            Mockito.anyString());/*from   w w  w.java  2s  .  c o m*/
}

From source file:org.craftercms.studio.controller.services.rest.SecurityControllerTest.java

@Test
public void testPermissionsMissingItemId() throws Exception {
    when(this.securityServiceMock.getPermissions(Mockito.any(Context.class), Mockito.anyString(),
            Mockito.anyString())).thenReturn(generateListOfPermissionsMock());

    mockMvc.perform(get("/api/1/security/permissions").param("site", RandomStringUtils.randomAlphabetic(10))
            .accept(MediaType.ALL)).andExpect(status().isBadRequest());

    verify(this.securityServiceMock, times(0)).getPermissions(Mockito.any(Context.class), Mockito.anyString(),
            Mockito.anyString());//from   w  w w .ja  v a2s  . c om
}

From source file:org.craftercms.studio.controller.services.rest.WorkflowControllerTest.java

@Test
public void testPackages() throws Exception {
    when(this.workflowManagerMock.getPackages(Mockito.anyString(),
            Mockito.anyListOf(WorkflowPackageFilter.class))).thenReturn(generateListOfPackages());

    this.mockMvc.perform(get("/api/1/workflow/packages/sample")
            .param("filters", RandomStringUtils.randomAlphabetic(10), RandomStringUtils.randomAlphabetic(10))
            .accept(MediaType.ALL)).andExpect(status().isOk());

    verify(this.workflowManagerMock, times(1)).getPackages(Mockito.anyString(),
            Mockito.anyListOf(WorkflowPackageFilter.class));
}

From source file:org.craftercms.studio.impl.AbstractManagerTest.java

protected WorkflowTransition createWorkflowTransitionMock() {
    WorkflowTransition transition = new WorkflowTransition();
    transition.setId(UUID.randomUUID().toString());
    transition.setName(RandomStringUtils.randomAlphabetic(10));
    return transition;
}