Examples of Errors


Examples of org.apache.hadoop.mrunit.internal.util.Errors

   *          result
   */
  protected void validate(final List<Pair<K2, V2>> outputs,
      final boolean orderMatters) {

    final Errors errors = new Errors(LOG);

    if (!outputs.isEmpty()) {
      // were we supposed to get output in the first place?
      if (expectedOutputs.isEmpty()) {
        errors.record("Expected no outputs; got %d outputs.", outputs.size());
      }
      // check that user's key and value writables implement equals, hashCode, toString
      checkOverrides(outputs.get(0));
    }

    final Map<Pair<K2, V2>, List<Integer>> expectedPositions = buildPositionMap(expectedOutputs);
    final Map<Pair<K2, V2>, List<Integer>> actualPositions = buildPositionMap(outputs);

    for (final Pair<K2, V2> output : expectedPositions.keySet()) {
      final List<Integer> expectedPositionList = expectedPositions.get(output);
      final List<Integer> actualPositionList = actualPositions.get(output);
      if (actualPositionList != null) {
        // the expected value has been seen - check positions
        final int expectedPositionsCount = expectedPositionList.size();
        final int actualPositionsCount = actualPositionList.size();
        if (orderMatters) {
          // order is important, so the positions must match exactly
          if (expectedPositionList.equals(actualPositionList)) {
            LOG.debug(String.format("Matched expected output %s at "
                + "positions %s", output, expectedPositionList.toString()));
          } else {
            int i = 0;
            while (expectedPositionsCount > i || actualPositionsCount > i) {
              if (expectedPositionsCount > i && actualPositionsCount > i) {
                final int expectedPosition = expectedPositionList.get(i);
                final int actualPosition = actualPositionList.get(i);
                if (expectedPosition == actualPosition) {
                  LOG.debug(String.format("Matched expected output %s at "
                      + "position %d", output, expectedPosition));
                } else {
                  errors.record("Matched expected output %s but at "
                      + "incorrect position %d (expected position %d)", output,
                      actualPosition, expectedPosition);
                }
              } else if (expectedPositionsCount > i) {
                // not ok, value wasn't seen enough times
                errors.record("Missing expected output %s at position %d.",
                    output, expectedPositionList.get(i));
              } else {
                // not ok, value seen too many times
                errors.record("Received unexpected output %s at position %d.",
                    output, actualPositionList.get(i));
              }
              i++;
            }
          }
        } else {
          // order is unimportant, just check that the count of times seen match
          if (expectedPositionsCount == actualPositionsCount) {
            // ok, counts match
            LOG.debug(String.format("Matched expected output %s in "
                + "%d positions", output, expectedPositionsCount));
          } else if (expectedPositionsCount > actualPositionsCount) {
            // not ok, value wasn't seen enough times
            for (int i = 0; i < expectedPositionsCount - actualPositionsCount; i++) {
              errors.record("Missing expected output %s", output);
            }
          } else {
            // not ok, value seen too many times
            for (int i = 0; i < actualPositionsCount - expectedPositionsCount; i++) {
              errors.record("Received unexpected output %s", output);
            }
          }
        }
        actualPositions.remove(output);
      } else {
        // the expected value was not found anywhere - output errors
        checkTypesAndLogError(outputs, output, expectedPositionList,
            orderMatters, errors, "Missing expected output");
      }
    }

    for (final Pair<K2, V2> output : actualPositions.keySet()) {
      // anything left in actual set is unexpected
      checkTypesAndLogError(outputs, output, actualPositions.get(output),
          orderMatters, errors, "Received unexpected output");
    }
   
    errors.assertNone();
  }
View Full Code Here

Examples of org.apache.isis.viewer.scimpi.dispatcher.view.display.Errors

        addElementProcessor(new DebugUsersView());
        addElementProcessor(new DefaultValue());
        addElementProcessor(new EditLink());
        addElementProcessor(new EditObject());
        addElementProcessor(new ElementType());
        addElementProcessor(new Errors());
        addElementProcessor(new ErrorDetails());
        addElementProcessor(new ErrorMessage());
        addElementProcessor(new ErrorReference());
        addElementProcessor(new ExcludeField());
        addElementProcessor(new Feedback());
View Full Code Here

Examples of org.apache.kafka.common.protocol.Errors

        if (response.hasResponse()) {
            ProduceResponse produceResponse = new ProduceResponse(response.responseBody());
            for (Map.Entry<TopicPartition, ProduceResponse.PartitionResponse> entry : produceResponse.responses().entrySet()) {
                TopicPartition tp = entry.getKey();
                ProduceResponse.PartitionResponse partResp = entry.getValue();
                Errors error = Errors.forCode(partResp.errorCode);
                RecordBatch batch = batches.get(tp);
                completeBatch(batch, error, partResp.baseOffset, correlationId, now);
            }
            this.sensors.recordLatency(response.request().request().destination(), response.requestLatencyMs());
        } else {
View Full Code Here

Examples of org.apache.sis.util.resources.Errors

        final List<Thread> threads = DaemonThread.listStalledThreads(lastCreatedDaemon);
        if (threads == null) {
            return null;
        }
        final String[] warnings = new String[threads.size()];
        final Errors resources = Errors.getResources(locale);
        for (int i=0; i<warnings.length; i++) {
            final Thread thread = threads.get(i);
            warnings[i] = resources.getString(thread.isAlive() ?
                    Errors.Keys.StalledThread_1 : Errors.Keys.DeadThread_1, thread.getName());
        }
        return warnings;
    }
