@Override
    public int compareTo(PluginDesc<?> other) {
        int nameComp = name.compareTo(other.name);
        int versionComp = encodedVersion.compareTo(other.encodedVersion);
        // isolated plugins appear after classpath plugins when they have identical versions.
        int isolatedComp = Boolean.compare(other.loader instanceof PluginClassLoader, loader instanceof PluginClassLoader);
        // choose an arbitrary order between different locations and types
        int loaderComp = location.compareTo(other.location);
        int typeComp = type.compareTo(other.type);
        return nameComp != 0 ? nameComp :
                versionComp != 0 ? versionComp :
                        isolatedComp != 0 ? isolatedComp :
                                loaderComp != 0 ? loaderComp :
                                        typeComp;
    }
@SuppressWarnings("rawtypes")
    @Test
    public void testPluginDescComparison() {
        PluginDesc<SinkConnector> connectorDescPluginPath = new PluginDesc<>(
                SinkConnector.class,
                regularVersion,
                PluginType.SINK,
                pluginLoader
        );

        PluginDesc<SinkConnector> connectorDescClasspath = new PluginDesc<>(
                SinkConnector.class,
                newerVersion,
                PluginType.SINK,
                systemLoader
        );

        assertNewer(connectorDescPluginPath, connectorDescClasspath);

        PluginDesc<Converter> converterDescPluginPath = new PluginDesc<>(
                Converter.class,
                noVersion,
                PluginType.CONVERTER,
                pluginLoader
        );

        PluginDesc<Converter> converterDescClasspath = new PluginDesc<>(
                Converter.class,
                snapshotVersion,
                PluginType.CONVERTER,
                systemLoader
        );

        assertNewer(converterDescPluginPath, converterDescClasspath);

        PluginDesc<Transformation> transformDescPluginPath = new PluginDesc<>(
                Transformation.class,
                null,
                PluginType.TRANSFORMATION,
                pluginLoader
        );

        PluginDesc<Transformation> transformDescClasspath = new PluginDesc<>(
                Transformation.class,
                regularVersion,
                PluginType.TRANSFORMATION,
                systemLoader
        );

        assertNewer(transformDescPluginPath, transformDescClasspath);

        PluginDesc<Predicate> predicateDescPluginPath = new PluginDesc<>(
                Predicate.class,
                regularVersion,
                PluginType.PREDICATE,
                pluginLoader
        );

        PluginDesc<Predicate> predicateDescClasspath = new PluginDesc<>(
                Predicate.class,
                regularVersion,
                PluginType.PREDICATE,
                systemLoader
        );

        assertNewer(predicateDescPluginPath, predicateDescClasspath);

        PluginDesc<ConfigProvider> configProviderDescPluginPath = new PluginDesc<>(
                FileConfigProvider.class,
                regularVersion,
                PluginType.CONFIGPROVIDER,
                pluginLoader
        );

        PluginDesc<ConfigProvider> configProviderDescOtherPluginLoader = new PluginDesc<>(
                FileConfigProvider.class,
                regularVersion,
                PluginType.CONFIGPROVIDER,
                otherPluginLoader
        );

        assertTrue(configProviderDescPluginPath.compareTo(configProviderDescOtherPluginLoader) != 0,
            "Different plugin loaders should have an ordering");


        PluginDesc<Converter> jsonConverterPlugin = new PluginDesc<>(
                JsonConverter.class,
                regularVersion,
                PluginType.CONVERTER,
                systemLoader
        );

        PluginDesc<HeaderConverter> jsonHeaderConverterPlugin = new PluginDesc<>(
                JsonConverter.class,
                regularVersion,
                PluginType.HEADER_CONVERTER,
                systemLoader
        );

        assertNewer(jsonConverterPlugin, jsonHeaderConverterPlugin);
    }