Blame view

src/test/java/eu/omp/irap/vespa/epntapclient/granule/GranuleTest.java 7.39 KB
f2e9bb55   Nathanael Jourdane   Add Granule Unit ...
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
/*
 * This file is a part of EpnTAPClient.
 * This program aims to provide EPN-TAP support for software clients, like CASSIS spectrum analyzer.
 * incompleteGranule.sete 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 LicenincompleteGranule.set as published
 * by the Free Software Foundation, either version 3 of the LicenincompleteGranule.set, or (at your option) any later
 * version. This program is distributed in the hope that it will be uincompleteGranule.setful, but WITHOUT ANY
 * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
 * PURPOincompleteGranule.set. incompleteGranule.sete the GNU General Public LicenincompleteGranule.set for more details. You should have received a copy of
 * the GNU General Public LicenincompleteGranule.set along with this program. If not, incompleteGranule.sete
 * <http://www.gnu.org/licenincompleteGranule.sets/>.
 */

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

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

fd1d4872   Nathanael Jourdane   Immplement unit t...
22
23
import java.text.ParseException;
import java.text.SimpleDateFormat;
f2e9bb55   Nathanael Jourdane   Add Granule Unit ...
24
import java.util.Date;
987f00a7   Nathanael Jourdane   Use ServicesList ...
25
import java.util.logging.Level;
fd1d4872   Nathanael Jourdane   Immplement unit t...
26
import java.util.logging.Logger;
f2e9bb55   Nathanael Jourdane   Add Granule Unit ...
27
28
29

import org.junit.Test;

c60d0aec   Nathanael Jourdane   Add Javadoc.
30
31
import eu.omp.irap.vespa.votable.votabledata.VoTableDataTest;

f2e9bb55   Nathanael Jourdane   Add Granule Unit ...
32
33
34
35
36
/**
 * @author N. Jourdane
 */
