PartialScanFileAcceptor extends AbstractScanFileAcceptor { @Override public void newMatch(File file) { if(getPropertyScanner().isTemplate(file, getScanConfig().getMasterLocale())) newTemplateMatch(file); else if(getPropertyScanner().isTranslation(file, getScanConfig())) newTranslationMatch(file); } PartialScanFileAcceptor(ProjectVersion projectVersion, PropertyScanner scanner, ScanConfiguration config); @Override void newMatch(File file); ProjectLocale getOrCreateProjectLocale(Locale locale);  }
@SuppressWarnings({ "unchecked", "rawtypes" }) @Test public void testNewMatchExistingTemplate() throws Exception { URI uri = URI.createFileURI("foo/test.properties"); PropertyFileDescriptor descriptor = getFixture().createDescriptor(template, uri); template.getDescriptors().add(descriptor); Resolvable folder = PropertyResourceUtil.getOrCreateFolder(template, "foo"); folder.getChildren().add(descriptor); uri = URI.createFileURI("foo/test_de.properties"); PropertyFileDescriptor translationDescriptor = getFixture().createDescriptor(translation, uri); translation.getDescriptors().add(translationDescriptor); folder = PropertyResourceUtil.getOrCreateFolder(translation, "foo"); folder.getChildren().add(translationDescriptor); translationDescriptor.setMaster(descriptor); getFixture().newMatch(new File("workspace/test/master/foo/test.properties")); assertEquals("Must not be added again",1,template.getChild("foo").getChildren().size()); assertEquals("Must not be added again",1,translation.getChild("foo").getChildren().size()); }
@SuppressWarnings({ "rawtypes", "unchecked" }) @Test public void testNewMatchAdditionalTemplate() throws Exception { URI uri = URI.createURI("foo/test.properties"); PropertyFileDescriptor descriptor = getFixture().createDescriptor(template, uri); template.getDescriptors().add(descriptor); Resolvable folder = PropertyResourceUtil.getOrCreateFolder(template, "foo"); folder.getChildren().add(descriptor); uri = URI.createURI("foo/test_de.properties"); PropertyFileDescriptor translationDescriptor = getFixture().createDescriptor(template, uri); translation.getDescriptors().add(translationDescriptor); folder = PropertyResourceUtil.getOrCreateFolder(translation, "foo"); folder.getChildren().add(translationDescriptor); translationDescriptor.setMaster(descriptor); getFixture().newMatch(new File("workspace/test/master/foo/test2.properties")); assertEquals("Must be added",2,template.getChild("foo").getChildren().size()); assertEquals("Must be added",2,translation.getChild("foo").getChildren().size()); }