View Full Code Here

Examples of org.elasticsearch.common.inject.internal.Errors

        Inject inject = field.getAnnotation(Inject.class);
        this.optional = inject.optional();

        Annotation[] annotations = field.getAnnotations();

        Errors errors = new Errors(field);
        Key<?> key = null;
        try {
            key = Annotations.getKey(type.getFieldType(field), field, annotations, errors);
        } catch (ErrorsException e) {
            errors.merge(e.getErrors());
        }
        errors.throwConfigurationExceptionIfErrorsExist();

        this.dependencies = ImmutableList.<Dependency<?>>of(
                newDependency(key, Nullability.allowsNull(annotations), -1));
    }
View Full Code Here

Examples of org.geotools.resources.i18n.Errors

     * if {@code level} is non-null, or a {@link String} otherwise.
     */
    private static Object doFormatUnparsable(String text, final int index, int errorIndex,
                                             final Locale locale, final Level level)
    {
        final Errors resources = Errors.getResources(locale);
        final int length = text.length();
        if (errorIndex < index) {
            errorIndex = index;
        }
        if (errorIndex == length) {
            if (level != null) {
                return resources.getLogRecord(level, ErrorKeys.UNEXPECTED_END_OF_STRING);
            }
            return resources.getString(ErrorKeys.UNEXPECTED_END_OF_STRING);
        }
        int upper = errorIndex;
        if (upper < length) {
            final int type = Character.getType(text.charAt(upper));
            while (++upper < length) {
                if (Character.getType(text.charAt(upper)) != type) {
                    break;
                }
            }
        }
        final String error = text.substring(errorIndex, upper);
        text = text.substring(index);
        if (level != null) {
            return resources.getLogRecord(level, ErrorKeys.UNPARSABLE_STRING_$2, text, error);
        }
        return resources.getString(ErrorKeys.UNPARSABLE_STRING_$2, text, error);
    }
View Full Code Here

Examples of org.jtalks.jcommune.plugin.auth.poulpe.dto.Errors

     * @throws java.io.IOException
     */
    private Map<String, String> parseErrors(Representation repr, Locale locale) throws IOException, JAXBException {
        JAXBContext context = JAXBContext.newInstance(Errors.class);
        Unmarshaller unmarshaller = context.createUnmarshaller();
        Errors errorsRepr = (Errors) unmarshaller.unmarshal(repr.getStream());

        Map<String, String> errors = new HashMap<>();
        ResourceBundle resourceBundle = ResourceBundle.getBundle("ValidationMessages", locale);
        for (org.jtalks.jcommune.plugin.auth.poulpe.dto.Error error : errorsRepr.getErrorList()) {
            if (error.getCode() != null && !error.getCode().isEmpty()) {
                Map.Entry<String, String> errorEntry = parseErrorCode(error.getCode(), resourceBundle);
                if (errorEntry != null) {
                    errors.put(errorEntry.getKey(), errorEntry.getValue());
                }
View Full Code Here

Examples of org.megatome.frame2.errors.Errors

  }

  private boolean setupEmailTest(final String emailAddr) {
    this.testBean.setEmail(emailAddr);
    this.testBean.setEmpty("dude"); //$NON-NLS-1$
    final Errors errors = setupAndRunValidate(this.testBean,
        EMAIL_BEAN_NAME);
    return validateErrors(errors);
  }
View Full Code Here

Examples of org.megatome.frame2.errors.Errors

  }

  private Errors setupAndRunValidate(final CommonsValidatorBean testBean,
      final String fieldBeanName) {
    // Add an error to verify the error is passed in..
    final Errors errors = ErrorsFactory.newInstance();
    errors.add("seed", "dude"); //$NON-NLS-1$ //$NON-NLS-2$

    final Validator validator = new Validator(this.validatorResources,
        fieldBeanName);
    // add the name bean to the validator as a resource
    // for the validations to be performed on.
View Full Code Here

Examples of org.megatome.frame2.errors.Errors

  public void testNullEmailNotRequired() {
    this.validatorResources = buildValidatorResources();

    this.testBean.setEmpty("dude"); //$NON-NLS-1$

    final Errors errors = setupAndRunValidate(this.testBean,
        EMAIL_BEAN_NAME);
    assertEquals(DEF_ERRORS_SIZE, errors.size());

  }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.