﻿id	summary	reporter	owner	description	type	status	priority	milestone	component	version	resolution	keywords	cc
12885	[patch] Modify OsmValidator class to add new tests	darya	team	"I'm creating a JOSM plugin to validate public transport routes. I want the results to appear in the existing Validator window. To do that, I need the possibility to add additional Test classes to the {{{org.openstreetmap.josm.data.validation.OsmValidator}}} class.  

A possible fix for my needs would be:

1) Change the class attribute {{{private static final allAvailableTests}}} to {{{private static allAvailableTests}}}

2) Add method:

{{{
#!java
public static void addTest(Class newTestClass) {
        Class<Test>[] newTestArray = new Class[allAvailableTests.length+1];
        for (int i=0; i<allAvailableTests.length; i++) {
            newTestArray[i] = allAvailableTests[i];
        }
        newTestArray[newTestArray.length-1] = newTestClass;
        allAvailableTests = newTestArray;
        try {
            allTestsMap.put(newTestClass.getName(), (Test)newTestClass.getConstructor().newInstance());
        } catch(ReflectiveOperationException e) {
            Main.error(e);
        }
    }
}}}

----------------

An alternative solution would be to change the method {{{OsmValidator.getAllTestsMap()}}}

from
{{{
#!java
    public static SortedMap<String, Test> getAllTestsMap() {
        applyPrefs(allTestsMap, false);
        return new TreeMap<>(allTestsMap);
  }
}}}

to
{{{
#!java
    public static SortedMap<String, Test> getAllTestsMap() {
        applyPrefs(allTestsMap, false);
        TreeMap<String, Test> sortedMap = new TreeMap<>(allTestsMap);
        allTestsMap = sortedMap;
        return sortedMap;
    }
}}}

Thank you in advance!"	enhancement	closed	normal	16.05	Core validator		fixed	OsmValidator, GSoC	darya
