ServiceTest.java 3.57 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.service;

import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertTrue;

import org.junit.Test;

import eu.omp.irap.vespa.epntapclient.epntap.service.Service;

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

	/**
	 * Create an incomplete service, without many parameters, which is forbidden.
	 *
	 * @return The created service.
	 */
	public static Service createIncompleteService() {
		Service incompleteService = new Service("ivo://cdpp/amda");
		incompleteService.setContentLevel("4");
		return incompleteService;
	}

	/**
	 * Create a service from an actual ADQL query. It is the AMDA service.
	 *
	 * @return The created service
	 */
	public static Service createService() {
		Service service = new Service("ivo://cdpp/amda");
		service.setContentLevel("4");
		service.setCreated("2014-11-06T17:00:00");
		service.setCreator("Centre de Données de la Physique des Plasmas");
		service.setDescription(
				"The CDPP (Centre de Données de la Physique des Plasmas) was created in 1998 jointly by CNES and INSU. The CDPP is the French national data centre \n"
						+ "                        for natural plasmas of the solar system. The CDPP assures the long term preservation of data obtained primarily from instruments built using French \n"
						+ "                        resources, and renders them readily accessible and exploitable by the international community. The CDPP also provides services to enable on-line data \n"
						+ "                        analysis (AMDA), 3D data visualization in context (3DView), and a propagation tool which bridges solar perturbations to in-situ measurements. \n"
						+ "                        The CDPP is involved in the development of interoperability, participates in several Virtual Observatory projects, and supports data distribution for\n"
						+ "                        scientific missions (Solar Orbiter, JUICE).");
		service.setReferenceURL("http://amda.cdpp.eu");
		service.setShortName("AMDA");
		service.setTitle("CDPP AMDA DataBase");
		service.setType("archive");
		service.setUpdated("2014-11-13T17:00:00");
		return service;
	}

	/**
	 * Test if the incomplete service appears like not valid.
	 */
	@SuppressWarnings("static-method") // Otherwise JUnit doesn't work.
	@Test
	public void isNotValid() {
		assertTrue("The complete service is not valid.", createService().isValid());
	}

	/**
	 * Test if the complete service appears like valid.
	 */
	@SuppressWarnings("static-method") // Otherwise JUnit doesn't work.
	@Test
	public void isValid() {
		assertFalse("The incomplete service is valid.", createIncompleteService().isValid());
	}
}