Issue #2316 Remove tests for old airep/pirep plugins.

Change-Id: I5503e6bd065e4daa4620c35d0a173a7cbb5bfe44

Former-commit-id: 8d7e812f92c48fd57a52e79433de9f094f675fe3
This commit is contained in:
Ben Steffensmeier 2013-09-05 16:24:46 -05:00
parent af8fbacf72
commit e091a9d18d
5 changed files with 0 additions and 833 deletions

View file

@ -98,13 +98,9 @@
<classpathentry combineaccessrules="false" kind="src" path="/com.raytheon.uf.common.dataplugin.gfe"/>
<classpathentry combineaccessrules="false" kind="src" path="/com.raytheon.edex.plugin.gfe"/>
<classpathentry combineaccessrules="false" kind="src" path="/com.raytheon.uf.common.python"/>
<classpathentry combineaccessrules="false" kind="src" path="/com.raytheon.edex.plugin.airep"/>
<classpathentry combineaccessrules="false" kind="src" path="/com.raytheon.uf.common.dataplugin.airep"/>
<classpathentry combineaccessrules="false" kind="src" path="/com.raytheon.uf.common.message"/>
<classpathentry combineaccessrules="false" kind="src" path="/com.raytheon.edex.plugin.shef"/>
<classpathentry combineaccessrules="false" kind="src" path="/com.raytheon.uf.common.dataplugin.obs"/>
<classpathentry combineaccessrules="false" kind="src" path="/com.raytheon.uf.common.dataplugin.pirep"/>
<classpathentry combineaccessrules="false" kind="src" path="/com.raytheon.edex.plugin.pirep"/>
<classpathentry combineaccessrules="false" kind="src" path="/gov.noaa.nws.ncep.common.dataplugin.ffg"/>
<classpathentry combineaccessrules="false" kind="src" path="/gov.noaa.nws.ncep.common"/>
<classpathentry combineaccessrules="false" kind="src" path="/gov.noaa.nws.ncep.edex.plugin.ffg"/>

View file

