public MessageOutput fromStreamOutput(Output output, final Stream stream, Configuration configuration) throws MessageOutputConfigurationException {
        Preconditions.checkNotNull(output);
        Preconditions.checkNotNull(stream);
        Preconditions.checkNotNull(configuration);

        final String outputType = output.getType();
        Preconditions.checkArgument(outputType != null);

        // We have two output lists for backwards compatibility.
        // See comments in MessageOutput.Factory and MessageOutput.Factory2 for details
        final MessageOutput.Factory2<? extends MessageOutput> factory2 = this.availableOutputs2.get(outputType);
        final MessageOutput.Factory<? extends MessageOutput> factory = this.availableOutputs.get(outputType);

        // If the same outputType value exists in both output factory maps for some reason, we want to prefer the
        // one that is using the more recent interface.
        if (factory2 != null) {
            return factory2.create(output, stream, configuration);
        } else if (factory != null) {
            return factory.create(stream, configuration);
        } else {
            throw new IllegalArgumentException("Output type is not supported: " + outputType);
        }
    }
@Test(expected = IllegalArgumentException.class)
    public void testNonExistentOutputType() throws MessageOutputConfigurationException {
        final String outputType = "non.existent";
        final Output output = mock(Output.class);
        when(output.getType()).thenReturn(outputType);
        final Stream stream = mock(Stream.class);
        final Configuration configuration = mock(Configuration.class);

        messageOutputFactory.fromStreamOutput(output, stream, configuration);
    }