001/*
002 * Units of Measurement TCK
003 * Copyright © 2005-2020, Jean-Marie Dautelle, Werner Keil, Otavio Santana.
004 *
005 * All rights reserved.
006 *
007 * Redistribution and use in source and binary forms, with or without modification,
008 * are permitted provided that the following conditions are met:
009 *
010 * 1. Redistributions of source code must retain the above copyright notice,
011 *    this list of conditions and the following disclaimer.
012 *
013 * 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions
014 *    and the following disclaimer in the documentation and/or other materials provided with the distribution.
015 *
016 * 3. Neither the name of JSR-385 nor the names of its contributors may be used to endorse or promote products
017 *    derived from this software without specific prior written permission.
018 *
019 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
020 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
021 * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
022 * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
023 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
024 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
025 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
026 * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
027 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
028 * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
029 */
030package tech.units.tck.util;
031
032import tech.uom.lib.common.function.DescriptionSupplier;
033
034/**
035 * TestNG groups and profiles used in the JSR 385 TCK.
036 * 
037 * @author <a href="mailto:[email protected]">Werner Keil</a>
038 * @author <a href="mailto:[email protected]">Thodoris Bais</a>
039 * @version 2.3, November 15, 2020
040 * @since 1.0
041 */
042public final class TestGroups {
043    // String constants
044    public static final String CORE = "core";
045    public static final String FORMAT = "format";
046    public static final String BASE_QUANTITY = "base_quantity";
047    public static final String DERIVED_QUANTITY = "derived_quantity";
048    public static final String SPI = "spi";
049
050    /**
051     * Minimal groups
052     */
053    private static final String[] MINIMAL_GROUPS = { CORE };
054
055    /**
056     * Format groups
057     */
058    private static final String[] FORMAT_GROUPS = { CORE, FORMAT };
059
060    /**
061     * Base Quantity groups
062     */
063    private static final String[] BASE_QUANTITY_GROUPS = { CORE, BASE_QUANTITY };
064
065    /**
066     * Quantity groups
067     */
068    private static final String[] QUANTITY_GROUPS = { CORE, BASE_QUANTITY, DERIVED_QUANTITY };
069
070    /**
071     * Quantity groups and Format
072     */
073    private static final String[] QUANTITY_GROUPS_AND_FORMAT = { CORE, FORMAT, BASE_QUANTITY, DERIVED_QUANTITY };
074
075    /**
076     * SPI groups
077     */
078    private static final String[] SPI_GROUPS = { CORE, FORMAT, SPI };
079
080        /**
081         * All groups
082         */
083        private static final String[] ALL_GROUPS = { CORE, FORMAT, BASE_QUANTITY, DERIVED_QUANTITY, SPI };
084
085    /**
086     * Profiles used in the JSR 385 TCK.
087     *
088     * Some of the most common profiles (used by {@link tech.units.tck.TCKRunner}) are:
089     * <ul>
090     * <li>{@link #MINIMAL} - used to include tests for the core elements of the API. These tests are <b>mandatory</b> for every implementation.</li>
091     * <li>{@link #FORMAT} - formatting tests used to include tests for elements in <code>javax.measure.format</code>.</li>
092     * <li>{@link #FULL} - All tests in the JSR 385 TCK.</li>
093     * </ul>
094     *
095     * @author Werner Keil
096     * @version 1.2
097     * @since 1.0
098     */
099    public enum Profile implements DescriptionSupplier {
100        MINIMAL("Minimal", MINIMAL_GROUPS), //
101        FORMAT("Format", FORMAT_GROUPS), //
102        BASE_QUANTITY("Base Quantity", BASE_QUANTITY_GROUPS), //
103        QUANTITY("Quantity", QUANTITY_GROUPS), //
104        QUANTITY_FORMAT("Quantity and Format", QUANTITY_GROUPS_AND_FORMAT), //
105        SPI("SPI", SPI_GROUPS, false), //
106        FULL("Full", ALL_GROUPS, true);
107
108        private final String description;
109        private final boolean isDefault;
110        private final String[] groups;
111
112        private Profile(String description, String[] groups, boolean isDefault) {
113            this.description = description;
114            this.groups = groups;
115            this.isDefault = isDefault;
116        }
117
118        private Profile(String description, String[] groups) {
119            this(description, groups, false);
120        }
121
122        /*
123         * (non-Javadoc)
124         * 
125         * @see DescriptionSupplier
126         */
127        public String getDescription() {
128            return description;
129        }
130
131        public String[] getGroups() { return groups; }
132
133        public boolean isDefault() {
134            return isDefault;
135        }
136    }
137}