### Question:
AMLBlockUtility { public static SailfishURI detectLanguage(List<AMLBlock> blocks, Set<SailfishURI> languageURIs, SailfishURI selectedLanguageURI, IActionManager actionManager) throws AMLException { if(AutoLanguageFactory.URI.matches(selectedLanguageURI)) { AMLLanguageDetectorVisitor visitor = new AMLLanguageDetectorVisitor(actionManager, languageURIs); for(AMLBlock block : blocks) { block.accept(visitor); } AlertCollector alertCollector = visitor.getAlertCollector(); if(alertCollector.getCount(AlertType.ERROR) > 0) { throw new AMLException("Failed to detect language", alertCollector); } Set<SailfishURI> compatibleLanguages = visitor.getCompatibleLanguageURIs(); if(compatibleLanguages.isEmpty()) { throw new AMLException("Failed to detect language"); } else { return compatibleLanguages.iterator().next(); } } return selectedLanguageURI; }  static List<AMLElement> flatten(Iterable<AMLElement> elements); static List<AMLElement> flatten(Iterable<AMLElement> elements, boolean onlyExecutable); static SailfishURI detectLanguage(List<AMLBlock> blocks, Set<SailfishURI> languageURIs, SailfishURI selectedLanguageURI, IActionManager actionManager); static void resolveActionURIs(List<AMLBlock> blocks, IActionManager actionManager, IConnectionManager connectionManager, String environmentName); static Map<String, SortedMap<Long, String>> resolveDefinedServiceNames(List<AMLBlock> blocks, String environmentName, IConnectionManager serviceManager); static int hash(AMLBlock block, AMLMatrixWrapper wrapper, Map<String, String> staticVariables, Map<AMLBlock, Integer> cache, Set<String> references); static int hash(AMLElement element, AMLMatrixWrapper wrapper, Map<String, String> staticVariables,
            Map<AMLBlock, Integer> cache, Set<String> references);  }### Answer:
@Test public void detectLanguageWithUnknownActionTest() { IActionManager actionManager = Mockito.mock(IActionManager.class); AMLBlock block = new AMLBlock().addElement(new AMLElement().setValue(Column.Action, "zzz")); try { AMLBlockUtility.detectLanguage(Collections.singletonList(block), Collections.<SailfishURI>emptySet(), AutoLanguageFactory.URI, actionManager); Assert.fail("No exception was thrown"); } catch(AMLException e) { AlertCollector alertCollector = e.getAlertCollector(); Assert.assertEquals("Failed to detect language", e.getMessage()); Assert.assertEquals(1, alertCollector.getCount(AlertType.ERROR)); Assert.assertEquals(0, alertCollector.getCount(AlertType.WARNING)); Assert.assertEquals(new Alert(0, null, Column.Action.getName(), "Unknown action: zzz"), alertCollector.getAlerts(AlertType.ERROR).iterator().next()); } }