@ -1,287 +0,0 @@
/**
* This software was developed and / or modified by Raytheon Company,
* pursuant to Contract DG133W-05-CQ-1067 with the US Government.
*
* U.S. EXPORT CONTROLLED TECHNICAL DATA
* This software product contains export-restricted data whose
* export/transfer/disclosure is restricted by U.S. law. Dissemination
* to non-U.S. persons whether in the United States or abroad requires
* an export license or other authorization.
*
* Contractor Name: Raytheon Company
* Contractor Address: 6825 Pine Street, Suite 340
* Mail Stop B8
* Omaha, NE 68106
* 402.291.0100
*
* See the AWIPS II Master Rights File ("Master Rights File.pdf") for
* further licensing information.
**/
package com.raytheon.edex.plugin.airep.decoder;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertTrue;
import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.TimeZone;
import org.junit.Test;
import com.raytheon.edex.plugin.airep.AirepSeparator;
import com.raytheon.edex.plugin.airep.decoder.AirepParser;
import com.raytheon.uf.common.dataplugin.airep.AirepRecord;
import com.raytheon.uf.edex.decodertools.time.TimeTools;
/**
* Various tests against the AirepParser. Extracted some from "mains" that held
* test code.
*
* <pre>
*
* SOFTWARE HISTORY
*
* Date Ticket# Engineer Description
* ------------ ---------- ----------- --------------------------
* Sep 7, 2012 jkorman Initial creation
*
* </pre>
*
* @author jkorman
* @version 1.0
*/
public class TestAIREPParser {
public static final String WMO_CRCRLF = "\r\r\n";
public static final String WMO_LEAD = "\01";
public static final String WMO_TRAIL = WMO_CRCRLF + "\03";
public static final int TURB_BIT = 0x80;
@Test
public void testAIREPSeparator() {
String data = WMO_LEAD + WMO_CRCRLF + "205" + WMO_CRCRLF + "UAPA01 KWBC 071554" +
WMO_CRCRLF + "ARP DAL278 3336N 165E 1543 F320 MS40 110/010KT TB 1=" +
WMO_CRCRLF + "ARP PAL110 12N 130E 1544 F370 MS48 090/025KT=" +
WMO_CRCRLF + "ARP UAL595 3746N 08107W 1504 F370 MS46 294/058KT TB LGT RM B752 OV" +
WMO_CRCRLF + " BKW=" + WMO_TRAIL;
String report = null;
AirepSeparator sep = AirepSeparator.separate(data.getBytes(), null);
assertNotNull(sep);
assertTrue(sep.hasNext());
report = sep.next().report;
assertEquals("ARP DAL278 3336N 165E 1543 F320 MS40 110/010KT TB 1",report);
report = sep.next().report;
assertEquals("ARP PAL110 12N 130E 1544 F370 MS48 090/025KT",report);
report = sep.next().report;
assertEquals("ARP UAL595 3746N 08107W 1504 F370 MS46 294/058KT TB LGT RM B752 OV\r BKW",report);
}
@Test
public void testLockup() {
String data = WMO_LEAD + WMO_CRCRLF + "494" + WMO_CRCRLF + "UAUS31 KWBC 112254" +
WMO_CRCRLF + "ARP UAL819 4626N 10618W 2248 F360 TB CONT LGT CHOP RM B752 OV" +
WMO_CRCRLF + " MLS270015=" + WMO_TRAIL;
String report = null;
AirepSeparator sep = AirepSeparator.separate(data.getBytes(), null);
assertNotNull(sep);
assertTrue(sep.hasNext());
AirepParser p = null;
Calendar c = TimeTools.getSystemCalendar(2012, 9, 10, 16, 10);
// The following are in degrees minutes
p = new AirepParser(sep.next().report, c);
assertNotNull(p);
}
/**
* Various forms of location identification.
*/
@Test
public void testPositionDecode() {
AirepParser p = null;
Calendar c = TimeTools.getSystemCalendar(2012, 9, 10, 16, 10);
// The following are in degrees minutes
p = new AirepParser("ARP DAL278 3336N 165E 1543 F320 MS40 110/010KT TB LGT=", c);
assertEquals("DAL278", p.getAircraftId());
assertEquals(33.6, p.getLatitude(), 0.01);
assertEquals(165.0, p.getLongitude(), 0.01);
p = new AirepParser("ARP DAL278 3336N 165W 1543 F320 MS40 110/010KT TB LGT=", c);
assertEquals("DAL278", p.getAircraftId());
assertEquals(33.6, p.getLatitude(), 0.01);
assertEquals(-165.0, p.getLongitude(), 0.01);
p = new AirepParser("ARP DAL278 N3336 E165 1543 F320 MS40 110/010KT TB LGT=", c);
assertEquals("DAL278", p.getAircraftId());
assertEquals(33.6, p.getLatitude(), 0.01);
assertEquals(165.0, p.getLongitude(), 0.01);
p = new AirepParser("ARP DAL278 N3336 W165 1543 F320 MS40 110/010KT TB LGT=", c);
assertEquals("DAL278", p.getAircraftId());
assertEquals(33.6, p.getLatitude(), 0.01);
assertEquals(-165.0, p.getLongitude(), 0.01);
// These are in decimal degrees!
p = new AirepParser("ARP DAL278 N33.36W089.25 1543 F320 MS40 110/010KT TB LGT=", c);
assertEquals("DAL278", p.getAircraftId());
assertEquals(33.36, p.getLatitude(), 0.01);
assertEquals(-89.25, p.getLongitude(), 0.01);
p = new AirepParser("ARP DAL278 33.36N089.25W 1543 F320 MS40 110/010KT TB LGT=", c);
assertEquals("DAL278", p.getAircraftId());
assertEquals(33.36, p.getLatitude(), 0.01);
assertEquals(-89.25, p.getLongitude(), 0.01);
}
/**
* Test various turbulence decoding.
*/
@Test
public void testAIREPParser() {
Calendar c = TimeTools.getSystemCalendar(2012, 9, 10, 16, 10);
AirepParser p = new AirepParser("ARP DAL278 3336N 165E 1543 F320 MS40 110/010KT TB LGT=", c);
AirepParser.Turbulence t = p.getTurbulence();
assertNotNull(t);
assertEquals(0x80 | AirepRecord.TURB_LGT, t.getTurbulence());
p = new AirepParser("ARP DAL278 3336N 165E 1543 F320 MS40 110/010KT TB MOD=", c);
t = p.getTurbulence();
assertNotNull(t);
assertEquals(TURB_BIT | AirepRecord.TURB_MOD, t.getTurbulence());
p = new AirepParser("ARP DAL278 3336N 165E 1543 F320 MS40 110/010KT TB MDT=", c);
t = p.getTurbulence();
assertNotNull(t);
assertEquals(0x40 | TURB_BIT, t.getTurbulence());
p = new AirepParser("ARP DAL278 3336N 165E 1543 F320 MS40 110/010KT TB LGT OCN MDT CAT=", c);
t = p.getTurbulence();
assertNotNull(t);
assertEquals(TURB_BIT | AirepRecord.TURB_MOD | AirepRecord.TURB_TYPE_CAT | AirepRecord.TURB_FREQ_OCN, t.getTurbulence());
p = new AirepParser("ARP DAL278 3336N 165E 1543 F320 MS40 110/010KT TB LGT CAT OCN MDT=", c);
t = p.getTurbulence();
assertNotNull(t);
assertEquals(TURB_BIT | AirepRecord.TURB_MOD | AirepRecord.TURB_TYPE_CAT | AirepRecord.TURB_FREQ_OCN, t.getTurbulence());
p = new AirepParser("ARP DAL278 3336N 165E 1543 F320 MS40 110/010KT TB SVR=", c);
t = p.getTurbulence();
assertNotNull(t);
assertEquals(TURB_BIT | AirepRecord.TURB_SEV, t.getTurbulence());
p = new AirepParser("ARP DAL278 3336N 165E 1543 F320 MS40 110/010KT TB XTRM=", c);
t = p.getTurbulence();
assertNotNull(t);
assertEquals(TURB_BIT | AirepRecord.TURB_XTRM, t.getTurbulence());
p = new AirepParser("ARP HAL4 2714N 14713W 0957 F350 MS46 270/052KT TB 1=", c);
t = p.getTurbulence();
assertNotNull(t);
assertEquals(TURB_BIT | AirepRecord.TURB_LGT, t.getTurbulence());
// Compound turbulence value
p = new AirepParser("ARP UAL761 3825N 11042W 1557 F340 MS44 235/030KT TB LGT-MOD RM\r\r\n A320 OV HVE=", c);
t = p.getTurbulence();
assertNotNull(t);
assertEquals(TURB_BIT | AirepRecord.TURB_LGT_MOD, t.getTurbulence());
// Compound turbulence value
p = new AirepParser("ARP UAL761 3825N 11042W 1557 F340 MS44 235/030KT TB LGTMOD RM\r\r\n A320 OV HVE=", c);
t = p.getTurbulence();
assertNotNull(t);
assertEquals(TURB_BIT | AirepRecord.TURB_LGT_MOD, t.getTurbulence());
// Two adjacent intensities-assume the strongest!
p = new AirepParser("ARP UAL761 3825N 11042W 1557 F340 MS44 235/030KT TB LGT MOD RM\r\r\n A320 OV HVE=", c);
t = p.getTurbulence();
assertNotNull(t);
assertEquals(TURB_BIT | AirepRecord.TURB_MOD, t.getTurbulence());
// Checks that the intensity and frequency is extracted from non-reported data.
p = new AirepParser("ARP UAL761 3825N 11042W 1557 F340 TB OCNL MOD TURBC IN CLOUD TOPS\r\r\n RM A320 OV HVE=", c);
t = p.getTurbulence();
assertNotNull(t);
assertEquals(TURB_BIT | AirepRecord.TURB_MOD | AirepRecord.TURB_FREQ_OCN, t.getTurbulence());
}
@Test
public void testAIREPTimes() {
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
sdf.setTimeZone(TimeZone.getTimeZone("ZULU"));
Calendar refTime = TimeTools.getBaseCalendar(2011, 12, 14);
refTime.set(Calendar.HOUR_OF_DAY, 17);
refTime.set(Calendar.MINUTE, 15);
refTime.set(Calendar.SECOND, 00);
refTime.set(Calendar.MILLISECOND, 0);
AirepParser p = new AirepParser("ARP UAL121 4400N 05700W 1640 F390 MS00 000/099KT TB MOD SK CLEAR=",refTime);
Calendar c = p.getObservationTime();
assertNotNull(c);
assertEquals(14, c.get(Calendar.DAY_OF_MONTH));
assertEquals(16, c.get(Calendar.HOUR_OF_DAY));
assertEquals(40, c.get(Calendar.MINUTE));
}
/**
* Test that an observation time greater than the reference time rolls
* back to the previous day.
*/
@Test
public void testAIREPDateRollback() {
Calendar refTime = TimeTools.getBaseCalendar(2011, 12, 14);
refTime.set(Calendar.HOUR_OF_DAY, 17);
refTime.set(Calendar.MINUTE, 15);
refTime.set(Calendar.SECOND, 00);
refTime.set(Calendar.MILLISECOND, 0);
String data = "ARP UAL121 4400N 05700W 1840 F390 MS00 000/099KT TB MOD SK CLEAR=";
AirepParser p = new AirepParser(data,refTime);
Calendar c = p.getObservationTime();
assertNotNull(c);
assertEquals(13, c.get(Calendar.DAY_OF_MONTH));
assertEquals(18, c.get(Calendar.HOUR_OF_DAY));
assertEquals(40, c.get(Calendar.MINUTE));
}
/**
* Test various reported winds
*/
@Test
public void testAIREPWinds() {
Calendar c = TimeTools.getSystemCalendar(2012, 9, 10, 16, 10);
AirepParser p = null;
// Winds with "KT"
p = new AirepParser("ARP DAL278 3336N 165E 1543 F320 MS40 110/010KT TB LGT=", c);
assertNotNull(p);
assertEquals(110, p.getWindDirection().intValue());
assertEquals(10, p.getWindSpeed().intValue());
// Winds with "KTS"
p = new AirepParser("ARP DAL278 3336N 165E 1543 F320 MS40 265/010KTS TB LGT=", c);
assertNotNull(p);
assertEquals(265, p.getWindDirection().intValue());
assertEquals(10, p.getWindSpeed().intValue());
// Winds with no units - assume knots
p = new AirepParser("ARP DAL278 3336N 165E 1543 F320 MS40 265/010 TB LGT=", c);
assertNotNull(p);
assertEquals(265, p.getWindDirection().intValue());
assertEquals(10, p.getWindSpeed().intValue());
}
}

