### Question:
DslParser implements ApplicationConfigurationParser { @Override public ApplicationConfiguration parseApplicationConfiguration(File file) throws IOException { Resource resource = resourceSet.getResource(URI.createFileURI(file.getAbsolutePath()), true); List<Issue> issues = validator.validate(resource, CheckMode.ALL, CancelIndicator.NullImpl); if (!issues.isEmpty()) { throw new IllegalStateException("Invalid bromium configuration. Issues: " + issues); } Model model = (Model) resource.getAllContents().next(); return ASTNodeConverter.convert(model); } @Inject  DslParser(ResourceSet resourceSet,
                     IResourceValidator validator,
                     ASTNodeConverter<Model, ApplicationConfiguration> ASTNodeConverter); @Override ApplicationConfiguration parseApplicationConfiguration(File file); @Override ApplicationConfiguration parseApplicationConfiguration(String filename);  }### Answer:
@Test public void ifNoIssuesThenDelegatedToConverter() throws IOException { File file = new File(getClass().getResource("/name.brm").getFile()); initMocks(file); when(resourceValidator.validate(resource, CheckMode.ALL, CancelIndicator.NullImpl)).thenReturn(new ArrayList<>()); ApplicationConfigurationParser parser = new DslParser(resourceSet, resourceValidator, ASTNodeConverter); ApplicationConfiguration actual = parser.parseApplicationConfiguration(file); assertEquals(applicationConfiguration, actual); }
@Test public void ifNoIssuesByFilenameThenDelegatedToConverter() throws IOException { String filename = getClass().getResource("/name.brm").getFile(); initMocks(new File(filename)); when(resourceValidator.validate(resource, CheckMode.ALL, CancelIndicator.NullImpl)).thenReturn(new ArrayList<>()); ApplicationConfigurationParser parser = new DslParser(resourceSet, resourceValidator, ASTNodeConverter); ApplicationConfiguration actual = parser.parseApplicationConfiguration(filename); assertEquals(applicationConfiguration, actual); }
@Test public void parsesActionsWithExposedParameters() throws IOException { File file = new File(getClass().getResource("/actions.brm").getFile()); initMocks(file); List<Issue> issues = Arrays.asList(mock(Issue.class)); when(resourceValidator.validate(resource, CheckMode.ALL, CancelIndicator.NullImpl)).thenReturn(issues); ApplicationConfigurationParser parser = new DslParser(resourceSet, resourceValidator, ASTNodeConverter); expectedException.expect(IllegalStateException.class); parser.parseApplicationConfiguration(file); }