public class GranuleTest {

fd1d4872   Nathanael Jourdane   Immplement unit t...
37
38
39
40
	/** The logger for the class GranuleTest. */
	private static final Logger LOGGER = Logger.getLogger(GranuleTest.class.getName());


c60d0aec   Nathanael Jourdane   Add Javadoc.
41
42
43
44
45
46
	/**
	 * Create a granule for tests purposes. It is planetary data for Uranus, got from an actual ADQL
	 * query, exactly the same content that {@link VoTableDataTest#createDataArray1()}
	 *
	 * @return The granule.
	 */
fd1d4872   Nathanael Jourdane   Immplement unit t...
47
48
49
50
51
	public static Granule createGranule1() {
		Date testDate = null;
		try {
			testDate = new SimpleDateFormat("yyyy-mm-dd").parse("2015-08-20");
		} catch (ParseException e) {
987f00a7   Nathanael Jourdane   Use ServicesList ...
52
			LOGGER.log(Level.WARNING, "Can not parse the test date.", e);
fd1d4872   Nathanael Jourdane   Immplement unit t...
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
		}

		Granule completeGranule = new Granule("Uranus");
		completeGranule.setGranuleGid("Planet");
		completeGranule.setObsId("7");
		completeGranule.setDataproductType("ca");
		completeGranule.setTargetName("Uranus");
		completeGranule.setTargetClass("planet");
		completeGranule.setTimeMin(Double.NaN);
		completeGranule.setTimeMax(Double.NaN);
		completeGranule.setTimeSamplingStepMin(Double.NaN);
		completeGranule.setTimeSamplingStepMax(Double.NaN);
		completeGranule.setTimeExpMin(Double.NaN);
		completeGranule.setTimeExpMax(Double.NaN);
		completeGranule.setSpectralRangeMin(Double.NaN);
		completeGranule.setSpectralRangeMax(Double.NaN);
		completeGranule.setSpectralResolutionMin(Double.NaN);
		completeGranule.setSpectralResolutionMax(Double.NaN);
		completeGranule.setC1Min(Double.NaN);
		completeGranule.setC1Max(Double.NaN);
		completeGranule.setC2Min(Double.NaN);
		completeGranule.setC2Max(Double.NaN);
		completeGranule.setC3Min(Double.NaN);
		completeGranule.setC3Max(Double.NaN);
		completeGranule.setSRegion("");
		completeGranule.setC1ResolMin(Double.NaN);
		completeGranule.setC1ResolMax(Double.NaN);
		completeGranule.setC2ResolMin(Double.NaN);
		completeGranule.setC2ResolMax(Double.NaN);
		completeGranule.setC3ResolMin(Double.NaN);
		completeGranule.setC3ResolMax(Double.NaN);
		completeGranule.setSpatialFrameType("celestial");
		completeGranule.setIncidenceMin(Double.NaN);
		completeGranule.setIncidenceMax(Double.NaN);
		completeGranule.setEmergenceMin(Double.NaN);
		completeGranule.setEmergenceMax(Double.NaN);
		completeGranule.setPhaseMin(Double.NaN);
		completeGranule.setPhaseMax(Double.NaN);
		completeGranule.setInstrumentHostName("");
		completeGranule.setInstrumentName("");
		completeGranule.setMeasurementType("\"phys.mass\" \"phys.size.radius\"");
		completeGranule.setProcessingLevel(5);
		completeGranule.setCreationDate(testDate);
		completeGranule.setModificationDate(testDate);
		completeGranule.setReleaseDate(testDate);
		completeGranule.setServiceTitle("Planets");
		return completeGranule;
	}

c60d0aec   Nathanael Jourdane   Add Javadoc.
102
103
104
105
106
107
	/**
	 * Create a granule for tests purposes. It is planetary data for Neptune, got from an actual
	 * query, exactly the same content that {@link VoTableDataTest#createDataArray2()}
	 *
	 * @return The granule.
	 */
fd1d4872   Nathanael Jourdane   Immplement unit t...
108
109
110
111
112
	public static Granule createGranule2() {
		Date testDate = null;
		try {
			testDate = new SimpleDateFormat("yyyy-mm-dd").parse("2015-08-20");
		} catch (ParseException e) {
987f00a7   Nathanael Jourdane   Use ServicesList ...
113
			LOGGER.log(Level.WARNING, "Can not parse the test date.", e);
fd1d4872   Nathanael Jourdane   Immplement unit t...
114
115
116
		}

		Granule completeGranule = new Granule("Neptune");
f2e9bb55   Nathanael Jourdane   Add Granule Unit ...
117
		completeGranule.setGranuleGid("Planet");
fd1d4872   Nathanael Jourdane   Immplement unit t...
118
		completeGranule.setObsId("8");
f2e9bb55   Nathanael Jourdane   Add Granule Unit ...
119
		completeGranule.setDataproductType("ca");
fd1d4872   Nathanael Jourdane   Immplement unit t...
120
		completeGranule.setTargetName("Neptune");
f2e9bb55   Nathanael Jourdane   Add Granule Unit ...
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
		completeGranule.setTargetClass("planet");
		completeGranule.setTimeMin(Double.NaN);
		completeGranule.setTimeMax(Double.NaN);
		completeGranule.setTimeSamplingStepMin(Double.NaN);
		completeGranule.setTimeSamplingStepMax(Double.NaN);
		completeGranule.setTimeExpMin(Double.NaN);
		completeGranule.setTimeExpMax(Double.NaN);
		completeGranule.setSpectralRangeMin(Double.NaN);
		completeGranule.setSpectralRangeMax(Double.NaN);
		completeGranule.setSpectralResolutionMin(Double.NaN);
		completeGranule.setSpectralResolutionMax(Double.NaN);
		completeGranule.setC1Min(Double.NaN);
		completeGranule.setC1Max(Double.NaN);
		completeGranule.setC2Min(Double.NaN);
		completeGranule.setC2Max(Double.NaN);
		completeGranule.setC3Min(Double.NaN);
		completeGranule.setC3Max(Double.NaN);
fd1d4872   Nathanael Jourdane   Immplement unit t...
138
		completeGranule.setSRegion("");
f2e9bb55   Nathanael Jourdane   Add Granule Unit ...
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
		completeGranule.setC1ResolMin(Double.NaN);
		completeGranule.setC1ResolMax(Double.NaN);
		completeGranule.setC2ResolMin(Double.NaN);
		completeGranule.setC2ResolMax(Double.NaN);
		completeGranule.setC3ResolMin(Double.NaN);
		completeGranule.setC3ResolMax(Double.NaN);
		completeGranule.setSpatialFrameType("celestial");
		completeGranule.setIncidenceMin(Double.NaN);
		completeGranule.setIncidenceMax(Double.NaN);
		completeGranule.setEmergenceMin(Double.NaN);
		completeGranule.setEmergenceMax(Double.NaN);
		completeGranule.setPhaseMin(Double.NaN);
		completeGranule.setPhaseMax(Double.NaN);
		completeGranule.setInstrumentHostName("");
		completeGranule.setInstrumentName("");
		completeGranule.setMeasurementType("\"phys.mass\" \"phys.size.radius\"");
		completeGranule.setProcessingLevel(5);
fd1d4872   Nathanael Jourdane   Immplement unit t...
156
157
158
		completeGranule.setCreationDate(testDate);
		completeGranule.setModificationDate(testDate);
		completeGranule.setReleaseDate(testDate);
f2e9bb55   Nathanael Jourdane   Add Granule Unit ...
159
160
161
162
		completeGranule.setServiceTitle("Planets");
		return completeGranule;
	}

c60d0aec   Nathanael Jourdane   Add Javadoc.
163
164
165
166
167
	/**
	 * Create an incomplete granule without many mandatory parameters, which is forbidden.
	 *
	 * @return the granule.
	 */
45fb4583   Nathanael Jourdane   Sort methods and ...
168
169
170
171
172
173
	public static Granule createIncompleteGranule() {
		Granule incompleteGranule = new Granule("Mercury");
		incompleteGranule.setGranuleGid("Planet");
		return incompleteGranule;
	}

c60d0aec   Nathanael Jourdane   Add Javadoc.
174
175
176
	/**
	 * Test if the incomplete granule appears like not valid.
	 */
987f00a7   Nathanael Jourdane   Use ServicesList ...
177
	@SuppressWarnings("static-method") // Otherwise JUnit doesn't work.
f2e9bb55   Nathanael Jourdane   Add Granule Unit ...
178
	@Test
fd1d4872   Nathanael Jourdane   Immplement unit t...
179
	public void isNotValidTest() {
f2e9bb55   Nathanael Jourdane   Add Granule Unit ...
180
181
182
		assertFalse("The incomplete granule is valid.", createIncompleteGranule().isValid());
	}

c60d0aec   Nathanael Jourdane   Add Javadoc.
183
184
185
	/**
	 * Test if a complete granule appears like valid.
	 */
987f00a7   Nathanael Jourdane   Use ServicesList ...
186
	@SuppressWarnings("static-method") // Otherwise JUnit doesn't work.
f2e9bb55   Nathanael Jourdane   Add Granule Unit ...
187
	@Test
fd1d4872   Nathanael Jourdane   Immplement unit t...
188
189
	public void isValidTest() {
		assertTrue("The complete granule is not valid.", createGranule1().isValid());
f2e9bb55   Nathanael Jourdane   Add Granule Unit ...
190
191
192
	}

}