Example #1
2
 /**
  * This function is used to re-run the analyser, and re-create the rows corresponding the its
  * results.
  */
 private void refreshReviewTable() {
   reviewPanel.removeAll();
   rows.clear();
   GridBagLayout gbl = new GridBagLayout();
   reviewPanel.setLayout(gbl);
   GridBagConstraints gbc = new GridBagConstraints();
   gbc.fill = GridBagConstraints.HORIZONTAL;
   gbc.gridy = 0;
   try {
     Map<String, Long> sums =
         analyser.processLogFile(config.getLogFilename(), fromDate.getDate(), toDate.getDate());
     for (Entry<String, Long> entry : sums.entrySet()) {
       String project = entry.getKey();
       double hours = 1.0 * entry.getValue() / (1000 * 3600);
       addRow(gbl, gbc, project, hours);
     }
     for (String project : main.getProjectsTree().getTopLevelProjects())
       if (!rows.containsKey(project)) addRow(gbl, gbc, project, 0);
     gbc.insets = new Insets(10, 0, 0, 0);
     addLeftLabel(gbl, gbc, "TOTAL");
     gbc.gridx = 1;
     gbc.weightx = 1;
     totalLabel.setBorder(BorderFactory.createEmptyBorder(0, 0, 0, 3));
     gbl.setConstraints(totalLabel, gbc);
     reviewPanel.add(totalLabel);
     gbc.weightx = 0;
     addRightLabel(gbl, gbc);
   } catch (IOException e) {
     e.printStackTrace();
   }
   recomputeTotal();
   pack();
 }
Example #2
0
  @Nullable
  public InstanceFactory findInstanceFactory(@Nonnull Type mockedType) {
    InstanceFactory instanceFactory = mockedTypesAndInstances.get(mockedType);

    if (instanceFactory != null) {
      return instanceFactory;
    }

    Class<?> mockedClass = getClassType(mockedType);
    //noinspection ReuseOfLocalVariable
    instanceFactory = mockedTypesAndInstances.get(mockedClass);

    if (instanceFactory != null) {
      return instanceFactory;
    }

    boolean abstractType = mockedClass.isInterface() || isAbstract(mockedClass.getModifiers());

    for (Entry<Type, InstanceFactory> entry : mockedTypesAndInstances.entrySet()) {
      Type registeredMockedType = entry.getKey();
      Class<?> registeredMockedClass = getClassType(registeredMockedType);

      if (abstractType) {
        registeredMockedClass = getMockedClassOrInterfaceType(registeredMockedClass);
      }

      if (mockedClass.isAssignableFrom(registeredMockedClass)) {
        instanceFactory = entry.getValue();
        break;
      }
    }

    return instanceFactory;
  }
 /**
  * Generates a string representation of the configuration options.
  *
  * @return A string
  * @see java.lang.Object#toString()
  */
 public String toString() {
   StringBuilder buff = new StringBuilder("AjaxMetricsFilterConfiguration:");
   buff.append("\n\tParameter Names:");
   for (Entry<String, String> entry : parameterNames.entrySet()) {
     buff.append("\n\t\t").append(entry.getKey()).append(":").append(entry.getValue());
   }
   buff.append("\n\tRun Options:");
   for (Entry<String, Boolean> entry : runOptions.entrySet()) {
     buff.append("\n\t\t").append(entry.getKey()).append(":").append(entry.getValue());
   }
   buff.append("\n\tBatch Options:");
   for (Entry<String, Integer> entry : batchOptions.entrySet()) {
     buff.append("\n\t\t").append(entry.getKey()).append(":").append(entry.getValue());
   }
   buff.append("\n\tListener Class Name:").append(listenerClassName);
   buff.append("\n\tAgent Logging Level:").append(agentLogLevel);
   buff.append("\n\tAgent Name:").append(agentName);
   return buff.toString();
 }
 /**
  * Get the vertex with the maximal label.
  *
  * @param vertexLabels Map that gives a label for each vertex.
  * @return Vertex with the maximal label.
  */
 private V getMaxLabelVertex(Map<V, Integer> vertexLabels) {
   Iterator<Entry<V, Integer>> iterator = vertexLabels.entrySet().iterator();
   Entry<V, Integer> max = iterator.next();
   while (iterator.hasNext()) {
     Entry<V, Integer> e = iterator.next();
     if (e.getValue() > max.getValue()) {
       max = e;
     }
   }
   return max.getKey();
 }
 /**
  * Generates a JavaScript command to update the JavaScript agent's parameter names. Follows this
  * format: <code>agent.updateParameterNames({serial: 'XXXX', parameter: 'YYYY'});</code>
  *
  * @return A JavaScript Command.
  */
 public String generateCommand(String type, Map<String, ?> props) {
   StringBuilder buff = new StringBuilder(agentName);
   buff.append(".update").append(type).append("({");
   for (Entry<String, ?> entry : props.entrySet()) {
     if (entry.getValue() instanceof String) {
       buff.append(entry.getKey()).append(": '").append(entry.getValue()).append("',");
     } else {
       buff.append(entry.getKey()).append(": ").append(entry.getValue()).append(",");
     }
   }
   buff.deleteCharAt(buff.length() - 1);
   buff.append("});");
   return buff.toString();
 }
Example #6
0
 private String generateOverviewText() throws InsufficientDataException {
   StringBuilder sb = new StringBuilder();
   final String team = config.getTeam();
   double total = checkTotal();
   final String nl = System.getProperty("line.separator");
   for (Entry<String, Row> entry : rows.entrySet()) {
     double hours = Double.parseDouble(entry.getValue().hoursTF.getText());
     double fraction = hours / total;
     if (fraction < 0.004) continue;
     String line = team + ", " + decimalFormat.format(fraction) + ", " + entry.getKey();
     sb.append(line + nl);
   }
   return sb.toString();
 }
  private boolean instanceMapHasMocksInSeparateEntries(
      @Nonnull Object mock1, @Nonnull Object mock2) {
    boolean found1 = false;
    boolean found2 = false;

    for (Entry<Object, Object> entry : instanceMap.entrySet()) {
      if (!found1 && isInMapEntry(entry, mock1)) {
        found1 = true;
      }

      if (!found2 && isInMapEntry(entry, mock2)) {
        found2 = true;
      }

      if (found1 && found2) {
        return true;
      }
    }

    return false;
  }