View file

@ -1,167 +0,0 @@
/**
* This software was developed and / or modified by Raytheon Company,
* pursuant to Contract DG133W-05-CQ-1067 with the US Government.
*
* U.S. EXPORT CONTROLLED TECHNICAL DATA
* This software product contains export-restricted data whose
* export/transfer/disclosure is restricted by U.S. law. Dissemination
* to non-U.S. persons whether in the United States or abroad requires
* an export license or other authorization.
*
* Contractor Name: Raytheon Company
* Contractor Address: 6825 Pine Street, Suite 340
* Mail Stop B8
* Omaha, NE 68106
* 402.291.0100
*
* See the AWIPS II Master Rights File ("Master Rights File.pdf") for
* further licensing information.
**/
package com.raytheon.edex.plugin.pirep;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import org.junit.Test;
import com.raytheon.edex.plugin.pirep.decoder.PirepTools;
import com.raytheon.uf.edex.decodertools.core.BasePoint;
import static org.junit.Assert.*;
/**
* Extracted methods tests from PirepParser.
*
* <pre>
*
* SOFTWARE HISTORY
*
* Date Ticket# Engineer Description
* ------------ ---------- ----------- --------------------------
* Aug 10, 2012 jkorman Initial creation
*
* </pre>
*
* @author jkorman
* @version 1.0
*/
public class TestPIREPParser {
private static final String LATLON_PTRN = "((([0-8]\\d[0-5]\\d)|(9000))[NS] ((0\\d{2}[0-5]\\d)|([1][0-7]\\d[0-5]\\d)|(18000))[EW])";
private static BasePoint parseLatLon(String latlon) {
BasePoint point = null;
// 012345678901
// lldds llldds
Integer lat_dd = PirepTools.parseInteger(latlon.substring(0, 2));
Integer lat_mm = PirepTools.parseInteger(latlon.substring(2, 4));
Integer lon_dd = PirepTools.parseInteger(latlon.substring(6, 9));
Integer lon_mm = PirepTools.parseInteger(latlon.substring(9, 11));
if ((lat_dd != null) && (lat_mm) != null) {
if ((lon_dd != null) && (lon_mm) != null) {
Double lat = lat_dd + (lat_mm / 60.0d);
Double lon = lon_dd + (lon_mm / 60.0d);
if (lat_dd.equals(0) && (lat_mm.equals(0))) {
lat = 0.0;
} else {
switch (latlon.charAt(4)) {
case 'N': {
break;
}
case 'S': {
lat = lat * -1;
break;
}
default: {
lat = null;
}
}
}
if (lon_dd.equals(0) && (lon_mm.equals(0))) {
lon = 0.0;
} else {
switch (latlon.charAt(11)) {
case 'E': {
break;
}
case 'W': {
lon = lon * -1;
break;
}
default: {
lon = null;
}
}
}
if (lat != null && lon != null) {
point = new BasePoint(lat, lon);
}
}
}
return point;
}
@Test
public void testparseLatLon() {
String[] latlons = { "0000N 00000W", "0000S 00000E", "9000S 00000W",
"9000N 00000W", "0000N 09000W", "9000S 09000W", "9000N 09000W",
"0000N 09000W", "4500S 09000W", "9000N 09000W",
"9000N 09959W", "0000N 10000W",
"4500S 09000W", "9000N 09000W",
"9000N 18000E", "9000S 18000E", "9000N 18000W", "9000S 18000W",
"9000N 17959W", "9000S 17959W",
};
Pattern p = Pattern.compile(LATLON_PTRN);
for (String s : latlons) {
Matcher m = p.matcher(s);
if (m.find()) {
BasePoint b = parseLatLon(m.group());
if (b != null) {
System.out.println(String.format("%16s %10.6f %11.6f", s,
b.getLatitude(), b.getLongitude()));
} else {
fail("Invalid parse " + s);
}
} else {
fail("no match for " + s);
}
}
}
@Test
public void testBearingDistancePattern() {
final String bearingDistPattern = "^([A-Z,0-9]{3,4})\\s*(\\d{3})(\\d{3})$";
String str = "123 123 123 \r SCT";
str = str.replaceAll("[\r\n]", " ");
str = str.replaceAll(" {2,}", " ");
System.out.println("[" + str + "]");
Pattern p = Pattern.compile(bearingDistPattern);
Matcher m = p.matcher("OMA 080056");
if(m.find()) {
System.out.println(m.group(1));
System.out.println(m.group(2) + " " + m.group(3));
}
m = p.matcher("OMA080056");
if(m.find()) {
System.out.println(m.group(1));
System.out.println(m.group(2) + " " + m.group(3));
}
}
}

