VOTableDataTest.java 4.35 KB
/*
 * This file is a part of EpnTAPClient.
 * This program aims to provide EPN-TAP support for software clients, like CASSIS spectrum analyzer.
 * See draft specifications: https://voparis-confluence.obspm.fr/pages/viewpage.action?pageId=559861
 * Copyright (C) 2016 Institut de Recherche en Astrophysique et Planétologie.
 *
 * This program is free software: you can
 * redistribute it and/or modify it under the terms of the GNU General Public License as published
 * by the Free Software Foundation, either version 3 of the License, or (at your option) any later
 * version. This program is distributed in the hope that it will be useful, but WITHOUT ANY
 * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
 * PURPOSE. See the GNU General Public License for more details. You should have received a copy of
 * the GNU General Public License along with this program. If not, see
 * <http://www.gnu.org/licenses/>.
 */

package eu.omp.irap.vespa.epntapclient.granule;

import java.util.ArrayList;
import java.util.List;

import eu.omp.irap.vespa.votable.votabledata.VOTableData;

/**
 * @author N. Jourdane
 */
public class VOTableDataTest {

	/**
	 * Creates the column names corresponding to the data arrays returned by
	 * {@link #createDataArray1()} and {@link #createDataArray2()} .
	 *
	 * @return An array of string containing the column names.
	 */
	public static String[] createColumnNames() {
		String[] columnNames = { "granule_uid", "granule_gid", "obs_id", "dataproduct_type",
				"target_name", "target_class", "time_min", "time_max", "time_sampling_step_min",
				"time_sampling_step_max", "time_exp_min", "time_exp_max", "spectral_range_min",
				"spectral_range_max", "spectral_resolution_min", "spectral_resolution_max", "c1min",
				"c1max", "c2min", "c2max", "c3min", "c3max", "s_region", "c1_resol_min",
				"c1_resol_max", "c2_resol_min", "c2_resol_max", "c3_resol_min", "c3_resol_max",
				"spatial_frame_type", "incidence_min", "incidence_max", "emergence_min",
				"emergence_max", "phase_min", "phase_max", "instrument_host_name",
				"instrument_name", "measurement_type", "processing_level", "creation_date",
				"modification_date", "release_date", "service_title" };
		return columnNames;
	}

	/**
	 * Create a data set for tests purposes. It is planetary data for Uranus, got from an actual
	 * ADQL query.
	 *
	 * @return An arrays of object containing the data values, with the same order as the columns
	 *         returned by {@link #createColumnNames()}.
	 */
	public static Object[] createDataArray1() {
		Object[] data1 = { "Uranus", "Planet", "7", "ca", "Uranus", "planet", Double.NaN,
				Double.NaN, Double.NaN, Double.NaN, Double.NaN, Double.NaN, Double.NaN, Double.NaN,
				Double.NaN, Double.NaN, Double.NaN, Double.NaN, Double.NaN, Double.NaN, Double.NaN,
				Double.NaN, "", Double.NaN, Double.NaN, Double.NaN, Double.NaN, Double.NaN,
				Double.NaN, "celestial", Double.NaN, Double.NaN, Double.NaN, Double.NaN, Double.NaN,
				Double.NaN, "", "", "\"phys.mass\" \"phys.size.radius\"", 5, "2015-08-20",
				"2015-08-20", "2015-08-20", "Planets" };
		return data1;
	}

	/**
	 * Create a data set for tests purposes. It is planetary data for Neptune, got from an actual
	 * ADQL query.
	 *
	 * @return An arrays of object containing the data values, with the same order as the columns
	 *         returned by {@link #createColumnNames()}.
	 */
	public static Object[] createDataArray2() {
		Object[] data2 = { "Neptune", "Planet", "8", "ca", "Neptune", "planet", Double.NaN,
				Double.NaN, Double.NaN, Double.NaN, Double.NaN, Double.NaN, Double.NaN, Double.NaN,
				Double.NaN, Double.NaN, Double.NaN, Double.NaN, Double.NaN, Double.NaN, Double.NaN,
				Double.NaN, "", Double.NaN, Double.NaN, Double.NaN, Double.NaN, Double.NaN,
				Double.NaN, "celestial", Double.NaN, Double.NaN, Double.NaN, Double.NaN, Double.NaN,
				Double.NaN, "", "", "\"phys.mass\" \"phys.size.radius\"", 5, "2015-08-20",
				"2015-08-20", "2015-08-20", "Planets" };
		return data2;
	}

	/**
	 * Create a VOTable data containing 2 datasets returned by {@link #createDataArray1()} and
	 * {@link #createDataArray2()}.
	 *
	 * @return the VOTable data.
	 */
	public static VOTableData createVoTableData() {
		List<Object[]> data = new ArrayList<>();
		data.add(createDataArray1());
		data.add(createDataArray2());
		return new VOTableData("Data set test", createColumnNames(), data);
	}
}