ModuleUtils { static String parseYearFromCopyrightString(String copyright) { if (copyright == null) { return "-1"; } String regex = "(\\d{4})\\s?-?\\s?(\\d{4})?"; Pattern pattern = Pattern.compile(regex); Matcher matcher = pattern.matcher(copyright); if (matcher.find()) { String firstYear = matcher.group(1); if (matcher.group(2) != null) { return firstYear + "-" + matcher.group(2); } else { return firstYear; } } else { return "-1"; } }  static Module[] removeDoubles(Module[] modules); static boolean isExcluded(Module module, String[] excludedModules); static String retrieveYear(Module module); static String retrieveSize(Module module); static Module[] cleanModules(Module[] modules, Reader exclusionListReader); static boolean isExcluded(String module, Reader exclusionListReader); static String symbolicToReadableName(String symbolicName, Module[] modules);  }
@Test public void testParseYearFromCopyrightString() throws Exception { assertThat(parseYearFromCopyrightString(null), is("-1")); assertThat(parseYearFromCopyrightString("Copyright (c) 2012 by Brockmann Consult GmbH"), is("2012")); assertThat(parseYearFromCopyrightString("(c) Copyright 1999 by Brockmann Consult GmbH"), is("1999")); assertThat(parseYearFromCopyrightString("(c) Copyright 2004 by NASA"), is("2004")); assertThat(parseYearFromCopyrightString("(c) 1756 Copyright by NASA"), is("1756")); assertThat(parseYearFromCopyrightString("(c) Copyright 3084 by FUB"), is("3084")); assertThat(parseYearFromCopyrightString("(c) Copyright 2009-2013 by FUB"), is("2009-2013")); assertThat(parseYearFromCopyrightString("(c) Copyright 2009 - 2013 by FUB"), is("2009-2013")); assertThat(parseYearFromCopyrightString("(c) Copyright 2008 BC GmbH"), is("2008")); }