DefaultMetadataVersionService implements MetadataVersionService { @Override @Transactional public void createMetadataVersionInDataStore( String versionName, String versionSnapshot ) { if ( StringUtils.isEmpty( versionSnapshot ) ) { throw new MetadataVersionServiceException( "The Metadata Snapshot is null while trying to create a Metadata Version entry in DataStore." ); } KeyJsonValue keyJsonValue = new KeyJsonValue(); keyJsonValue.setKey( versionName ); keyJsonValue.setNamespace( MetadataVersionService.METADATASTORE ); keyJsonValue.setValue( renderService.toJsonAsString( new MetadataWrapper( versionSnapshot ) ) ); try { metaDataKeyJsonService.addMetaDataKeyJsonValue( keyJsonValue ); } catch ( Exception ex ) { String message = "Exception occurred while saving the Metadata snapshot in Data Store" + ex.getMessage(); log.error( message, ex ); throw new MetadataVersionServiceException( message, ex ); } } DefaultMetadataVersionService( MetadataVersionStore metadataVersionStore,
        MetadataExportService metadataExportService, MetadataKeyJsonService metaDataKeyJsonService,
        NodeService nodeService, MetadataSystemSettingService metadataSystemSettingService,
        RenderService renderService ); @Override @Transactional long addVersion( MetadataVersion version ); @Override @Transactional void updateVersion( MetadataVersion version ); @Override @Transactional void updateVersionName( long id, String name ); @Override @Transactional void deleteVersion( MetadataVersion version ); @Override @Transactional( readOnly = true ) MetadataVersion getVersionById( long id ); @Override @Transactional( readOnly = true ) MetadataVersion getVersionByName( String versionName ); @Override @Transactional( readOnly = true ) List<MetadataVersion> getAllVersions(); @Override @Transactional( readOnly = true ) MetadataVersion getCurrentVersion(); @Override @Transactional( readOnly = true ) MetadataVersion getInitialVersion(); @Override @Transactional( readOnly = true ) List<MetadataVersion> getAllVersionsInBetween( Date startDate, Date endDate ); @Override @Transactional( readOnly = true ) Date getCreatedDate( String versionName ); @Override @Transactional synchronized boolean saveVersion( VersionType versionType ); @Override @Transactional( readOnly = true ) String getVersionData( String versionName ); @Override @Transactional void createMetadataVersionInDataStore( String versionName, String versionSnapshot ); @Override @Transactional void deleteMetadataVersionInDataStore( String nameSpaceKey ); @Override boolean isMetadataPassingIntegrity( MetadataVersion version, String versionSnapshot );  }
@Test( expected = MetadataVersionServiceException.class ) public void testShouldThrowMetadataVersionServiceExceptionWhenSnapshotIsEmpty() { versionService.createMetadataVersionInDataStore( "myVersion", "" ); }
@Test( expected = MetadataVersionServiceException.class ) public void testShouldThrowMetadataVersionServiceExceptionWhenSnapshotIsNull() { versionService.createMetadataVersionInDataStore( "myVersion", null ); }