### Question:
RegularAxisImpl extends AbstractReferenceableAxis<Double> implements RegularAxis, Serializable { @Override public int findIndexOfUnconstrained(Double position) { if (position == null || Double.isNaN(position)) { throw new IllegalArgumentException("Cannot find the index of null or NaN"); } if (isLongitude) { position = GISUtils.getNearestEquivalentLongitude( (getCoordinateExtent().getHigh() + getCoordinateExtent().getLow()) / 2.0, position); } Double indexDbl = getIndex(position); int index = (int) Math.round(indexDbl); return index; } RegularAxisImpl(String name, double firstValue, double spacing, int size,
            boolean isLongitude); @Override boolean wraps(); @Override double getCoordinateSpacing(); @Override Double getCoordinateValue(int index); @Override int size(); @Override boolean isAscending(); @Override String toString(); @Override Extent<Double> getCoordinateBounds(int index); @Override Extent<Double> getCoordinateExtent(); @Override int findIndexOf(Double position); @Override int findIndexOfUnconstrained(Double position); @Override int hashCode(); @Override boolean equals(Object obj);  }### Answer:
@Test(expected = IllegalArgumentException.class) public void testFindIndexOfUnconstrainedException() { Exception caughtEx = null; try { longitudeAxis.findIndexOfUnconstrained(null); } catch (IllegalArgumentException e) { caughtEx = e; } assertNotNull(caughtEx); latitudeAxis.findIndexOfUnconstrained(Double.NaN); }
@Test public void testFindIndexOfUnconstrained() { double step = 1 / 5.0; int maxPosNo = 101; for (int i = 0; i < maxPosNo; i++) { double position = -20.0 + i * step; int expectPos = (int) Math.round((position - 20.0) / SPACE); assertEquals(expectPos, latitudeAxis.findIndexOfUnconstrained(position)); } for (int i = 0; i < maxPosNo; i++) { double position = -20.0 + i * step; int expectPos = (int) Math.round((position - 100.0) / SPACE); assertEquals(expectPos, longitudeAxis.findIndexOfUnconstrained(position)); } for (int i = 0; i < maxPosNo; i++) { double position = 420.0 + i * step; int expectPos = (int) Math.round((position - 360.0 - 100.0) / SPACE); assertEquals(expectPos, longitudeAxis.findIndexOfUnconstrained(position)); } }