ConfigurableMetadataBasedFileVersioner extends MetadataBasedFileVersioner { @Override public void createDataStoreReferences(Product product, Metadata metadata) throws VersioningException { setFilePathSpec(getFilePathSpec(product.getProductType())); super.createDataStoreReferences(product, metadata); } ConfigurableMetadataBasedFileVersioner();  ConfigurableMetadataBasedFileVersioner(Properties properties); @Override void createDataStoreReferences(Product product, Metadata metadata);  }
@Test public void testVersioningForProductType() throws VersioningException { versioner.createDataStoreReferences(product, metadata); assertThat(product.getProductReferences().size(), is(1)); assertThat(product.getProductReferences().get(0).getDataStoreReference(), is("file:/base/path/2013/03/23/test.dat")); }
@Test public void testVersioningForProductTypeNotDefined() throws VersioningException { ProductType pt = new ProductType(); pt.setProductRepositoryPath("file:/base/path"); pt.setName("TEST_TYPE2"); product.setProductType(pt); expectedException.expect(VersioningException.class); versioner.createDataStoreReferences(product, metadata); }
@Test public void testVersioningForAllProductTypesDoesntOverrideSpecific() throws VersioningException { properties.setProperty("org.apache.oodt.cas.filemgr.versioning.configuration.all_product_types", "/[Year]/[Month]/[Filename]"); versioner.createDataStoreReferences(product, metadata); assertThat(product.getProductReferences().size(), is(1)); assertThat(product.getProductReferences().get(0).getDataStoreReference(), is("file:/base/path/2013/03/23/test.dat")); }
@Test public void testVersioningForAllProductTypes() throws VersioningException { properties.setProperty("org.apache.oodt.cas.filemgr.versioning.configuration.all_product_types", "/[Year]/[Month]/[Filename]"); ProductType pt = new ProductType(); pt.setProductRepositoryPath("file:/base/path"); pt.setName("TEST_TYPE2"); product.setProductType(pt); versioner.createDataStoreReferences(product, metadata); assertThat(product.getProductReferences().size(), is(1)); assertThat(product.getProductReferences().get(0).getDataStoreReference(), is("file:/base/path/2013/03/test.dat")); }