src/test/java/gov/usgs/cida/pubs/DaoAnnotationsTest.java
@SuppressWarnings({ "unchecked", "rawtypes" })
	@Test
	public void testRequiredAnnotations()  
	throws IOException, NoSuchMethodException, ClassNotFoundException {
		Class[] classes = getClasses("gov.usgs.cida.pubs.dao");
		Collection<Class<?>> exc = List.of(EXCLUDE_CLASSES);
		Collection<String> excMethod = List.of(EXCLUDE_METHODS);
		for (Class classe : classes) {
			Class c = classe;
			if (!exc.contains(c)) {
				Method[] methods = c.getDeclaredMethods();
				for (Method method : methods) {
					if (!method.isBridge()
							&& !excMethod.contains(method.getName())) {
						for (Class element : REQUIRED_ANNOTATIONS) {
							if ((method.getName().startsWith("set") && method
									.getName().endsWith("Dao"))
									|| method.getName().endsWith("Test")) {
								// Skip setxxxDao Methods
								continue;
							} else if (Modifier.PUBLIC == method.getModifiers()) {
								assertTrue(
										method.isAnnotationPresent(element),
										"Method " + method.getName()
												+ " of Class " + c.getName()
												+ " does not have annotation :"
												+ element
										);
								if (element
										.isAssignableFrom(Transactional.class)) {
									if (method.getName().startsWith("get")
											|| method.getName().startsWith(
													"find")) {
										assertTrue(
												((Transactional) method
														.getAnnotation(element))
														.readOnly(),
												"Method "
														+ method.getName()
														+ " of Class "
														+ c.getName()
														+ " has a \"get\" Method that is not ReadOnly"
												);
									} else {
										assertEquals(
												((Transactional) method
														.getAnnotation(element))
														.propagation(),
												Propagation.REQUIRED,
												"Method "
														+ method.getName()
														+ " of Class "
														+ c.getName()
														+ " has a non-\"get\" "
														+ "Method that is NOT Transaction required"
												);
									}
								}
							}
						}
					}
				}
			}
		}
	}
/**
	 * Test methods in dao classes have required annotations.
	 * @throws IOException e.
	 * @throws NoSuchMethodException e.
	 * @throws ClassNotFoundException e.
	 */
Test methods in dao classes have required annotations.
Test methods in dao classes have required annotations .
@SuppressWarnings({ "unchecked", "rawtypes" })
	@Test
	public void testRequiredAnnotations()  
	throws IOException, NoSuchMethodException, ClassNotFoundException {
		Class[] classes = getClasses("gov.usgs.cida.pubs.dao");
		Collection<Class<?>> exc = List.of(EXCLUDE_CLASSES);
		Collection<String> excMethod = List.of(EXCLUDE_METHODS);
		for (Class classe : classes) {
			Class c = classe;
			if (!exc.contains(c)) {
				Method[] methods = c.getDeclaredMethods();
				for (Method method : methods) {
					if (!method.isBridge()
							&& !excMethod.contains(method.getName())) {
						for (Class element : REQUIRED_ANNOTATIONS) {
							if ((method.getName().startsWith("set") && method
									.getName().endsWith("Dao"))
									|| method.getName().endsWith("Test")) {
								continue;
							} else if (Modifier.PUBLIC == method.getModifiers()) {
								assertTrue(
										method.isAnnotationPresent(element),
										"Method " + method.getName()
												+ " of Class " + c.getName()
												+ " does not have annotation :"
												+ element
										);
								if (element
										.isAssignableFrom(Transactional.class)) {
									if (method.getName().startsWith("get")
											|| method.getName().startsWith(
													"find")) {
										assertTrue(
												((Transactional) method
														.getAnnotation(element))
														.readOnly(),
												"Method "
														+ method.getName()
														+ " of Class "
														+ c.getName()
														+ " has a \"get\" Method that is not ReadOnly"
												);
									} else {
										assertEquals(
												((Transactional) method
														.getAnnotation(element))
														.propagation(),
												Propagation.REQUIRED,
												"Method "
														+ method.getName()
														+ " of Class "
														+ c.getName()
														+ " has a non-\"get\" "
														+ "Method that is NOT Transaction required"
												);
									}
								}
							}
						}
					}
				}
			}
		}
	}
@ SuppressWarnings ( { "unchecked" , "rawtypes" } ) @ Test public void testRequiredAnnotations ( ) throws IOException , NoSuchMethodException , ClassNotFoundException { Class [ ] classes = getClasses ( "gov.usgs.cida.pubs.dao" ) ; Collection < Class < ? > > exc = List . of ( EXCLUDE_CLASSES ) ; Collection < String > excMethod = List . of ( EXCLUDE_METHODS ) ; for ( Class classe : classes ) { Class c = classe ; if ( ! exc . contains ( c ) ) { Method [ ] methods = c . getDeclaredMethods ( ) ; for ( Method method : methods ) { if ( ! method . isBridge ( ) && ! excMethod . contains ( method . getName ( ) ) ) { for ( Class element : REQUIRED_ANNOTATIONS ) { if ( ( method . getName ( ) . startsWith ( "set" ) && method . getName ( ) . endsWith ( "Dao" ) ) || method . getName ( ) . endsWith ( "Test" ) ) { continue ; } else if ( Modifier . PUBLIC == method . getModifiers ( ) ) { assertTrue ( method . isAnnotationPresent ( element ) , "Method " + method . getName ( ) + " of Class " + c . getName ( ) + " does not have annotation :" + element ) ; if ( element . isAssignableFrom ( Transactional . class ) ) { if ( method . getName ( ) . startsWith ( "get" ) || method . getName ( ) . startsWith ( "find" ) ) { assertTrue ( ( ( Transactional ) method . getAnnotation ( element ) ) . readOnly ( ) , "Method " + method . getName ( ) + " of Class " + c . getName ( ) + " has a \"get\" Method that is not ReadOnly" ) ; } else { assertEquals ( ( ( Transactional ) method . getAnnotation ( element ) ) . propagation ( ) , Propagation . REQUIRED , "Method " + method . getName ( ) + " of Class " + c . getName ( ) + " has a non-\"get\" " + "Method that is NOT Transaction required" ) ; } } } } } } } } }
Test methods in dao classes have required annotations.
Test methods in dao classes have required annotations .
// Skip setxxxDao Methods