protected Object getOutputVariableValue(Map<String, OutputVariable<?>> data, String key) { OutputVariable<?> ov = data.get(key); return (ov != null) ? ov.getValue() : null; }
public void setOutputVariable(OutputVariable<?> variable) { /** * if the output variable is contained in sequenceOutputVariableFactories, * then it must be a DirectSequenceOutputVariableFactory, hence we set its * value so that it can be used to produce the next timeline variable. */ if (sequenceOutputVariableFactories.containsKey(variable.getName())) { if(variable.getValue() instanceof Integer) { DirectSequenceOutputVariableFactory<Integer> v = (DirectSequenceOutputVariableFactory<Integer>) sequenceOutputVariableFactories.get(variable.getName()); v.setValue((Integer) variable.getValue()); } else if(variable.getValue() instanceof Double) { DirectSequenceOutputVariableFactory<Double> v = (DirectSequenceOutputVariableFactory<Double>) sequenceOutputVariableFactories.get(variable.getName()); v.setValue((Double) variable.getValue()); } // v.setValue((Integer)variable.getValue()); } else outputVariables.put(variable.getName(), variable); }
criteria = map.get("criterion").toString().split(":");
/** * Process status update event received from client */ @Override public void receiveEvent(ClientStateInformation information) { if(information.getState() != currentState) { logger.info("Received status update: "+information); if(information.getState() == ClientState.SEARCH) { searchStartTime = System.currentTimeMillis(); for(SequenceOutputVariableFactory<?> factory : sequenceOutputVariableFactories.values()) { factory.setStartTime(searchStartTime); } } OutputVariable<Long> time = new OutputVariable<Long>("Time_"+currentState.getName(), System.currentTimeMillis() - currentStateStarted); outputVariables.put(time.getName(), time); currentState = information.getState(); currentStateStarted = System.currentTimeMillis(); } }
public OutputVariable<String> getVariable() { try { return new OutputVariable<String>(propertyName, Properties.getStringValue(propertyName)); } catch (Exception e) { // TODO: What would be better? return new OutputVariable<String>(propertyName, "error"); } }
public List<OutputVariable<T>> getOutputVariables() { List<OutputVariable<T>> variables = new ArrayList<OutputVariable<T>>(); for(String variableName : getVariableNames()) { OutputVariable<T> variable = new OutputVariable<T>(variableName, getTimeLineValue(variableName)); variables.add(variable); } return variables; }
variables.put(var.getName(), var); variables.put(variableName, new OutputVariable<String>(variableName, "")); } else { logger.error("No obtained value for output variable: "+variableName);
private static Integer getIntegerValue(Map<String,OutputVariable<?>> map, RuntimeVariable variable){ OutputVariable<?> out = map.get(variable.toString()); if( out != null){ return (Integer) out.getValue(); } else { return null; } }
public OutputVariable<T> getVariable(TestSuiteChromosome chromosome) { return new OutputVariable<T>(variable.name(), getData(chromosome)); }
private static Double getDoubleValue(Map<String,OutputVariable<?>> map, RuntimeVariable variable){ OutputVariable<?> out = map.get(variable.toString()); if( out != null){ return (Double) out.getValue(); } else { return null; } } };
/** * Write result to disk using selected backend * * @return true if the writing was successful */ public boolean writeStatisticsForAnalysis() { logger.info("Writing statistics"); if(backend == null) { LoggingUtils.getEvoLogger().info("Backend is null"); return false; } outputVariables.put(RuntimeVariable.Total_Time.name(), new OutputVariable<Object>(RuntimeVariable.Total_Time.name(), System.currentTimeMillis() - startTime)); TestSuiteChromosome individual = new TestSuiteChromosome(); Map<String,OutputVariable<?>> map = getOutputVariables(individual); if(map==null){ logger.error("Not going to write down statistics data, as some are missing"); return false; } boolean valid = RuntimeVariable.validateRuntimeVariables(map); if(!valid){ logger.error("Not going to write down statistics data, as some data is invalid"); return false; } else { backend.writeData(individual, map); return true; } }
/** * Retrieve one line of data * @param data * @return */ private String getCSVData(Map<String, OutputVariable<?>> data) { StringBuilder r = new StringBuilder(); Iterator<Entry<String, OutputVariable<?>>> it = data.entrySet().iterator(); while (it.hasNext()) { Entry<String, OutputVariable<?>> e = (Entry<String, OutputVariable<?>>)it.next(); r.append(e.getValue().getValue()); if (it.hasNext()) r.append(","); } return r.toString(); }
return false; outputVariables.put(RuntimeVariable.Total_Time.name(), new OutputVariable<Object>(RuntimeVariable.Total_Time.name(), System.currentTimeMillis() - startTime));
/** * Write some overall stats * * @param buffer * a {@link java.lang.StringBuffer} object. * @param entry * a {@link org.evosuite.utils.ReportGenerator.StatisticEntry} * object. */ protected void writeParameterTable(StringBuffer buffer, Map<String, OutputVariable<?>> data) { buffer.append("<h2 id=parameters>EvoSuite Parameters</h2>\n"); buffer.append("<div class=statistics><ul>\n"); for (String key : data.keySet()) { buffer.append("<li>" + key + ": " + data.get(key).getValue() + "\n"); } buffer.append("</ul></div>\n"); } }
buffer.append("<td>"); if (data.containsKey(RuntimeVariable.Total_Time.name())) { long duration = (Long)data.get(RuntimeVariable.Total_Time.name()).getValue() / 1000L; buffer.append(String.format("%d:%02d:%02d", duration / 3600, (duration % 3600) / 60, (duration % 60))); } else buffer.append(filename); buffer.append("\">"); buffer.append(data.get("TARGET_CLASS").getValue()); buffer.append("</tr>\n");
@Test public void testLineCoverage() { SearchStatistics statistics = this.aux(new Properties.Criterion[] { Properties.Criterion.LINE }); Map<String, OutputVariable<?>> variables = statistics.getOutputVariables(); assertEquals(11, (Integer) variables.get("Total_Goals").getValue(), 0.0); assertEquals(11, (Integer) variables.get("Covered_Goals").getValue(), 0.0); }
@Test public void testRhoCoverage() { SearchStatistics statistics = this.aux(new Properties.Criterion[] { Properties.Criterion.RHO }); Map<String, OutputVariable<?>> variables = statistics.getOutputVariables(); assertEquals(11, (Integer) variables.get("Total_Goals").getValue(), 0.0); assertEquals(11, (Integer) variables.get("Covered_Goals").getValue(), 0.0); }
if(data.containsKey(RuntimeVariable.MutationScore.name())) buffer.append("<li>Mutation score: " + NumberFormat.getPercentInstance().format((Double)data.get(RuntimeVariable.MutationScore.name()).getValue()) + "\n");