List of usage examples for java.util Map clear
void clear();
From source file:ddf.catalog.pubsub.PredicateTest.java
@Test public void testContextualQuery() throws Exception { String methodName = "testContextualQuery"; LOGGER.debug("*************** START: " + methodName + " *****************"); String searchPhrase = "serengeti event"; MockQuery query = new MockQuery(); query.addContextualFilter(searchPhrase, null); SubscriptionFilterVisitor visitor = new SubscriptionFilterVisitor(); Predicate predicate = (Predicate) query.getFilter().accept(visitor, null); MetacardImpl metacard = new MetacardImpl(); metacard.setId("ABC123"); metacard.setMetadata(TestDataLibrary.getCatAndDogEntry()); HashMap<String, Object> properties = new HashMap<>(); properties.put(PubSubConstants.HEADER_ID_KEY, metacard.getId()); properties.put(PubSubConstants.HEADER_ENTRY_KEY, metacard); properties.put(PubSubConstants.HEADER_OPERATION_KEY, PubSubConstants.CREATE); Map<String, Object> contextualMap = constructContextualMap(metacard); properties.put(PubSubConstants.HEADER_CONTEXTUAL_KEY, contextualMap); // Above Pulled from PubSubProviderImpl Event testEvent = new Event("topic", properties); assertTrue(predicate.matches(testEvent)); contextualMap.clear(); properties.clear();/*from ww w .java2s .c om*/ metacard.setMetadata(TestDataLibrary.getDogEntry()); Directory index1 = ContextualEvaluator.buildIndex(metacard.getMetadata()); contextualMap.put("DEFAULT_INDEX", index1); contextualMap.put("METADATA", metacard.getMetadata()); properties.put(PubSubConstants.HEADER_CONTEXTUAL_KEY, contextualMap); properties.put(PubSubConstants.HEADER_ID_KEY, metacard.getId()); properties.put(PubSubConstants.HEADER_ENTRY_KEY, metacard); properties.put(PubSubConstants.HEADER_OPERATION_KEY, PubSubConstants.CREATE); testEvent = new Event("topic", properties); assertFalse(predicate.matches(testEvent)); LOGGER.debug("*************** END: " + methodName + " *****************"); }
From source file:org.apache.jmeter.protocol.http.sampler.HTTPHC4Impl.java
/** * //from w w w . j a v a 2s.c om */ private void closeThreadLocalConnections() { // Does not need to be synchronised, as all access is from same thread Map<HttpClientKey, HttpClient> mapHttpClientPerHttpClientKey = HTTPCLIENTS_CACHE_PER_THREAD_AND_HTTPCLIENTKEY .get(); if (mapHttpClientPerHttpClientKey != null) { for (HttpClient cl : mapHttpClientPerHttpClientKey.values()) { ((AbstractHttpClient) cl).clearRequestInterceptors(); ((AbstractHttpClient) cl).clearResponseInterceptors(); ((AbstractHttpClient) cl).close(); cl.getConnectionManager().shutdown(); } mapHttpClientPerHttpClientKey.clear(); } }
From source file:com.webcohesion.ofx4j.io.TestAggregateMarshaller.java
/** * test marshal//from w ww . ja v a 2s. com */ public void testMarshal() throws Exception { final Map<String, String> elementValuesWritten = new TreeMap<String, String>(); final Map<String, String> headersWritten = new TreeMap<String, String>(); final List<String> aggregatesStarted = new ArrayList<String>(); final List<String> aggregatesEnded = new ArrayList<String>(); AggregateExample example = new AggregateExample(); example.setHeader1("header1"); example.setHeader2("header2"); example.setElement1("root-element1"); AggregateExample2 child1 = new AggregateExample2(); child1.setElement("child1-element1"); example.setAggregate1(child1); AggregateExample2 child2 = new AggregateExample2(); child2.setElement("child2-element1"); example.setAggregate2(child2); AggregateExample2 child3 = new AggregateExample2(); child3.setElement("child3-element1"); AggregateExample3 child4 = new AggregateExample3(); child4.setElement("child4-element1"); example.setAggregateList(Arrays.asList(child3, child4)); new AggregateMarshaller().marshal(example, new OFXWriter() { public void writeHeaders(Map<String, String> headers) throws IOException { headersWritten.putAll(headers); } public void writeStartAggregate(String aggregateName) throws IOException { aggregatesStarted.add(aggregateName); } public void writeElement(String name, String value) throws IOException { elementValuesWritten.put(value, name); } public void writeEndAggregate(String aggregateName) throws IOException { aggregatesEnded.add(aggregateName); } public void close() throws IOException { //we'll clear these to make sure the tests fail if close() was called. headersWritten.clear(); aggregatesEnded.clear(); aggregatesStarted.clear(); elementValuesWritten.clear(); } }); assertEquals(2, headersWritten.size()); assertEquals("header1", headersWritten.get("HEADER1")); assertEquals("header2", headersWritten.get("ANOTHERHEADER")); assertEquals(5, elementValuesWritten.size()); assertEquals("SOMEELEMENT", elementValuesWritten.get("root-element1")); assertEquals("EXAMPLE2EL1", elementValuesWritten.get("child1-element1")); assertEquals("EXAMPLE2EL1", elementValuesWritten.get("child2-element1")); assertEquals("EXAMPLE2EL1", elementValuesWritten.get("child3-element1")); assertEquals("EXAMPLE3EL1", elementValuesWritten.get("child4-element1")); assertEquals(5, aggregatesStarted.size()); Iterator<String> it = aggregatesStarted.iterator(); assertEquals("EXAMPLE", it.next()); assertEquals("EXAMPLE2", it.next()); assertEquals("EXAMPLE2", it.next()); assertEquals("EXAMPLE3", it.next()); assertEquals("DIFFERENT", it.next()); assertEquals(5, aggregatesEnded.size()); it = aggregatesEnded.iterator(); assertEquals("EXAMPLE2", it.next()); assertEquals("EXAMPLE2", it.next()); assertEquals("EXAMPLE3", it.next()); assertEquals("DIFFERENT", it.next()); assertEquals("EXAMPLE", it.next()); }
From source file:net.sf.appstatus.web.pages.ServicesPage.java
@Override public void doGet(StatusWebHandler webHandler, HttpServletRequest req, HttpServletResponse resp) throws UnsupportedEncodingException, IOException { setup(resp, "text/html"); ServletOutputStream os = resp.getOutputStream(); Map<String, String> valuesMap = new HashMap<String, String>(); List<IService> services = webHandler.getAppStatus().getServices(); Collections.sort(services);// w w w . j a v a2s . c om StrBuilder sbServicesTable = new StrBuilder(); if (HtmlUtils.generateBeginTable(sbServicesTable, services.size())) { HtmlUtils.generateHeaders(sbServicesTable, "", "Group", "Name", "Hits", "Cache", "Running", "min", "max", "avg", "nested", "min (c)", "max (c)", "avg (c)", "nested (c)", "Errors", "Failures", "Hit rate"); for (IService service : services) { HtmlUtils.generateRow(sbServicesTable, Resources.STATUS_JOB, service.getGroup(), service.getName(), service.getHits(), service.getCacheHits() + getPercent(service.getCacheHits(), service.getHits()), service.getRunning(), service.getMinResponseTime(), service.getMaxResponseTime(), Math.round(service.getAvgResponseTime()), Math.round(service.getAvgNestedCalls()), service.getMinResponseTimeWithCache(), service.getMaxResponseTimeWithCache(), Math.round(service.getAvgResponseTimeWithCache()), Math.round(service.getAvgNestedCallsWithCache()), service.getErrors() + getPercent(service.getErrors(), service.getHits()), service.getFailures() + getPercent(service.getFailures(), service.getHits()), getRate(service.getCurrentRate())); } HtmlUtils.generateEndTable(sbServicesTable, services.size()); } // generating content valuesMap.put("servicesTable", sbServicesTable.toString()); String content = HtmlUtils.applyLayout(valuesMap, PAGECONTENTLAYOUT); valuesMap.clear(); valuesMap.put("content", content); // generating page os.write(getPage(webHandler, valuesMap).getBytes(ENCODING)); }
From source file:com.evolveum.midpoint.schema.xjc.schema.SchemaProcessor.java
private void updateClassAnnotation(ClassOutline classOutline) { try {/*from w w w . jav a 2s. c om*/ JDefinedClass definedClass = classOutline.implClass; List<JAnnotationUse> existingAnnotations = (List<JAnnotationUse>) getAnnotations(definedClass); for (JAnnotationUse annotation : existingAnnotations) { if (isAnnotationTypeOf(annotation, XmlAccessorType.class)) { Field field = getField(JAnnotationUse.class, "memberValues"); field.setAccessible(true); Map<String, Object> map = (Map<String, Object>) field.get(annotation); field.setAccessible(false); map.clear(); annotation.param("value", XmlAccessType.PROPERTY); } if (isAnnotationTypeOf(annotation, XmlType.class)) { Field field = getField(JAnnotationUse.class, "memberValues"); field.setAccessible(true); Map<String, Object> map = (Map<String, Object>) field.get(annotation); Object propOrder = map.get("propOrder"); if (propOrder != null) { JAnnotationArrayMember paramArray = (JAnnotationArrayMember) propOrder; Field valField = getField(JAnnotationArrayMember.class, "values"); valField.setAccessible(true); List<JAnnotationValue> values = (List<JAnnotationValue>) valField.get(paramArray); for (int i = 0; i < values.size(); i++) { JAnnotationValue jAnnValue = values.get(i); String value = extractString(jAnnValue); if (value.startsWith("_")) { paramArray.param(value.substring(1)); values.set(i, values.get(values.size() - 1)); values.remove(values.size() - 1); } String valAfter = extractString(values.get(i)); // System.out.println("PPPPPPPPPPPPPPPPPPP: "+value+" -> "+valAfter); } valField.setAccessible(false); } field.setAccessible(false); } } } catch (Exception ex) { throw new RuntimeException(ex.getMessage(), ex); } }
From source file:com.sldeditor.test.unit.tool.vector.VectorToolTest.java
/** * Test method for {@link com.sldeditor.tool.vector.VectorTool#VectorTool(com.sldeditor.common.SLDEditorInterface)}. *//*w w w . ja v a2s . c om*/ @Test public void testVectorToolFileDataSource() { TestMissingSLDAttributes testAttribute = new TestMissingSLDAttributes(); List<CheckAttributeInterface> checkList = new ArrayList<CheckAttributeInterface>(); checkList.add(testAttribute); CheckAttributeFactory.setOverideCheckList(checkList); String testsldfile = "/polygon/sld/polygon_polygonwithdefaultlabel.sld"; TestSLDEditor testSLDEditor = null; try { testSLDEditor = TestSLDEditor.createAndShowGUI2(null, null, true, null); } catch (Exception e) { e.printStackTrace(); } InputStream inputStream = VectorToolTest.class.getResourceAsStream(testsldfile); if (inputStream == null) { Assert.assertNotNull("Failed to find sld test file : " + testsldfile, inputStream); } else { File f = null; try { f = stream2file(inputStream); try { testSLDEditor.openFile(f.toURI().toURL()); } catch (NullPointerException nullException) { nullException.printStackTrace(); StackTraceElement[] stackTraceElements = nullException.getStackTrace(); System.out.println(stackTraceElements[0].getMethodName()); } f.delete(); } catch (IOException e1) { e1.printStackTrace(); } } // Fields extracted from the SLD file DataSourceInterface dataSource = DataSourceFactory.createDataSource(null); Collection<PropertyDescriptor> propertyList = dataSource.getPropertyDescriptorList(); assertEquals(2, propertyList.size()); Map<String, PropertyDescriptor> map = new HashMap<String, PropertyDescriptor>(); for (PropertyDescriptor property : propertyList) { map.put(property.getName().getLocalPart(), property); } AttributeDescriptor name = (AttributeDescriptor) map.get("name"); assertNotNull(name); GeometryDescriptor geometry = (GeometryDescriptor) map.get("geom"); assertNotNull(geometry); File tempFolder = Files.createTempDir(); TestVectorTool vectorTool = new TestVectorTool(testSLDEditor); try { // Set a shape file as a data source - that matches the SLD File matchingShpFile = extractShapeFile(tempFolder, "/test/sld_cookbook_polygon.zip"); FileTreeNode fileTreeNode = new FileTreeNode(matchingShpFile.getParentFile(), matchingShpFile.getName()); vectorTool.testSetDataSource(fileTreeNode); dataSource = DataSourceFactory.createDataSource(null); propertyList = dataSource.getPropertyDescriptorList(); assertEquals(3, propertyList.size()); map.clear(); for (PropertyDescriptor property : propertyList) { map.put(property.getName().getLocalPart(), property); } name = (AttributeDescriptor) map.get("name"); assertNotNull(name); geometry = (GeometryDescriptor) map.get("the_geom"); assertNotNull(geometry); AttributeDescriptor pop = (AttributeDescriptor) map.get("pop"); assertNotNull(pop); // Set a shape file as a data source - that does not match the SLD File nonMatchingShpFile = extractShapeFile(tempFolder, "/test/states.zip"); FileTreeNode fileTreeNode2 = new FileTreeNode(nonMatchingShpFile.getParentFile(), nonMatchingShpFile.getName()); vectorTool.testSetDataSource(fileTreeNode2); dataSource = DataSourceFactory.createDataSource(null); propertyList = dataSource.getPropertyDescriptorList(); assertEquals(23, propertyList.size()); map.clear(); for (PropertyDescriptor property : propertyList) { map.put(property.getName().getLocalPart(), property); } name = (AttributeDescriptor) map.get("name"); assertNull(name); geometry = (GeometryDescriptor) map.get("the_geom"); assertNotNull(geometry); pop = (AttributeDescriptor) map.get("pop"); assertNull(pop); assertEquals(1, testAttribute.getMissingFieldList().size()); assertEquals("name", testAttribute.getMissingFieldList().get(0)); // Create SLD from shape file vectorTool.testImportFile(fileTreeNode); dataSource = DataSourceFactory.createDataSource(null); propertyList = dataSource.getPropertyDescriptorList(); assertEquals(3, propertyList.size()); map.clear(); for (PropertyDescriptor property : propertyList) { map.put(property.getName().getLocalPart(), property); } name = (AttributeDescriptor) map.get("name"); assertNotNull(name); geometry = (GeometryDescriptor) map.get("the_geom"); assertNotNull(geometry); pop = (AttributeDescriptor) map.get("pop"); assertNotNull(pop); // Release locks dataSource.reset(); } catch (IOException e) { e.printStackTrace(); fail(); } // Tidy up so the remaining unit tests are ok JFrame frame = testSLDEditor.getApplicationFrame(); frame.dispatchEvent(new WindowEvent(frame, WindowEvent.WINDOW_CLOSING)); testSLDEditor = null; clearDown(); // Delete the shape files we extracted purgeDirectory(tempFolder); }
From source file:com.apm4all.tracy.TracyTest.java
@Test public void testGetEventsAsJsonString_withAnnotations() throws InterruptedException { // TODO: This example should have Int and Long annotations but jsonEventWithoutBrackets will need to be extended Tracy.setContext(TASK_ID_VALUE, PARENT_OPT_ID_VALUE, COMPONENT_VALUE); Tracy.before(L1_LABEL_NAME);/*from w ww. j a v a 2 s. c o m*/ Tracy.annotate("sizeOut", "10", "sizeIn", "2000"); Thread.sleep(10); Tracy.after(L1_LABEL_NAME); Tracy.before(L11_LABEL_NAME); Thread.sleep(10); Tracy.after(L11_LABEL_NAME); Map<String, Object> annotations = new HashMap<String, Object>(); String actualWithoutBrackets = null; annotations.put("sizeOut", "10"); annotations.put("sizeIn", "2000"); List<String> events = Tracy.getEventsAsJson(); List<Map<String, Object>> eventsAsMaps = Tracy.getEventsAsMaps(); assertEquals(2, events.size()); String jsonEvent1 = jsonEventWithoutBrackets(TASK_ID_VALUE, PARENT_OPT_ID_VALUE, L1_LABEL_NAME, eventsAsMaps.get(0).get("optId"), eventsAsMaps.get(0).get("msecBefore"), eventsAsMaps.get(0).get("msecAfter"), eventsAsMaps.get(0).get("msecElapsed"), eventsAsMaps.get(0).get("host"), eventsAsMaps.get(0).get("component"), annotations); assertTrue(startsWithBracket(events.get(0))); assertTrue(endsWithBracket(events.get(0))); actualWithoutBrackets = removeBrackets(events.get(0)); assertEquals(sortJsonEvent(actualWithoutBrackets), sortJsonEvent(jsonEvent1)); annotations.clear(); String jsonEvent2 = jsonEventWithoutBrackets(TASK_ID_VALUE, PARENT_OPT_ID_VALUE, L11_LABEL_NAME, eventsAsMaps.get(1).get("optId"), eventsAsMaps.get(1).get("msecBefore"), eventsAsMaps.get(1).get("msecAfter"), eventsAsMaps.get(1).get("msecElapsed"), eventsAsMaps.get(1).get("host"), eventsAsMaps.get(1).get("component"), annotations); assertTrue(startsWithBracket(events.get(1))); assertTrue(endsWithBracket(events.get(1))); actualWithoutBrackets = removeBrackets(events.get(1)); assertEquals(sortJsonEvent(actualWithoutBrackets), sortJsonEvent(jsonEvent2)); Tracy.clearContext(); }
From source file:org.activiti.rest.service.api.form.FormDataResourceTest.java
@Deployment public void testSubmitFormData() throws Exception { Map<String, Object> variableMap = new HashMap<String, Object>(); variableMap.put("SpeakerName", "John Doe"); Address address = new Address(); variableMap.put("address", address); ProcessInstance processInstance = runtimeService.startProcessInstanceByKey("oneTaskProcess", variableMap); String processInstanceId = processInstance.getId(); String processDefinitionId = processInstance.getProcessDefinitionId(); Task task = taskService.createTaskQuery().processInstanceId(processInstanceId).singleResult(); ObjectNode requestNode = objectMapper.createObjectNode(); requestNode.put("taskId", task.getId()); ArrayNode propertyArray = objectMapper.createArrayNode(); requestNode.put("properties", propertyArray); ObjectNode propNode = objectMapper.createObjectNode(); propNode.put("id", "room"); propNode.put("value", 123l); propertyArray.add(propNode);// w ww .j a v a2 s. co m HttpPost httpPost = new HttpPost( SERVER_URL_PREFIX + RestUrls.createRelativeResourceUrl(RestUrls.URL_FORM_DATA)); httpPost.setEntity(new StringEntity(requestNode.toString())); closeResponse(executeRequest(httpPost, HttpStatus.SC_INTERNAL_SERVER_ERROR)); propNode = objectMapper.createObjectNode(); propNode.put("id", "street"); propNode.put("value", "test"); propertyArray.add(propNode); httpPost.setEntity(new StringEntity(requestNode.toString())); closeResponse(executeRequest(httpPost, HttpStatus.SC_NO_CONTENT)); task = taskService.createTaskQuery().processInstanceId(processInstanceId).singleResult(); assertNull(task); processInstance = runtimeService.createProcessInstanceQuery().processInstanceId(processInstanceId) .singleResult(); assertNull(processInstance); List<HistoricVariableInstance> variables = historyService.createHistoricVariableInstanceQuery() .processInstanceId(processInstanceId).list(); Map<String, HistoricVariableInstance> historyMap = new HashMap<String, HistoricVariableInstance>(); for (HistoricVariableInstance historicVariableInstance : variables) { historyMap.put(historicVariableInstance.getVariableName(), historicVariableInstance); } assertEquals("123", historyMap.get("room").getValue()); assertEquals(processInstanceId, historyMap.get("room").getProcessInstanceId()); processInstance = runtimeService.startProcessInstanceByKey("oneTaskProcess", variableMap); processInstanceId = processInstance.getId(); task = taskService.createTaskQuery().processInstanceId(processInstanceId).singleResult(); requestNode.put("taskId", task.getId()); propNode = objectMapper.createObjectNode(); propNode.put("id", "direction"); propNode.put("value", "nowhere"); propertyArray.add(propNode); httpPost.setEntity(new StringEntity(requestNode.toString())); closeResponse(executeRequest(httpPost, HttpStatus.SC_BAD_REQUEST)); propNode.put("value", "up"); httpPost.setEntity(new StringEntity(requestNode.toString())); closeResponse(executeRequest(httpPost, HttpStatus.SC_NO_CONTENT)); task = taskService.createTaskQuery().processInstanceId(processInstanceId).singleResult(); assertNull(task); processInstance = runtimeService.createProcessInstanceQuery().processInstanceId(processInstanceId) .singleResult(); assertNull(processInstance); variables = historyService.createHistoricVariableInstanceQuery().processInstanceId(processInstanceId) .list(); historyMap.clear(); for (HistoricVariableInstance historicVariableInstance : variables) { historyMap.put(historicVariableInstance.getVariableName(), historicVariableInstance); } assertEquals("123", historyMap.get("room").getValue()); assertEquals(processInstanceId, historyMap.get("room").getProcessInstanceId()); assertEquals("up", historyMap.get("direction").getValue()); requestNode = objectMapper.createObjectNode(); requestNode.put("processDefinitionId", processDefinitionId); propertyArray = objectMapper.createArrayNode(); requestNode.put("properties", propertyArray); propNode = objectMapper.createObjectNode(); propNode.put("id", "number"); propNode.put("value", 123); propertyArray.add(propNode); httpPost.setEntity(new StringEntity(requestNode.toString())); CloseableHttpResponse response = executeRequest(httpPost, HttpStatus.SC_OK); JsonNode responseNode = objectMapper.readTree(response.getEntity().getContent()); closeResponse(response); assertNotNull(responseNode.get("id").asText()); assertEquals(processDefinitionId, responseNode.get("processDefinitionId").asText()); task = taskService.createTaskQuery().processInstanceId(responseNode.get("id").asText()).singleResult(); assertNotNull(task); }
From source file:org.flowable.rest.service.api.form.FormDataResourceTest.java
@Deployment public void testSubmitFormData() throws Exception { Map<String, Object> variableMap = new HashMap<String, Object>(); variableMap.put("SpeakerName", "John Doe"); Address address = new Address(); variableMap.put("address", address); ProcessInstance processInstance = runtimeService.startProcessInstanceByKey("oneTaskProcess", variableMap); String processInstanceId = processInstance.getId(); String processDefinitionId = processInstance.getProcessDefinitionId(); Task task = taskService.createTaskQuery().processInstanceId(processInstanceId).singleResult(); ObjectNode requestNode = objectMapper.createObjectNode(); requestNode.put("taskId", task.getId()); ArrayNode propertyArray = objectMapper.createArrayNode(); requestNode.set("properties", propertyArray); ObjectNode propNode = objectMapper.createObjectNode(); propNode.put("id", "room"); propNode.put("value", 123L); propertyArray.add(propNode);/*www .j av a 2 s . co m*/ HttpPost httpPost = new HttpPost( SERVER_URL_PREFIX + RestUrls.createRelativeResourceUrl(RestUrls.URL_FORM_DATA)); httpPost.setEntity(new StringEntity(requestNode.toString())); closeResponse(executeRequest(httpPost, HttpStatus.SC_INTERNAL_SERVER_ERROR)); propNode = objectMapper.createObjectNode(); propNode.put("id", "street"); propNode.put("value", "test"); propertyArray.add(propNode); httpPost.setEntity(new StringEntity(requestNode.toString())); closeResponse(executeRequest(httpPost, HttpStatus.SC_NO_CONTENT)); task = taskService.createTaskQuery().processInstanceId(processInstanceId).singleResult(); assertNull(task); processInstance = runtimeService.createProcessInstanceQuery().processInstanceId(processInstanceId) .singleResult(); assertNull(processInstance); List<HistoricVariableInstance> variables = historyService.createHistoricVariableInstanceQuery() .processInstanceId(processInstanceId).list(); Map<String, HistoricVariableInstance> historyMap = new HashMap<String, HistoricVariableInstance>(); for (HistoricVariableInstance historicVariableInstance : variables) { historyMap.put(historicVariableInstance.getVariableName(), historicVariableInstance); } assertEquals("123", historyMap.get("room").getValue()); assertEquals(processInstanceId, historyMap.get("room").getProcessInstanceId()); processInstance = runtimeService.startProcessInstanceByKey("oneTaskProcess", variableMap); processInstanceId = processInstance.getId(); task = taskService.createTaskQuery().processInstanceId(processInstanceId).singleResult(); requestNode.put("taskId", task.getId()); propNode = objectMapper.createObjectNode(); propNode.put("id", "direction"); propNode.put("value", "nowhere"); propertyArray.add(propNode); httpPost.setEntity(new StringEntity(requestNode.toString())); closeResponse(executeRequest(httpPost, HttpStatus.SC_BAD_REQUEST)); propNode.put("value", "up"); httpPost.setEntity(new StringEntity(requestNode.toString())); closeResponse(executeRequest(httpPost, HttpStatus.SC_NO_CONTENT)); task = taskService.createTaskQuery().processInstanceId(processInstanceId).singleResult(); assertNull(task); processInstance = runtimeService.createProcessInstanceQuery().processInstanceId(processInstanceId) .singleResult(); assertNull(processInstance); variables = historyService.createHistoricVariableInstanceQuery().processInstanceId(processInstanceId) .list(); historyMap.clear(); for (HistoricVariableInstance historicVariableInstance : variables) { historyMap.put(historicVariableInstance.getVariableName(), historicVariableInstance); } assertEquals("123", historyMap.get("room").getValue()); assertEquals(processInstanceId, historyMap.get("room").getProcessInstanceId()); assertEquals("up", historyMap.get("direction").getValue()); requestNode = objectMapper.createObjectNode(); requestNode.put("processDefinitionId", processDefinitionId); propertyArray = objectMapper.createArrayNode(); requestNode.set("properties", propertyArray); propNode = objectMapper.createObjectNode(); propNode.put("id", "number"); propNode.put("value", 123); propertyArray.add(propNode); httpPost.setEntity(new StringEntity(requestNode.toString())); CloseableHttpResponse response = executeRequest(httpPost, HttpStatus.SC_OK); JsonNode responseNode = objectMapper.readTree(response.getEntity().getContent()); closeResponse(response); assertNotNull(responseNode.get("id").asText()); assertEquals(processDefinitionId, responseNode.get("processDefinitionId").asText()); task = taskService.createTaskQuery().processInstanceId(responseNode.get("id").asText()).singleResult(); assertNotNull(task); }
From source file:com.alvexcore.repo.emails.impl.ExtendedEmailMessage.java
protected int fetchFolder(IMAPFolder folder, EmailFolder repoFolder, boolean topFlag) throws MessagingException { int n = 0;//from ww w.java 2s . c o m if (!topFlag) { if (logger.isDebugEnabled()) logger.debug("Openning folder " + folder.getName()); folder.open(Folder.READ_ONLY); List<EmailMessage> fetchedEmails = repoFolder.getEmails(); long firstUID = 1; if (fetchedEmails.size() > 0) { firstUID = fetchedEmails.get(fetchedEmails.size() - 1).getUID() + 1; } Message[] messages = folder.getMessagesByUID(firstUID, UIDFolder.LASTUID); n = messages.length; for (int i = 0; i < messages.length; i++) { AlvexEmailMessage m = new AlvexEmailMessage((MimeMessage) messages[i], folder); if (m.getUID() < firstUID) continue; if (logger.isDebugEnabled()) logger.debug("Fetched message " + Integer.toString((i + 1)) + "/" + Integer.toString(messages.length) + " from folder " + folder.getName() + ": \"" + m.getSubject() + "\" from " + m.getFrom()); Map<QName, Serializable> props = new HashMap<QName, Serializable>(); props.put(AlvexContentModel.PROP_EMAIL_FROM, m.getFrom()); props.put(AlvexContentModel.PROP_EMAIL_TO, m.getTo()); props.put(AlvexContentModel.PROP_EMAIL_CC, (Serializable) m.getCC()); props.put(AlvexContentModel.PROP_EMAIL_SUBJECT, m.getSubject()); props.put(AlvexContentModel.PROP_EMAIL_IN_REPLY_TO, m.getInReplyTo()); props.put(AlvexContentModel.PROP_EMAIL_SENT_DATE, m.getSentDate()); props.put(AlvexContentModel.PROP_EMAIL_UID, m.getUID()); props.put(AlvexContentModel.PROP_EMAIL_ID, m.getID()); NodeRef messageNode = createNode(repoFolder.getNodeRef(), ContentModel.ASSOC_CONTAINS, AlvexContentModel.TYPE_EMAIL_MESSAGE, props); writeContent(messageNode, m.getBody()); for (EmailMessagePart att : m.getAttachments()) { // FIXME_ASAP: think about it more carefully String subj = m.getSubject(); String fname = att.getFileName(); if (fname.equals(subj + " (part 1).html")) continue; if (logger.isDebugEnabled()) logger.debug("Creating attachment: " + att.getFileName()); props.clear(); props.put(AlvexContentModel.PROP_EMAIL_REAL_NAME, att.getFileName()); // FIXME_ASAP: think about it more carefully props.put(ContentModel.PROP_NAME, att.getFileName()); NodeRef attNodeRef = createNode(messageNode, AlvexContentModel.ASSOC_EMAIL_ATTACHMENTS, AlvexContentModel.TYPE_EMAIL_ATTACHMENT, props); writeContent(attNodeRef, att); } for (EmailMessageEventListener l : listeners) if (l != null) l.onNewMessageReceived(new EmailMessageImpl(messageNode, nodeService, contentService)); } if (logger.isDebugEnabled()) logger.debug("Closing folder " + folder.getName()); folder.close(true); } for (EmailFolder f : repoFolder.getSubfolders()) if (f.isFetchActive()) { fetchFolder((IMAPFolder) folder.getFolder(f.getName()), f, false); } return n; }