<!DOCTYPE suite SYSTEM "http://testng.org/testng-1.0.dtd">

<suite verbose="1" name="VID UI Tests" annotations="JDK">
    <listeners>
        <listener class-name="vid.automation.test.infra.SkipTestsTestngTransformer"/>
    </listeners>
    <test name="test">
        <method-selectors>
            <method-selector>
                <script language="beanshell">
                    <![CDATA[
                        String [] exclusionGroups = new String [] {
                            "shouldBeMigratedToWorkWithSimulator",
                            "underDevelopment",
                            "Angular2Tests",
                            "worksOnlyWithLocalhostVID",
                            "worksOnlyWithLocalASDC"
                        };
                        String [] classes2 = new String [] {
                            "vid.automation.test.test.AddNetworkTest",
                            "vid.automation.test.test.BrowseASDCTest",
                            "vid.automation.test.test.ChangeManagementTest",
                            "vid.automation.test.test.ALaCarteflowTest",
                            "vid.automation.test.test.VlanTagSubInterfaceTest",
                            "vid.automation.test.test.CreatePortMirroringConfigurationTest",
                            "vid.automation.test.test.CreateNewInstanceTest"
                        };

                        String [] classes3 = new String [] {
                            "vid.automation.test.test.NewServiceInstanceTest"
                        };

                        String [] classes4 = new String [] {
                            "vid.automation.test.test.DrawingBoardTest",
                            "vid.automation.test.test.ViewEditServiceInstanceTest"
                        };

                        int selectPart = 0;

                        for (g: exclusionGroups) {
                            if (groups.containsKey(g)) return false;
                        }

                        if (selectPart == 0) return true;

                        for (groupName: groups.keySet()) {
                            // There's a non-obvious case here:
                            // If there's a "partialGroup" group, and it is *not* for current `selectPart` then
                            // don't run the test -- even if it is in a Class which does belong to the `selectPart`
                            // classes list
                            if (groupName.startsWith("partialGroup_")) {
                                return groupName.equals("partialGroup_" + selectPart);
                            }
                        }

                        methodClass = method.getDeclaringClass().toString();
                        for (c: classes2) {
                            if (methodClass.contains(c)) return selectPart==2;
                        }
                        for (c: classes3) {
                            if (methodClass.contains(c)) return selectPart==3;
                        }
                        for (c: classes4) {
                            if (methodClass.contains(c)) return selectPart==4;
                        }
                        // else
                        return selectPart==1;
                    ]]>
                </script>
            </method-selector>
        </method-selectors>

        <packages>
            <package name="vid.automation.test.test.*"/>
        </packages>
    </test>
</suite>