View file

@ -1,233 +0,0 @@
/**
* This software was developed and / or modified by Raytheon Company,
* pursuant to Contract DG133W-05-CQ-1067 with the US Government.
*
* U.S. EXPORT CONTROLLED TECHNICAL DATA
* This software product contains export-restricted data whose
* export/transfer/disclosure is restricted by U.S. law. Dissemination
* to non-U.S. persons whether in the United States or abroad requires
* an export license or other authorization.
*
* Contractor Name: Raytheon Company
* Contractor Address: 6825 Pine Street, Suite 340
* Mail Stop B8
* Omaha, NE 68106
* 402.291.0100
*
* See the AWIPS II Master Rights File ("Master Rights File.pdf") for
* further licensing information.
**/
package com.raytheon.edex.plugin.pirep;
import java.util.List;
import org.junit.Test;
import com.raytheon.edex.plugin.pirep.decoder.PirepTools;
import com.raytheon.uf.common.dataplugin.pirep.PirepLayerData;
import com.raytheon.uf.common.dataplugin.pirep.PirepRecord;
import com.raytheon.uf.edex.decodertools.aircraft.AircraftFlightCondition;
import static org.junit.Assert.*;
/**
* Test various PIREP decoder components.
*
* <pre>
*
* SOFTWARE HISTORY
*
* Date Ticket# Engineer Description
* ------------ ---------- ----------- --------------------------
* Aug 8, 2012 jkorman Initial creation
*
* </pre>
*
* @author jkorman
* @version 1.0
*/
public class TestPIREPRecord {
/**
* Test that the getter for TBF (turbulence frequency) and TBI (turbulence
* intensity) get the data for the greatest intensity.
*/
@Test
public void testTurbulenceConstruction() {
PirepRecord rec = new PirepRecord();
PirepLayerData layer = new PirepLayerData(rec);
layer.setLayerType(PirepLayerData.LAYER_TYP_TURBC);
layer.setFrequency("OCN");
layer.setFirstValue("LGT");
layer.setSecondValue("MOD");
layer.setBaseLayerHeight(15000);
layer.setTopLayerHeight(20000);
rec.addLayer(layer);
layer = new PirepLayerData(rec);
layer.setLayerType(PirepLayerData.LAYER_TYP_TURBC);
layer.setFrequency("CON");
layer.setFirstValue("MOD");
layer.setSecondValue("SEV");
layer.setBaseLayerHeight(20000);
layer.setTopLayerHeight(22000);
rec.addLayer(layer);
String[] data = rec.getStrings("TBF");
assertNotNull(data);
assertTrue(data.length > 0);
assertEquals("CON", data[0]);
data = rec.getStrings("TBI");
assertNotNull(data);
assertTrue(data.length > 0);
assertEquals("MODSEV", data[0]);
}
/**
* Turbulence at one level, differing intensities.
*/
@Test
public void testPirepTurbc_1() {
AircraftFlightCondition expected = new AircraftFlightCondition();
expected.setBaseHeight(10000);
expected.setTopHeight(null);
expected.setIntensity1("MOD");
expected.setIntensity2("SEV");
expected.setType(null);
expected.setFrequency(null);
PirepTools t = new PirepTools("MOD TO SVR 100");
checkLevel(t, 1);
checkData(expected, t.decodeTurbulenceData().get(0));
}
/**
* Turbulence between levels, differing intensities with frequency.
*/
@Test
public void testPirepTurbc_2() {
AircraftFlightCondition expected = new AircraftFlightCondition();
expected.setBaseHeight(20000);
expected.setTopHeight(30000);
expected.setIntensity1("MOD");
expected.setIntensity2("SEV");
expected.setType(null);
expected.setFrequency("OCN");
PirepTools t = new PirepTools("SVR OCNL MOD 200-300");
checkLevel(t, 1);
checkData(expected, t.decodeTurbulenceData().get(0));
}
/**
* Turbulence between levels, differing intensities.
*/
@Test
public void testPirepTurbc_3() {
AircraftFlightCondition expected = new AircraftFlightCondition();
expected.setBaseHeight(12000);
expected.setTopHeight(15000);
expected.setIntensity1("LGT");
expected.setIntensity2("MOD");
expected.setType(null);
expected.setFrequency(null);
PirepTools t = new PirepTools("LGT-MDT 120-150");
checkLevel(t, 1);
checkData(expected, t.decodeTurbulenceData().get(0));
}
/**
* Turbulence below a level, single intensity. Embedded carriage control
* should be ignored.
*/
@Test
public void testPirepTurbc_4() {
AircraftFlightCondition expected = new AircraftFlightCondition();
expected.setBaseHeight(-9999);
expected.setTopHeight(10000);
expected.setIntensity1("MOD");
expected.setIntensity2(null);
expected.setType(null);
expected.setFrequency(null);
PirepTools t = new PirepTools("MDT BLO\n 100");
checkLevel(t, 1);
checkData(expected, t.decodeTurbulenceData().get(0));
}
/**
* Turbulence above a level, differing intensities. Light turbulence (LGT)
* is misspelled. Includes a turbulence type.
*/
@Test
public void testPirepTurbc_5() {
AircraftFlightCondition expected = new AircraftFlightCondition();
expected.setBaseHeight(-9999);
expected.setTopHeight(12000);
expected.setIntensity1("LGT");
expected.setIntensity2("MOD");
expected.setType("CHOP");
expected.setFrequency(null);
PirepTools t = new PirepTools("LIT-MOD CHOP ABOVE 120");
checkLevel(t, 1);
checkData(expected, t.decodeTurbulenceData().get(0));
}
/**
* Turbulence between two levels, show that levels are reordered. Includes a
* turbulence frequency, show that it is corrected.
*/
@Test
public void testPirepTurbc_6() {
AircraftFlightCondition expected = new AircraftFlightCondition();
expected.setBaseHeight(8000);
expected.setTopHeight(12000);
expected.setIntensity1("MOD");
expected.setIntensity2(null);
expected.setType(null);
expected.setFrequency("CON");
PirepTools t = new PirepTools("CONTINOUS MOD 120-080");
checkLevel(t, 1);
List<AircraftFlightCondition> list = t.decodeTurbulenceData();
checkData(expected, list.get(0));
}
/**
* Checks that the PirepTools has decoded data.
*
* @param tools
* The tools object that contains decoded data.
*/
private void checkLevel(PirepTools tools, int elements) {
assertNotNull(tools);
List<AircraftFlightCondition> list = tools.decodeTurbulenceData();
assertNotNull(list);
assertEquals(elements, list.size());
}
/**
* Checks individual data elements.
*
* @param expected
* The expected flight conditions.
* @param actual
* The actual decoded flight conditions.
*/
private void checkData(AircraftFlightCondition expected,
AircraftFlightCondition actual) {
assertEquals(expected.getFrequency(), actual.getFrequency());
assertEquals(expected.getIntensity1(), actual.getIntensity1());
assertEquals(expected.getIntensity2(), actual.getIntensity2());
assertEquals(expected.getType(), actual.getType());
assertEquals(expected.getBaseHeight(), actual.getBaseHeight());
assertEquals(expected.getTopHeight(), actual.getTopHeight());
}
}

