### Question:
Util { public static String getTemplate(Class<?> clazz) { Component cmp = clazz.getAnnotation(Component.class); if (cmp == null) { throw new NgoyException("Annotation %s not found on class %s", Component.class.getName(), clazz.getName()); } String templateUrl = cmp.templateUrl(); String tpl; if (isSet(templateUrl)) { InputStream in = clazz.getResourceAsStream(templateUrl); if (in == null) { throw new NgoyException("Template could not be found: '%s'", templateUrl); } try (InputStream inn = in) { tpl = copyToString(inn); } catch (Exception e) { throw wrap(e); } } else { tpl = cmp.template(); } return tpl; } private  Util(); static void copy(InputStream in, OutputStream out); static String copyToString(InputStream in); static boolean isSet(@Nullable String s); static String escapeJava(String text); static String escapeHtmlXml(String text); static String getTemplate(Class<?> clazz); static String getLine(String s, int lineNumber); static String getCompileExceptionMessageWithoutLocation(CompileException compileException); static String primitiveToRefType(String clazz); static boolean isPrimitive(String clazz); static String sourceClassName(Class<?> clazz); static String sourceClassName(Field field); static String sourceClassName(Method method); static String sourceClassName(Class<?> clazz, @Nullable Type genericType); static String getArrayClass(String type); static Class<?> tryLoadClass(String type); static Method findMethod(Class<?> c, String methodName, int nArgs); @Nullable static Method findMethod(Class<?> c, String methodName, int nArgs, boolean forLambda); @SuppressWarnings("unchecked") static Map<K, V> map(Object... keyValuePairs); @SafeVarargs static List<T> list(T... items); @SafeVarargs static Set<T> set(T... items);  }### Answer:
@Test public void getTemplate_noAnnotation() { expectedEx.expect(NgoyException.class); expectedEx.expectMessage(containsString("Annotation")); expectedEx.expectMessage(containsString(format("not found on class %s", UtilTest.class.getName()))); Util.getTemplate(UtilTest.class); }
@Test public void getTemplate_notFound() { expectedEx.expect(NgoyException.class); expectedEx.expectMessage(containsString("Template could not be found")); expectedEx.expectMessage(containsString("does_not_exist")); Util.getTemplate(NotFoundCmp.class); }
@Test public void getTemplate_ok() { assertThat(Util.getTemplate(OkCmp.class)).isEqualTo("test-abc"); }