List of usage examples for org.apache.commons.lang RandomStringUtils randomAlphabetic
public static String randomAlphabetic(int count)
Creates a random string whose length is the number of characters specified.
Characters will be chosen from the set of alphabetic characters.
From source file:org.craftercms.studio.controller.services.rest.AbstractControllerTest.java
protected List<Site> generateSiteListMock() { List<Site> toRet = new ArrayList<Site>(); for (int i = 0; i < 5 + (int) (Math.random() * ((10 - 5) + 1)); i++) { Site site = new Site(); site.setSiteId(RandomStringUtils.randomAlphabetic(10)); site.setSiteName(RandomStringUtils.randomAlphabetic(10)); toRet.add(site);/* w w w. j a v a2s . co m*/ } return toRet; }
From source file:org.craftercms.studio.controller.services.rest.AbstractControllerTest.java
protected Version createVersionMock() { Version version = new Version(); version.setLabel(RandomStringUtils.randomNumeric(1) + "." + RandomStringUtils.randomNumeric(2)); version.setComment(RandomStringUtils.randomAlphabetic(100)); return version; }
From source file:org.craftercms.studio.controller.services.rest.AbstractControllerTest.java
protected WorkflowPackage createPackageMock() { WorkflowPackage workflowPackage = new WorkflowPackage(); workflowPackage.setId(UUID.randomUUID().toString()); workflowPackage.setState(RandomStringUtils.randomAlphabetic(8)); workflowPackage.setScheduledDate(new Date()); workflowPackage.setDescription(RandomStringUtils.randomAlphanumeric(256)); workflowPackage.setItems(generateItemListMock()); workflowPackage.setName(RandomStringUtils.randomAlphabetic(15)); Map<String, Object> props = new HashMap<String, Object>(); props.put("prop1", RandomStringUtils.randomAlphanumeric(10)); props.put("prop2", RandomStringUtils.randomAlphanumeric(10)); workflowPackage.setProperties(props); workflowPackage.setSubmittedBy(RandomStringUtils.randomAlphabetic(10)); workflowPackage.setWorkflowId(RandomStringUtils.randomAlphanumeric(15)); return workflowPackage; }
From source file:org.craftercms.studio.controller.services.rest.AbstractControllerTest.java
protected WorkflowTransition createTransitionMock() { WorkflowTransition transition = new WorkflowTransition(); transition.setId(UUID.randomUUID().toString()); transition.setName(RandomStringUtils.randomAlphabetic(10)); return transition; }
From source file:org.craftercms.studio.controller.services.rest.AbstractControllerTest.java
protected WorkflowTransitionRequest generateTransitionRequestMock() { WorkflowTransitionRequest requestObject = new WorkflowTransitionRequest(); requestObject.setPackageId(RandomStringUtils.randomAlphanumeric(10)); //requestObject.setPackageId(" "); WorkflowTransition transition = new WorkflowTransition(); transition.setId(UUID.randomUUID().toString()); transition.setName(RandomStringUtils.randomAlphabetic(10)); requestObject.setTransition(transition); Map<String, Object> params = new HashMap<String, Object>(); params.put("param1", RandomStringUtils.randomAlphanumeric(20)); params.put("param2", RandomStringUtils.randomAlphanumeric(20)); requestObject.setParams(params);/*from ww w . j a va2s. c o m*/ return requestObject; }
From source file:org.craftercms.studio.controller.services.rest.AbstractControllerTest.java
protected Form createFormDefinitionMock() { Form form = new Form(); form.setName(RandomStringUtils.randomAlphabetic(10)); form.setId(UUID.randomUUID().toString()); Map<String, Object> schema = new HashMap<String, Object>(); schema.put("param1", "param1"); schema.put("param2", "param2"); form.setSchema(schema);//w ww.j a v a 2 s .c o m form.setSiteId(RandomStringUtils.randomAlphabetic(10)); form.setSiteName(RandomStringUtils.randomAlphabetic(10)); return form; }
From source file:org.craftercms.studio.controller.services.rest.AbstractControllerTest.java
protected Configuration createModuleConfigurationMock() { Configuration module = new Configuration(); module.setModuleName(RandomStringUtils.randomAlphabetic(10)); module.setModuleType(RandomStringUtils.randomAlphabetic(10)); return module; }
From source file:org.craftercms.studio.controller.services.rest.ConfigurationControllerTest.java
@Test public void testConfiguration() throws Exception { when(this.configurationManagerMock.getConfiguration(Mockito.any(Context.class), Mockito.anyString(), Mockito.anyString())).thenReturn(createModuleConfigurationMock()); this.mockMvc//from w ww .ja va 2s . c o m .perform(get("/api/1/config/configuration/sample") .param("module", RandomStringUtils.randomAlphabetic(10)).accept(MediaType.ALL)) .andExpect(status().isOk()); verify(this.configurationManagerMock, times(1)).getConfiguration(Mockito.any(Context.class), Mockito.anyString(), Mockito.anyString()); }
From source file:org.craftercms.studio.controller.services.rest.ConfigurationControllerTest.java
@Test public void testConfigure() throws Exception { doAnswer(new Answer<Void>() { @Override//from w ww . j av a 2s . c o m public Void answer(InvocationOnMock invocationOnMock) throws Throwable { Object[] args = invocationOnMock.getArguments(); return null; } }).when(this.configurationManagerMock).configure(Mockito.any(Context.class), Mockito.anyString(), Mockito.anyString(), Mockito.any(ModuleConfiguration.class)); this.mockMvc.perform( post("/api/1/config/configure/sample").param("module", RandomStringUtils.randomAlphabetic(10)) .content(generateRequestBody(createModuleConfigurationMock())) .contentType(MediaType.APPLICATION_JSON).accept(MediaType.ALL)) .andExpect(status().isOk()); verify(this.configurationManagerMock, times(1)).configure(Mockito.any(Context.class), Mockito.anyString(), Mockito.anyString(), Mockito.any(ModuleConfiguration.class)); }
From source file:org.craftercms.studio.controller.services.rest.ConfigurationControllerTest.java
@Test public void testConfigureMissingConfiguration() throws Exception { doAnswer(new Answer<Void>() { @Override//from w w w .ja v a 2 s .c om public Void answer(InvocationOnMock invocationOnMock) throws Throwable { Object[] args = invocationOnMock.getArguments(); return null; } }).when(this.configurationManagerMock).configure(Mockito.any(Context.class), Mockito.anyString(), Mockito.anyString(), Mockito.any(ModuleConfiguration.class)); this.mockMvc .perform(post("/api/1/config/configure/sample") .param("module", RandomStringUtils.randomAlphabetic(10)).content(StringUtils.EMPTY) .contentType(MediaType.APPLICATION_JSON).accept(MediaType.ALL)) .andExpect(status().isBadRequest()); verify(this.configurationManagerMock, times(0)).configure(Mockito.any(Context.class), Mockito.anyString(), Mockito.anyString(), Mockito.any(ModuleConfiguration.class)); }