@Test public void testAddChangedResourceOk() throws Exception { ConfigFileResource resource1 = createResource( "myPid" ); Configuration config = createConfiguration( "myPid" ); ConfigFileRepository repo = new ConfigFileRepository(); assertTrue( repo.add( config, resource1 ) ); assertFalse( repo.add( config, resource1 ) ); when( resource1.getLastModified() ).thenReturn( System.currentTimeMillis() + 1 ); assertTrue( repo.add( config, resource1 ) ); assertFalse( repo.add( config, resource1 ) ); }
public boolean add( final Configuration configuration, final ConfigFileResource resource ) { String id = createIdentity( resource ); String pid = configuration.getPid(); if ( isNewOrChanged( resource ) ) { this.mapping.put( pid, new ResourceInfo( id, resource.getLastModified() ) ); return true; } return false; }
ConfigFileRepository { public boolean add( final Configuration configuration, final ConfigFileResource resource ) { String id = createIdentity( resource ); String pid = configuration.getPid(); if ( isNewOrChanged( resource ) ) { this.mapping.put( pid, new ResourceInfo( id, resource.getLastModified() ) ); return true; } return false; } }
ConfigFileRepository { public boolean add( final Configuration configuration, final ConfigFileResource resource ) { String id = createIdentity( resource ); String pid = configuration.getPid(); if ( isNewOrChanged( resource ) ) { this.mapping.put( pid, new ResourceInfo( id, resource.getLastModified() ) ); return true; } return false; } ConfigFileRepository(); }
ConfigFileRepository { public boolean add( final Configuration configuration, final ConfigFileResource resource ) { String id = createIdentity( resource ); String pid = configuration.getPid(); if ( isNewOrChanged( resource ) ) { this.mapping.put( pid, new ResourceInfo( id, resource.getLastModified() ) ); return true; } return false; } ConfigFileRepository(); boolean add( final Configuration configuration, final ConfigFileResource resource ); String getConfigurationPid( final ConfigFileResource resource ); boolean isEmpty(); @SuppressWarnings( "unchecked" ) void load( final File repoFile ); void store( final File repoFile ); }
ConfigFileRepository { public boolean add( final Configuration configuration, final ConfigFileResource resource ) { String id = createIdentity( resource ); String pid = configuration.getPid(); if ( isNewOrChanged( resource ) ) { this.mapping.put( pid, new ResourceInfo( id, resource.getLastModified() ) ); return true; } return false; } ConfigFileRepository(); boolean add( final Configuration configuration, final ConfigFileResource resource ); String getConfigurationPid( final ConfigFileResource resource ); boolean isEmpty(); @SuppressWarnings( "unchecked" ) void load( final File repoFile ); void store( final File repoFile );  }