HibernateMetadataVersionStore extends HibernateIdentifiableObjectStore<MetadataVersion> implements MetadataVersionStore { @Override public MetadataVersion getVersionByName( String versionName ) { CriteriaBuilder builder = getCriteriaBuilder(); return getSingleResult( builder, newJpaParameters() .addPredicate( root -> builder.equal( root.get( "name" ), versionName ) ) ); } HibernateMetadataVersionStore( SessionFactory sessionFactory, JdbcTemplate jdbcTemplate,
        ApplicationEventPublisher publisher, CurrentUserService currentUserService, AclService aclService ); @Override MetadataVersion getVersionByKey( long key ); @Override MetadataVersion getVersionByName( String versionName ); @Override MetadataVersion getCurrentVersion(); @Override List<MetadataVersion> getAllVersionsInBetween( Date startDate, Date endDate ); @Override MetadataVersion getInitialVersion();  }
@Test public void testGetVersionByName() throws Exception { MetadataVersion metadataVersion = new MetadataVersion( "version1", VersionType.ATOMIC ); metadataVersion.setHashCode( "12345" ); metadataVersionStore.save( metadataVersion ); assertEquals( metadataVersion, metadataVersionStore.getVersionByName( "version1" ) ); assertNull( metadataVersionStore.getVersionByName( "non_existing" ) ); metadataVersionStore.delete( metadataVersion ); }
@Test public void testUpdate() throws Exception { MetadataVersion metadataVersion = new MetadataVersion( "version1", VersionType.ATOMIC ); metadataVersion.setHashCode( "12345" ); metadataVersionStore.save( metadataVersion ); metadataVersion.setName( "newVersion" ); metadataVersionStore.update( metadataVersion ); assertNotNull( metadataVersionStore.getVersionByName( "newVersion" ) ); metadataVersionStore.delete( metadataVersion ); }
@Test public void testDelete() throws Exception { assertNull( metadataVersionStore.getVersionByName( "version1" ) ); }