@Test public void getGeoLevelBoundsForArea_COMMON1() { /** * Inputs: geography='SAHSU' geoLevelSelect='LEVEL3' studyID=1 mapAreaID='01.008.005600' * * <p>should yield the results: "(54.5492,-6.56952,54.5205,-6.62246)" */ try { User validUser = cloneValidUser(); StudyResultRetrievalContext validStudyResultRetrievalContext = cloneValidResultContext(); validStudyResultRetrievalContext.setGeoLevelSelectName("LEVEL3"); MapArea validMapArea = MapArea.newInstance("01.008.005600", "01.008.005600", "01.008.005600"); BoundaryRectangle boundaryRectangle = rifStudyRetrievalService.getGeoLevelBoundsForArea( validUser, validStudyResultRetrievalContext, validMapArea); assertEquals("-6.56952", boundaryRectangle.getXMax()); assertEquals("54.5492", boundaryRectangle.getYMax()); assertEquals("54.5205", boundaryRectangle.getYMin()); assertEquals("-6.62246", boundaryRectangle.getXMin()); } catch (RIFServiceException rifServiceException) { fail(); } }
@Test public void getGeoLevelBoundsForArea_NULL2() { try { User validUser = cloneValidUser(); MapArea validMapArea = MapArea.newInstance("01.008.003500", "01.008.003500", "01.008.003500"); rifStudyRetrievalService.getGeoLevelBoundsForArea(validUser, null, validMapArea); fail(); } catch (RIFServiceException rifServiceException) { checkErrorType(rifServiceException, RIFServiceError.EMPTY_API_METHOD_PARAMETER, 1); } }
@Test public void getGeoLevelBoundsForArea_NULL1() { try { StudyResultRetrievalContext validStudyResultRetrievalContext = cloneValidResultContext(); validStudyResultRetrievalContext.setGeoLevelSelectName("LEVEL3"); MapArea validMapArea = MapArea.newInstance("01.008.003500", "01.008.003500", "01.008.003500"); rifStudyRetrievalService.getGeoLevelBoundsForArea( null, validStudyResultRetrievalContext, validMapArea); fail(); } catch (RIFServiceException rifServiceException) { checkErrorType(rifServiceException, RIFServiceError.EMPTY_API_METHOD_PARAMETER, 1); } }
@Test public void getGeoLevelBoundsForArea_MALICIOUS3() { try { User validUser = cloneValidUser(); StudyResultRetrievalContext maliciousStudyResultRetrievalContext = cloneMaliciousResultContext(); MapArea validMapArea = MapArea.newInstance("01.008.003500", "01.008.003500", "01.008.003500"); rifStudyRetrievalService.getGeoLevelBoundsForArea( validUser, maliciousStudyResultRetrievalContext, validMapArea); fail(); } catch (RIFServiceException rifServiceException) { checkErrorType(rifServiceException, RIFGenericLibraryError.SECURITY_VIOLATION, 1); } }
@Test public void getGeoLevelBoundsForArea_EMPTY3() { try { User validUser = cloneValidUser(); StudyResultRetrievalContext validStudyResultRetrievalContext = cloneValidResultContext(); validStudyResultRetrievalContext.setGeoLevelSelectName("LEVEL3"); MapArea emptyMapArea = MapArea.newInstance("", "01.008.003500", "01.008.003500"); rifStudyRetrievalService.getGeoLevelBoundsForArea( validUser, validStudyResultRetrievalContext, emptyMapArea); fail(); } catch (RIFServiceException rifServiceException) { checkErrorType(rifServiceException, RIFServiceError.INVALID_MAP_AREA, 1); } }
@Test public void getGeoLevelBoundsForArea_EMPTY2() { try { User validUser = cloneValidUser(); StudyResultRetrievalContext emptyStudyResultRetrievalContext = cloneValidResultContext(); emptyStudyResultRetrievalContext.setStudyID(""); MapArea validMapArea = MapArea.newInstance("01.008.003500", "01.008.003500", "01.008.003500"); rifStudyRetrievalService.getGeoLevelBoundsForArea( validUser, emptyStudyResultRetrievalContext, validMapArea); fail(); } catch (RIFServiceException rifServiceException) { checkErrorType( rifServiceException, RIFServiceError.INVALID_STUDY_RESULT_RETRIEVAL_CONTEXT, 1); } }
/** * Validate form. * * @throws RIFJobSubmissionToolException the RIF job submission tool exception */ public void validateForm() throws RIFServiceException { ArrayList<MapArea> selectedMapAreas = currentMapAreaSelectionBasket.getMapAreas(); ArrayList<MapArea> duplicateMapAreas = MapArea.identifyDuplicatesWithinList(selectedMapAreas); if (duplicateMapAreas.size() > 0) { StringBuilder duplicateList = new StringBuilder(); for (int i = 0; i < duplicateMapAreas.size(); i++) { if (i != 0) { duplicateList.append(","); } duplicateList.append(duplicateMapAreas.get(i).getDisplayName()); } String errorMessage = RIFServiceMessages.getMessage( "mapArea.error.duplicateMapAreasFound", duplicateList.toString()); RIFServiceException rifJobSubmissionToolException = new RIFServiceException(errorMessage); throw rifJobSubmissionToolException; } }