List of usage examples for org.apache.commons.collections MultiMap get
Object get(Object key);
From source file:org.squashtest.tm.service.internal.requirement.VerifiedRequirementsManagerServiceImpl.java
@SuppressWarnings("unchecked") private Map<ExecutionStatus, Long> findResultsForSteppedCoverageWithoutExecution( List<RequirementVersionCoverage> stepedCoverage, List<Long> testCaseIds, List<Long> iterationsIds, Map<Long, Long> nbSteppedCoverageByTestCase) { MultiMap testCaseExecutionStatus = iterationDao.findVerifiedITPI(testCaseIds, iterationsIds); Map<ExecutionStatus, Long> result = new EnumMap<>(ExecutionStatus.class); for (RequirementVersionCoverage cov : stepedCoverage) { Long tcId = cov.getVerifyingTestCase().getId(); List<TestCaseExecutionStatus> tcsStatus = (List<TestCaseExecutionStatus>) testCaseExecutionStatus .get(tcId);/*from w w w. j a va2 s . c o m*/ if (tcsStatus != null) { for (TestCaseExecutionStatus tcStatus : tcsStatus) { //For each cov we must count one status per steps. So fast pass status is forwarded to steps... result.put(tcStatus.getStatus(), (long) cov.getVerifyingSteps().size()); } } } return result; }
From source file:org.squashtest.tm.service.internal.requirement.VerifiedRequirementsManagerServiceImpl.java
@SuppressWarnings("unchecked") private Map<ExecutionStatus, Long> findResultsForSteppedCoverageWithExecution( List<RequirementVersionCoverage> stepedCoverage, List<Long> mainVersionTCWithItpiIds, Map<Long, Long> nbSimpleCoverageByTestCase) { List<Long> testStepsIds = new ArrayList<>(); Map<ExecutionStatus, Long> result = new EnumMap<>(ExecutionStatus.class); //First we compute all testStep id in a list, to allow multiple occurrence of the same step. //Witch is not a good practice but is allowed by the app so we must take this possibility in account for calculations. for (RequirementVersionCoverage cov : stepedCoverage) { Long tcId = cov.getVerifyingTestCase().getId(); if (mainVersionTCWithItpiIds.contains(tcId)) { for (ActionTestStep step : cov.getVerifyingSteps()) { testStepsIds.add(step.getId()); }/*w w w . j av a 2s.c om*/ } } //now retrieve a list of exec steps MultiMap executionsStatus = executionStepDao.findStepExecutionsStatus(mainVersionTCWithItpiIds, testStepsIds); for (Long testStepsId : testStepsIds) { List<ExecutionStep> executionSteps = (List<ExecutionStep>) executionsStatus.get(testStepsId); for (ExecutionStep executionStep : executionSteps) { //Here come horrible code to detect if ITPI was fast passed AFTER execution. //We have no attribute in model to help us, and no time to develop a proper solution. //So we'll use execution date on itpi and exec. If the delta between two date is superior to 2 seconds, //we consider it's a fast pass Execution execution = executionStep.getExecution(); IterationTestPlanItem itpi = execution.getTestPlan(); Date itpiDateLastExecutedOn = itpi.getLastExecutedOn(); Date execDateLastExecutedOn = execution.getLastExecutedOn(); ExecutionStatus status = ExecutionStatus.READY; //if execution dates are null, the execution was only READY, so we don't compare dates to avoid npe if (itpiDateLastExecutedOn != null && execDateLastExecutedOn != null) { DateTime itpiLastExecutedOn = new DateTime(itpi.getLastExecutedOn().getTime()); DateTime execLastExecutedOn = new DateTime(execution.getLastExecutedOn().getTime()); Interval interval = new Interval(execLastExecutedOn, itpiLastExecutedOn); boolean fastPass = interval.toDuration().isLongerThan(new Duration(2000L)); //If we have a fast path use it for step status status = fastPass ? itpi.getExecutionStatus() : executionStep.getExecutionStatus(); } Long memo = result.get(status); if (memo == null) { result.put(status, 1L); } else { result.put(status, memo + 1); } } } return result; }
From source file:org.squashtest.tm.web.internal.controller.requirement.VerifyingTestCaseManagerController.java
@ResponseBody @SuppressWarnings("unchecked") @RequestMapping(value = "/requirement-versions/{requirementVersionId}/coverage-stats", method = RequestMethod.GET, params = { "perimeter" }) public RequirementCoverageStat getCoverageStat(@PathVariable long requirementVersionId, @RequestParam String perimeter) { LOGGER.debug("JTH go controller go"); MultiMap mapIdsByType = JsTreeHelper.mapIdsByType(new String[] { perimeter }); List<Long> iterationIds = new ArrayList<>(); RequirementCoverageStat stat = new RequirementCoverageStat(); if (mapIdsByType.containsKey(campaign_name)) { List<Long> ids = (List<Long>) mapIdsByType.get(campaign_name); try {// ww w . j a v a2 s. c o m //Only one selected node for v1.13... Campaign campaign = campaignFinder.findById(ids.get(0)); iterationIds.addAll(getIterationsIdsForCampagain(campaign)); } catch (IdentityUnavailableException e) { stat.setCorruptedPerimeter(true); } } if (mapIdsByType.containsKey(iteration_name)) { List<Long> ids = (List<Long>) mapIdsByType.get(iteration_name); iterationIds.addAll(ids); } verifiedRequirementsManagerService.findCoverageStat(requirementVersionId, iterationIds, stat); return stat; }
From source file:org.talend.dataprofiler.core.ui.events.EventManager.java
/** * call the registered event's related receiver to handle * // w w w . j a v a 2 s. c om * @param context * @param event * @param data */ public boolean publish(Object context, EventEnum event, Object data) { MultiMap receverQueryMap = ctxToReceiverQueueMap.get(context); if (receverQueryMap == null || receverQueryMap.isEmpty()) { return true; } List<IEventReceiver> receivers = (List<IEventReceiver>) receverQueryMap.get(event); if (receivers == null || receivers.size() == 0) { return true; } // Notify the receiver to handle the event. boolean handleResult = Boolean.TRUE; for (IEventReceiver receiver : receivers) { handleResult = receiver.handle(data); if (!handleResult) { break; } } return handleResult; }
From source file:org.talend.dataprofiler.core.ui.events.EventManager.java
/** * find if there are some registered event for the context, if existed, return the index position in the event list. * // w w w .jav a2 s . co m * @param context * @param event * @return */ public IEventReceiver findRegisteredEvent(Object context, EventEnum event, int index) { MultiMap receverQueryMap = ctxToReceiverQueueMap.get(context); if (receverQueryMap == null || receverQueryMap.isEmpty()) { return null; } List<IEventReceiver> receivers = (List<IEventReceiver>) receverQueryMap.get(event); if (receivers == null || receivers.size() == 0 || receivers.size() < index) { return null; } return receivers.get(index); }
From source file:org.yes.cart.service.domain.impl.PriceServiceImpl.java
/** * Atm we can have different price definitions (lowest in list with high priority): * price without any time limitations;// w w w . j ava 2s . c om * price, which starts in infinitive past and will be end at some date; * price, which has the start date but no end date; * price with start and end date. * * @param skuPrices all prices filtered by currency, and quantity for all skus * @return the list of sku prices, which is filtered by time frame */ List<Pair<String, SkuPrice>> getSkuPricesFilteredByTimeFrame(final List<Pair<String, SkuPrice>> skuPrices) { final List<Pair<String, SkuPrice>> allPrices = new LinkedList<Pair<String, SkuPrice>>(); final MultiMap qtySkuPriceMap = new MultiValueMap(); for (Pair<String, SkuPrice> skuPrice : skuPrices) { qtySkuPriceMap.put(skuPrice.getFirst() + ":" + skuPrice.getSecond().getQuantity(), skuPrice); } for (Object o : qtySkuPriceMap.keySet()) { final String key = (String) o; final List<Pair<String, SkuPrice>> skuPricesForOneSku = new ArrayList<Pair<String, SkuPrice>>( (Collection<Pair<String, SkuPrice>>) qtySkuPriceMap.get(key)); reorderSkuPrices(skuPricesForOneSku); long time = java.lang.System.currentTimeMillis(); //TODO: V2 time machine boolean found = false; found = addFramedPrice(allPrices, skuPricesForOneSku, time); if (!found) { found = addEndPrice(allPrices, skuPricesForOneSku, time); } if (!found) { found = addStartPrice(allPrices, skuPricesForOneSku, time); } if (!found) { addAllTimePrice(allPrices, skuPricesForOneSku, time); } } return allPrices; }