CircularRegion { public boolean isValid() { if (this.radius > MAX_RADIUS || this.radius <= 0) { Logger.error("The radius must be greater than %s and less than or equal to %s meters.", 0, MAX_RADIUS); return false; } if (!RegionEvent.regionEventLatitudeIsValid(this.latitude)) { Logger.error("The latitude must be greater than or equal to %s and less than or equal to %s degrees.", RegionEvent.MIN_LATITUDE, RegionEvent.MAX_LATITUDE); return false; } if (!RegionEvent.regionEventLongitudeIsValid(this.longitude)) { Logger.error("The longitude must be greater than or equal to %s and less than or equal to %s degrees.", RegionEvent.MIN_LONGITUDE, RegionEvent.MAX_LONGITUDE); return false; } return true; } CircularRegion(@FloatRange(from = 0.0, to = MAX_RADIUS) double radius,
                          @FloatRange(from = RegionEvent.MIN_LATITUDE, to = RegionEvent.MAX_LATITUDE) double latitude,
                          @FloatRange(from = RegionEvent.MIN_LONGITUDE, to = RegionEvent.MAX_LONGITUDE) double longitude); double getRadius(); double getLatitude(); double getLongitude(); boolean isValid(); final static int MAX_RADIUS; }
@Test public void testValidCircularRegion() { CircularRegion circularRegion = new CircularRegion(10, 0.0, 0.0); assertTrue(circularRegion.isValid()); }
@Test public void testRadiusAboveMax() { CircularRegion circularRegion = new CircularRegion(100001, 0.0, 0.0); assertFalse(circularRegion.isValid()); }
@Test public void testRadiusBelowMin() { CircularRegion circularRegion = new CircularRegion(-1, 0.0, 0.0); assertFalse(circularRegion.isValid()); }
@Test public void testLatitudeAboveMax() { CircularRegion circularRegion = new CircularRegion(10, 91.0, 0.0); assertFalse(circularRegion.isValid()); }
@Test public void testLatitudeBelowMin() { CircularRegion circularRegion = new CircularRegion(10, -91.0, 0.0); assertFalse(circularRegion.isValid()); }
@Test public void testLongitudeAboveMax() { CircularRegion circularRegion = new CircularRegion(10, 0.0, 181.0); assertFalse(circularRegion.isValid()); }
@Test public void testLongitudeBelowMin() { CircularRegion circularRegion = new CircularRegion(10, 0.0, -181.0); assertFalse(circularRegion.isValid()); }