ProximityRegion { public boolean isValid() { if (proximityId == null) { Logger.error("The proximity ID must not be null."); return false; } if (!RegionEvent.regionEventCharacterCountIsValid(proximityId)) { Logger.error("The proximity ID must not be greater than %s or less than %s characters in length.", RegionEvent.MAX_CHARACTER_LENGTH, 1); return false; } if (major > MAX_MAJOR_MINOR_VALUE || major < 0) { Logger.error("The major must not be greater than " + MAX_MAJOR_MINOR_VALUE + " or less than " + 0 + "."); return false; } if (minor > MAX_MAJOR_MINOR_VALUE || minor < 0) { Logger.error("The minor must not be greater than %s or less than %s.", MAX_MAJOR_MINOR_VALUE, 0); return false; } return true; } ProximityRegion(@NonNull String proximityId,
                           @IntRange(from = 0, to = MAX_MAJOR_MINOR_VALUE) int major,
                           @IntRange(from = 0, to = MAX_MAJOR_MINOR_VALUE) int minor); void setCoordinates(@Nullable @FloatRange(from = RegionEvent.MIN_LATITUDE, to = RegionEvent.MAX_LATITUDE) Double latitude,
                               @Nullable @FloatRange(from = RegionEvent.MIN_LONGITUDE, to = RegionEvent.MAX_LONGITUDE) Double longitude); void setRssi(@Nullable @IntRange(from = MIN_RSSI, to = MAX_RSSI) Integer rssi); @NonNull String getProximityId(); int getMajor(); int getMinor(); @Nullable Double getLatitude(); @Nullable Double getLongitude(); @Nullable Integer getRssi(); boolean isValid();  }
@Test public void testValidProximityRegion() { ProximityRegion proximityRegion = new ProximityRegion("valid_proximity_region", 1, 2); assertTrue(proximityRegion.isValid()); }
@Test public void testNullProximityId() { ProximityRegion proximityRegion = new ProximityRegion(null, 1, 2); assertFalse(proximityRegion.isValid()); }
@Test public void testProximityIdAboveMax() { String proximityId = createFixedSizeString('a', 256); ProximityRegion proximityRegion = new ProximityRegion(proximityId, 1, 2); assertFalse(proximityRegion.isValid()); }
@Test public void testProximityIdBelowMin() { ProximityRegion proximityRegion = new ProximityRegion("", 1, 2); assertFalse(proximityRegion.isValid()); }
@Test public void testMajorAboveMax() { ProximityRegion proximityRegion = new ProximityRegion("proximity region test", 65536, 2); assertFalse(proximityRegion.isValid()); }
@Test public void testMajorBelowMin() { ProximityRegion proximityRegion = new ProximityRegion("proximity region test", -1, 2); assertFalse(proximityRegion.isValid()); }
@Test public void testMinorAboveMax() { ProximityRegion proximityRegion = new ProximityRegion("proximity region test", 1, 65536); assertFalse(proximityRegion.isValid()); }
@Test public void testMinorBelowMin() { ProximityRegion proximityRegion = new ProximityRegion("proximity region test", 1, -1); assertFalse(proximityRegion.isValid()); }