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.DependencyControllerTest.java

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

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

    String itemsJSONList = generateRequestBody(generateItemListMock());
    this.mockMvc.perform(post("/api/1/dependency/update/sample").accept(MediaType.ALL)
            .param("operation", RandomStringUtils.randomAlphabetic(10)).content(itemsJSONList.getBytes()))
            .andExpect(status().isBadRequest());

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

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

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

        @Override/*from w  ww.j  a v a2 s  .  co  m*/
        public Void answer(InvocationOnMock invocationOnMock) throws Throwable {
            Object[] args = invocationOnMock.getArguments();
            return null;
        }
    }).when(this.dependencyManagerMock).update(Mockito.any(Context.class), Mockito.anyString(),
            Mockito.anyString(), Mockito.anyListOf(Item.class));

    this.mockMvc.perform(post("/api/1/dependency/update/sample").accept(MediaType.ALL).param("itemId", "1")
            .param("operation", RandomStringUtils.randomAlphabetic(10)).content(StringUtils.EMPTY.getBytes()))
            .andExpect(status().isBadRequest());

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

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

@Test
public void testChannels() throws Exception {
    when(this.deploymentManagerMock.channels(Mockito.any(Context.class), Mockito.anyString(),
            Mockito.anyString())).thenReturn(generateChannelsList());

    this.mockMvc/*  w  w  w  . ja  va 2s.c om*/
            .perform(get("/api/1/deployment/channels/sample")
                    .param("environment", RandomStringUtils.randomAlphabetic(10)).accept(MediaType.ALL))
            .andExpect(status().isOk());

    verify(this.deploymentManagerMock, times(1)).channels(Mockito.any(Context.class), Mockito.anyString(),
            Mockito.anyString());
}

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

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

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

    this.mockMvc.perform(post("/api/1/forms/remove/sample")
            .param("type", RandomStringUtils.randomAlphabetic(10)).accept(MediaType.ALL))
            .andExpect(status().isOk());

    verify(this.formServiceMock, times(1)).remove(Mockito.any(Context.class), Mockito.anyString(),
            Mockito.anyString());
}

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

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

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

    this.mockMvc
            .perform(post("/api/1/forms/copy/sample").param("src", RandomStringUtils.randomAlphabetic(200))
                    .param("dst", RandomStringUtils.randomAlphabetic(200)).accept(MediaType.ALL))
            .andExpect(status().isOk());

    verify(this.formServiceMock, times(1)).copy(Mockito.any(Context.class), Mockito.anyString(),
            Mockito.anyString(), Mockito.anyString());
}

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

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

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

    this.mockMvc.perform(post("/api/1/forms/copy/sample").param("dst", RandomStringUtils.randomAlphabetic(200))
            .accept(MediaType.ALL)).andExpect(status().isBadRequest());

    verify(this.formServiceMock, times(0)).copy(Mockito.any(Context.class), Mockito.anyString(),
            Mockito.anyString(), Mockito.anyString());
}

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

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

        @Override//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.formServiceMock).copy(Mockito.any(Context.class), Mockito.anyString(), Mockito.anyString(),
            Mockito.anyString());

    this.mockMvc.perform(post("/api/1/forms/copy/sample").param("src", RandomStringUtils.randomAlphabetic(200))
            .accept(MediaType.ALL)).andExpect(status().isBadRequest());

    verify(this.formServiceMock, times(0)).copy(Mockito.any(Context.class), Mockito.anyString(),
            Mockito.anyString(), Mockito.anyString());
}

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

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

        @Override//from   ww w .  j a  v a2 s  .co m
        public Void answer(InvocationOnMock invocationOnMock) throws Throwable {
            Object[] args = invocationOnMock.getArguments();
            return null;
        }
    }).when(this.contentManagerMock).copy(Mockito.any(Context.class), Mockito.anyListOf(Item.class),
            Mockito.anyString(), Mockito.anyBoolean());

    String itemsJSONList = generateRequestBody(generateItemListMock());
    this.mockMvc.perform(post("/api/1/content/copy/site").accept(MediaType.ALL)
            .param("destinationPath", RandomStringUtils.randomAlphabetic(10))
            .param("includeChildren", (new Random()).nextBoolean() ? "true" : "false")
            .content(itemsJSONList.getBytes())).andExpect(status().isOk());

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

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

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

        @Override//www  . j  av  a 2  s  .co m
        public Void answer(InvocationOnMock invocationOnMock) throws Throwable {
            Object[] args = invocationOnMock.getArguments();
            return null;
        }
    }).when(this.contentManagerMock).copy(Mockito.any(Context.class), Mockito.anyListOf(Item.class),
            Mockito.anyString(), Mockito.anyBoolean());

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

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

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

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

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

    this.mockMvc.perform(post("/api/1/content/copy/site").accept(MediaType.ALL)
            .param("destinationPath", RandomStringUtils.randomAlphabetic(10))
            .param("includeChildren", (new Random()).nextBoolean() ? "true" : "false")
            .content(StringUtils.EMPTY.getBytes())).andExpect(status().isBadRequest());

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