@Override
    public void parse(InputStream inputStream, ContentHandler handler, Metadata metadata,
                      ParseContext context) throws IOException {

        this.config = context.get(AgeRecogniserConfig.class, config);
        if (!available) {
            LOG.error("Parser Unavailable, check your configuration");
            return;
        }

        // If content is not plain text use Tika to extract text out of content.
        Reader reader;
        if (MediaType.TEXT_PLAIN.toString().equals(metadata.get(Metadata.CONTENT_TYPE))) {
            reader = new InputStreamReader(inputStream, StandardCharsets.UTF_8);
        } else {
            reader = secondaryParser.parse(inputStream);
        }

        // Use Spark AgePredictor to get predicted Age
        try {
            double predictAuthorAge = getAgePredictorClient().predictAge(IOUtils.toString(reader));

            metadata.add(MD_KEY_ESTIMATED_AGE, Double.toString(predictAuthorAge));

        } catch (Exception e) {
            LOG.error("Age Predictor is not available. Please check wiki for detailed instructions",
                    e);
            return;
        }
    }
USED in test cases to mock response of AgeClassifier
tika-parsers/tika-parsers-ml/tika-age-recogniser/src/main/java/org/apache/tika/parser/recognition/AgeRecogniser.java