View file

@ -1,142 +0,0 @@
/**
* This software was developed and / or modified by Raytheon Company,
* pursuant to Contract DG133W-05-CQ-1067 with the US Government.
*
* U.S. EXPORT CONTROLLED TECHNICAL DATA
* This software product contains export-restricted data whose
* export/transfer/disclosure is restricted by U.S. law. Dissemination
* to non-U.S. persons whether in the United States or abroad requires
* an export license or other authorization.
*
* Contractor Name: Raytheon Company
* Contractor Address: 6825 Pine Street, Suite 340
* Mail Stop B8
* Omaha, NE 68106
* 402.291.0100
*
* See the AWIPS II Master Rights File ("Master Rights File.pdf") for
* further licensing information.
**/
package com.raytheon.edex.plugin.pirep;
import java.util.List;
import org.junit.Test;
import static org.junit.Assert.*;
import com.raytheon.edex.plugin.pirep.PirepSeparator;
import com.raytheon.edex.plugin.pirep.decoder.PirepTools;
import com.raytheon.edex.plugin.pirep.decoder.TEI;
import com.raytheon.edex.plugin.pirep.decoder.TEIInfo;
/**
* Various unit tests for the TEIInfo parser class.
*
* <pre>
*
* SOFTWARE HISTORY
*
* Date Ticket# Engineer Description
* ------------ ---------- ----------- --------------------------
* Aug 7, 2012 jkorman Initial creation
*
* </pre>
*
* @author jkorman
* @version 1.0
*/
public class TestTEIInfo {
/**
* Test that a legal PIREP is parsed correctly.
*/
@Test
public void testParseNormal() {
final String data = "LYH UA /OV LYH/TM 1226/FL210/TP P180/SK OVC100/WX FV99SM/TA 0/WV 27035KT/TB MDT/IC LGT RIME/RM CB W=";
List<TEIInfo> parts = TEIInfo.findTEIs(data);
assertNotNull(parts);
assertEquals(12, parts.size());
assertEquals(TEI.PIREP, parts.get(0).getTei());
assertEquals(TEI.OV, parts.get(1).getTei());
assertEquals(TEI.TM, parts.get(2).getTei());
assertEquals(TEI.FL, parts.get(3).getTei());
assertEquals(TEI.TP, parts.get(4).getTei());
assertEquals(TEI.SK, parts.get(5).getTei());
assertEquals(TEI.WX, parts.get(6).getTei());
assertEquals(TEI.TA, parts.get(7).getTei());
assertEquals(TEI.WV, parts.get(8).getTei());
assertEquals(TEI.TB, parts.get(9).getTei());
assertEquals(TEI.IC, parts.get(10).getTei());
assertEquals(TEI.RM, parts.get(11).getTei());
}
/**
* Test that out of order elements are parsed correctly.
*/
@Test
public void testParseBadOrder() {
final String data = "LYH UA /OV LYH/TM 1226/FL210/SK OVC100/TP P180/WX FV99SM/TA 0/WV 27035KT/IC LGT RIME/TB MDT/RM CB W=";
List<TEIInfo> parts = TEIInfo.findTEIs(data);
assertNotNull(parts);
assertEquals(12, parts.size());
assertEquals(TEI.PIREP, parts.get(0).getTei());
assertEquals(TEI.OV, parts.get(1).getTei());
assertEquals(TEI.TM, parts.get(2).getTei());
assertEquals(TEI.FL, parts.get(3).getTei());
assertEquals(TEI.SK, parts.get(4).getTei());
assertEquals(TEI.TP, parts.get(5).getTei());
assertEquals(TEI.WX, parts.get(6).getTei());
assertEquals(TEI.TA, parts.get(7).getTei());
assertEquals(TEI.WV, parts.get(8).getTei());
assertEquals(TEI.IC, parts.get(9).getTei());
assertEquals(TEI.TB, parts.get(10).getTei());
assertEquals(TEI.RM, parts.get(11).getTei());
}
/**
* Test that "/SKC" does not get confused with the "/SK" TEI.
*/
@Test
public void testSky() {
final String data = "LYH UA /OV LYH/TM 1226/FL210/SK OVC100/SKC/TA 0/WV 27035KT=";
final String skyData = "OVC100/SKC";
List<TEIInfo> parts = TEIInfo.findTEIs(data);
assertNotNull(parts);
assertEquals(7, parts.size());
assertEquals(TEI.PIREP, parts.get(0).getTei());
assertEquals(TEI.OV, parts.get(1).getTei());
assertEquals(TEI.TM, parts.get(2).getTei());
assertEquals(TEI.FL, parts.get(3).getTei());
assertEquals(TEI.SK, parts.get(4).getTei());
assertEquals(skyData, parts.get(4).getTeiText());
assertEquals(TEI.TA, parts.get(5).getTei());
assertEquals(TEI.WV, parts.get(6).getTei());
}
/**
* Test that "/SKC" does not get confused with the "/SK" TEI.
*/
@Test
public void testNoTurbDecode() {
final String data = "UBUS01 KMSC 061800\nCAO UA /OV DHT310017 /TM 1850 /FL125 /TP BE35 /WX FV30SM /TA 12\n/WV 24021KT /TB NEG=";
PirepSeparator sep = PirepSeparator.separate(data.getBytes(), null);
while(sep.hasNext()) {
List<TEIInfo> parts = TEIInfo.findTEIs(sep.next().getReport());
PirepTools tools = null;
for(TEIInfo info : parts) {
System.out.println(info.getTeiText());
if(TEI.TB.equals(info.getTei())) {
tools = new PirepTools(info.getTeiText());
System.out.println(tools.decodeTurbulenceData());
}
}
}
}
}