import org.apache.archiva.metadata.model.*;
import org.apache.archiva.repository.Repository;
import org.apache.archiva.test.utils.ArchivaSpringJUnit4ClassRunner;
+import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
+import org.springframework.format.annotation.NumberFormat;
import org.springframework.test.context.ContextConfiguration;
import java.text.SimpleDateFormat;
import static org.assertj.core.api.Assertions.assertThat;
-@RunWith(ArchivaSpringJUnit4ClassRunner.class)
-@ContextConfiguration(locations = {"classpath*:/META-INF/spring-context.xml", "classpath*:/spring-context.xml"})
+@RunWith( ArchivaSpringJUnit4ClassRunner.class )
+@ContextConfiguration( locations = {"classpath*:/META-INF/spring-context.xml", "classpath*:/spring-context.xml"} )
public abstract class AbstractMetadataRepositoryTest
- extends TestCase {
+ extends TestCase
+{
protected static final String OTHER_REPO_ID = "other-repo";
- protected MetadataRepository repository;
- protected RepositorySessionFactory sessionFactory;
protected static final String TEST_REPO_ID = "test";
private static final String TEST_PROJECT_VERSION_2_0 = "2.0";
- private static final String TEST_URL = "http://archiva.apache.org";
+ protected static final String TEST_URL = "http://archiva.apache.org";
- private static final Organization TEST_ORGANIZATION = new Organization("Apache", "http://apache.org");
+ private static final Organization TEST_ORGANIZATION = new Organization( "Apache", "http://apache.org" );
private static final String TEST_FACET_ID = "test-facet-id";
private static final String TEST_METADATA_VALUE = "testmetadata";
- protected Logger log = LoggerFactory.getLogger(getClass());
+ protected Logger log = LoggerFactory.getLogger( getClass( ) );
/*
* Used by tryAssert to allow to throw exceptions in the lambda expression.
*/
@FunctionalInterface
- private interface AssertFunction {
- void accept() throws Exception;
+ protected interface AssertFunction
+ {
+ void accept( ) throws Exception;
}
- private void tryAssert(AssertFunction func) throws Exception {
- tryAssert(func, 5, 500);
+ protected void tryAssert( AssertFunction func ) throws Exception
+ {
+ tryAssert( func, 20, 500 );
}
+
+ protected abstract RepositorySessionFactory getSessionFactory( );
+
+ protected abstract MetadataRepository getRepository( );
+
/*
* Runs the assert method until the assert is successful or the number of retries
- * is reached. Needed because the JCR Oak index update is asynchronous, so updates
+ * is reached. This is needed because the JCR Oak index update is asynchronous, so updates
* may not be visible immediately after the modification.
*/
- private void tryAssert(AssertFunction func, int retries, int sleepMillis) throws Exception {
+ private void tryAssert( AssertFunction func, int retries, int sleepMillis ) throws Exception
+ {
Throwable t = null;
int retry = retries;
- while (retry-- > 0) {
- try {
- func.accept();
+ while ( retry-- > 0 )
+ {
+ try
+ {
+ func.accept( );
return;
- } catch (Exception | AssertionError e) {
+ }
+ catch ( Exception | AssertionError e )
+ {
t = e;
- Thread.currentThread().sleep(sleepMillis);
- log.warn("Retrying assert " + retry);
+ Thread.currentThread( ).sleep( sleepMillis );
+ log.warn( "Retrying assert {}: {}", retry, e.getMessage( ) );
}
}
- if (retry <= 0 && t != null) {
- if (t instanceof RuntimeException) {
+ log.warn( "Retries: {}, Exception: {}", retry, t.getMessage( ) );
+ if ( retry <= 0 && t != null )
+ {
+ if ( t instanceof RuntimeException )
+ {
throw (RuntimeException) t;
- } else if (t instanceof Exception) {
+ }
+ else if ( t instanceof Exception )
+ {
throw (Exception) t;
}
+ else if ( t instanceof Error )
+ {
+ throw (Error) t;
+ }
}
}
- public static Map<String, MetadataFacetFactory> createTestMetadataFacetFactories() {
- Map<String, MetadataFacetFactory> factories = new HashMap<>();
- factories.put(TEST_FACET_ID, new MetadataFacetFactory() {
+ public static Map<String, MetadataFacetFactory> createTestMetadataFacetFactories( )
+ {
+ Map<String, MetadataFacetFactory> factories = new HashMap<>( );
+ factories.put( TEST_FACET_ID, new MetadataFacetFactory( )
+ {
@Override
- public MetadataFacet createMetadataFacet() {
- return new TestMetadataFacet(TEST_METADATA_VALUE);
+ public MetadataFacet createMetadataFacet( )
+ {
+ return new TestMetadataFacet( TEST_METADATA_VALUE );
}
@Override
- public MetadataFacet createMetadataFacet(String repositoryId, String name) {
- return new TestMetadataFacet(TEST_METADATA_VALUE);
+ public MetadataFacet createMetadataFacet( String repositoryId, String name )
+ {
+ return new TestMetadataFacet( TEST_METADATA_VALUE );
}
- });
+ } );
// add to ensure we don't accidentally create an empty facet ID.
- factories.put("", new MetadataFacetFactory() {
+ factories.put( "", new MetadataFacetFactory( )
+ {
@Override
- public MetadataFacet createMetadataFacet() {
- return new TestMetadataFacet("", TEST_VALUE);
+ public MetadataFacet createMetadataFacet( )
+ {
+ return new TestMetadataFacet( "", TEST_VALUE );
}
@Override
- public MetadataFacet createMetadataFacet(String repositoryId, String name) {
- return new TestMetadataFacet("", TEST_VALUE);
+ public MetadataFacet createMetadataFacet( String repositoryId, String name )
+ {
+ return new TestMetadataFacet( "", TEST_VALUE );
}
- });
+ } );
// for the getArtifactsByProjectVersionMetadata tests
- factories.put(GenericMetadataFacet.FACET_ID, new GenericMetadataFacetFactory());
+ factories.put( GenericMetadataFacet.FACET_ID, new GenericMetadataFacetFactory( ) );
return factories;
}
@Test
- public void testRootNamespaceWithNoMetadataRepository()
- throws Exception {
- try (RepositorySession session = sessionFactory.createSession()) {
- Collection<String> namespaces = repository.getRootNamespaces(session, TEST_REPO_ID);
- assertThat(namespaces).isNotNull().isEmpty();
+ public void testRootNamespaceWithNoMetadataRepository( )
+ throws Exception
+ {
+ try ( RepositorySession session = getSessionFactory( ).createSession( ) )
+ {
+ tryAssert( ( ) -> {
+ Collection<String> namespaces = getRepository( ).getRootNamespaces( session, TEST_REPO_ID );
+ assertThat( namespaces ).isNotNull( ).isEmpty( );
+ } );
}
}
@Test
- public void testGetNamespaceOnly()
- throws Exception {
- try (RepositorySession session = sessionFactory.createSession()) {
- assertThat(repository.getRootNamespaces(session, TEST_REPO_ID)).isNotNull().isEmpty();
+ public void testGetNamespaceOnly( )
+ throws Exception
+ {
+ try ( RepositorySession session = getSessionFactory( ).createSession( ) )
+ {
+ tryAssert( ( ) -> {
+ assertThat( getRepository( ).getRootNamespaces( session, TEST_REPO_ID ) ).isNotNull( ).isEmpty( );
+ } );
+ getRepository( ).updateNamespace( session, TEST_REPO_ID, TEST_NAMESPACE );
- repository.updateNamespace(session, TEST_REPO_ID, TEST_NAMESPACE);
+ tryAssert( ( ) -> {
+ assertThat( getRepository( ).getRootNamespaces( session, TEST_REPO_ID ) ).isNotNull( ).isNotEmpty( ).contains(
+ TEST_NAMESPACE ).hasSize( 1 );
+ } );
+ getRepository( ).removeNamespace( session, TEST_REPO_ID, TEST_NAMESPACE );
- assertThat(repository.getRootNamespaces(session, TEST_REPO_ID)).isNotNull().isNotEmpty().contains(
- TEST_NAMESPACE).hasSize(1);
-
- repository.removeNamespace(session, TEST_REPO_ID, TEST_NAMESPACE);
-
- assertThat(repository.getRootNamespaces(session, TEST_REPO_ID)).isNotNull().isEmpty();
+ tryAssert( ( ) -> {
+ assertThat( getRepository( ).getRootNamespaces( session, TEST_REPO_ID ) ).isNotNull( ).isEmpty( );
+ } );
}
}
@Test
- public void testGetProjectOnly()
- throws Exception {
- try (RepositorySession session = sessionFactory.createSession()) {
+ public void testGetProjectOnly( )
+ throws Exception
+ {
+ try ( RepositorySession session = getSessionFactory( ).createSession( ) )
+ {
- assertNull(repository.getProject(session, TEST_REPO_ID, TEST_NAMESPACE, TEST_PROJECT));
- assertThat(repository.getRootNamespaces(session, TEST_REPO_ID)).isNotNull().isEmpty();
+ tryAssert( ( ) -> {
+ assertNull( getRepository( ).getProject( session, TEST_REPO_ID, TEST_NAMESPACE, TEST_PROJECT ) );
+ assertThat( getRepository( ).getRootNamespaces( session, TEST_REPO_ID ) ).isNotNull( ).isEmpty( );
+ } );
- ProjectMetadata project = new ProjectMetadata();
- project.setId(TEST_PROJECT);
- project.setNamespace(TEST_NAMESPACE);
+ ProjectMetadata project = new ProjectMetadata( );
+ project.setId( TEST_PROJECT );
+ project.setNamespace( TEST_NAMESPACE );
- repository.updateProject(session, TEST_REPO_ID, project);
+ getRepository( ).updateProject( session, TEST_REPO_ID, project );
- project = repository.getProject(session, TEST_REPO_ID, TEST_NAMESPACE, TEST_PROJECT);
- assertEquals(TEST_PROJECT, project.getId());
- assertEquals(TEST_NAMESPACE, project.getNamespace());
+ tryAssert( ( ) -> {
+ ProjectMetadata proj = getRepository( ).getProject( session, TEST_REPO_ID, TEST_NAMESPACE, TEST_PROJECT );
+ assertEquals( TEST_PROJECT, proj.getId( ) );
+ assertEquals( TEST_NAMESPACE, proj.getNamespace( ) );
+ } );
// test that namespace is also constructed
- Collection<String> namespaces = repository.getRootNamespaces( session, TEST_REPO_ID);
- assertThat(namespaces).isNotNull().isNotEmpty().contains(TEST_NAMESPACE).hasSize(1);
+ tryAssert( ( ) -> {
+ Collection<String> namespaces = getRepository( ).getRootNamespaces( session, TEST_REPO_ID );
+
+ assertThat( namespaces ).isNotNull( ).isNotEmpty( ).contains( TEST_NAMESPACE ).hasSize( 1 );
+ } );
}
}
@Test
- public void testGetProjectVersionOnly()
- throws Exception {
- try (RepositorySession session = sessionFactory.createSession()) {
+ public void testGetProjectVersionOnly( )
+ throws Exception
+ {
+ try ( RepositorySession session = getSessionFactory( ).createSession( ) )
+ {
+
+ tryAssert( ( ) -> {
+ assertNull( getRepository( ).getProjectVersion( session, TEST_REPO_ID, TEST_NAMESPACE, TEST_PROJECT, TEST_PROJECT_VERSION ) );
+ assertNull( getRepository( ).getProject( session, TEST_REPO_ID, TEST_NAMESPACE, TEST_PROJECT ) );
+ assertThat( getRepository( ).getRootNamespaces( session, TEST_REPO_ID ) ).isNotNull( ).isEmpty( );
+ } );
+
+ ProjectVersionMetadata metadata = new ProjectVersionMetadata( );
+ metadata.setId( TEST_PROJECT_VERSION );
- assertNull(repository.getProjectVersion(session, TEST_REPO_ID, TEST_NAMESPACE, TEST_PROJECT, TEST_PROJECT_VERSION));
- assertNull(repository.getProject(session, TEST_REPO_ID, TEST_NAMESPACE, TEST_PROJECT));
- assertThat(repository.getRootNamespaces(session, TEST_REPO_ID)).isNotNull().isEmpty();
+ getRepository( ).updateProjectVersion( session, TEST_REPO_ID, TEST_NAMESPACE, TEST_PROJECT, metadata );
- ProjectVersionMetadata metadata = new ProjectVersionMetadata();
- metadata.setId(TEST_PROJECT_VERSION);
+ metadata = getRepository( ).getProjectVersion( session, TEST_REPO_ID, TEST_NAMESPACE, TEST_PROJECT, TEST_PROJECT_VERSION );
+ assertEquals( TEST_PROJECT_VERSION, metadata.getId( ) );
- repository.updateProjectVersion(session, TEST_REPO_ID, TEST_NAMESPACE, TEST_PROJECT, metadata);
+ tryAssert( ( ) -> {
- metadata = repository.getProjectVersion(session, TEST_REPO_ID, TEST_NAMESPACE, TEST_PROJECT, TEST_PROJECT_VERSION);
- assertEquals(TEST_PROJECT_VERSION, metadata.getId());
+ // test that namespace and project is also constructed
+ Collection<String> namespaces = getRepository( ).getRootNamespaces( session, TEST_REPO_ID );
- // test that namespace and project is also constructed
- Collection<String> namespaces = repository.getRootNamespaces(session, TEST_REPO_ID);
+ assertThat( namespaces ).isNotNull( ).isNotEmpty( ).hasSize( 1 ).contains( TEST_NAMESPACE );
- assertThat(namespaces).isNotNull().isNotEmpty().hasSize(1).contains(TEST_NAMESPACE);
+ } );
- ProjectMetadata projectMetadata = repository.getProject(session, TEST_REPO_ID, TEST_NAMESPACE, TEST_PROJECT);
- assertNotNull(projectMetadata);
- assertEquals(TEST_PROJECT, projectMetadata.getId());
- assertEquals(TEST_NAMESPACE, projectMetadata.getNamespace());
+ tryAssert( ( ) -> {
+
+ ProjectMetadata projectMetadata = getRepository( ).getProject( session, TEST_REPO_ID, TEST_NAMESPACE, TEST_PROJECT );
+ assertNotNull( projectMetadata );
+ assertEquals( TEST_PROJECT, projectMetadata.getId( ) );
+ assertEquals( TEST_NAMESPACE, projectMetadata.getNamespace( ) );
+ } );
}
}
@Test
- public void testGetArtifactOnly()
- throws Exception {
- try (RepositorySession session = sessionFactory.createSession()) {
+ public void testGetArtifactOnly( )
+ throws Exception
+ {
+ try ( RepositorySession session = getSessionFactory( ).createSession( ) )
+ {
- assertThat(new ArrayList<>(
- repository.getArtifacts(session, TEST_REPO_ID, TEST_NAMESPACE,
- TEST_PROJECT, TEST_PROJECT_VERSION))).isNotNull().isEmpty();
- assertThat(
- repository.getProjectVersion(session, TEST_REPO_ID, TEST_NAMESPACE, TEST_PROJECT, TEST_PROJECT_VERSION)).isNull();
- assertThat(repository.getProject(session, TEST_REPO_ID, TEST_NAMESPACE, TEST_PROJECT)).isNull();
+ tryAssert( ( ) -> {
+ assertThat( new ArrayList<>(
+ getRepository( ).getArtifacts( session, TEST_REPO_ID, TEST_NAMESPACE,
+ TEST_PROJECT, TEST_PROJECT_VERSION ) ) ).isNotNull( ).isEmpty( );
+ assertThat(
+ getRepository( ).getProjectVersion( session, TEST_REPO_ID, TEST_NAMESPACE, TEST_PROJECT, TEST_PROJECT_VERSION ) ).isNull( );
+ assertThat( getRepository( ).getProject( session, TEST_REPO_ID, TEST_NAMESPACE, TEST_PROJECT ) ).isNull( );
- assertThat(repository.getRootNamespaces(session, TEST_REPO_ID)).isNotNull().isEmpty();
+ assertThat( getRepository( ).getRootNamespaces( session, TEST_REPO_ID ) ).isNotNull( ).isEmpty( );
- ArtifactMetadata metadata = createArtifact();
+ } );
- repository.updateArtifact(session, TEST_REPO_ID, TEST_NAMESPACE, TEST_PROJECT, TEST_PROJECT_VERSION, metadata);
+ ArtifactMetadata metadata = createArtifact( );
- Collection<ArtifactMetadata> artifacts =
- repository.getArtifacts(session, TEST_REPO_ID, TEST_NAMESPACE, TEST_PROJECT, TEST_PROJECT_VERSION);
- //assertEquals( Collections.singletonList( metadata ), new ArrayList<ArtifactMetadata>( artifacts ) );
- assertThat(artifacts).containsExactly(metadata);
- // test that namespace, project and project version is also constructed
+ getRepository( ).updateArtifact( session, TEST_REPO_ID, TEST_NAMESPACE, TEST_PROJECT, TEST_PROJECT_VERSION, metadata );
+
+ tryAssert( ( ) -> {
+ Collection<ArtifactMetadata> artifacts =
+ getRepository( ).getArtifacts( session, TEST_REPO_ID, TEST_NAMESPACE, TEST_PROJECT, TEST_PROJECT_VERSION );
+ //assertEquals( Collections.singletonList( metadata ), new ArrayList<ArtifactMetadata>( artifacts ) );
+ assertThat( artifacts ).containsExactly( metadata );
+ // test that namespace, project and project version is also constructed
- assertThat(repository.getRootNamespaces(session, TEST_REPO_ID)).isNotNull().isNotEmpty().contains(
- TEST_NAMESPACE).hasSize(1);
+ assertThat( getRepository( ).getRootNamespaces( session, TEST_REPO_ID ) ).isNotNull( ).isNotEmpty( ).contains(
+ TEST_NAMESPACE ).hasSize( 1 );
- ProjectMetadata projectMetadata = repository.getProject(session, TEST_REPO_ID, TEST_NAMESPACE, TEST_PROJECT);
- assertEquals(TEST_PROJECT, projectMetadata.getId());
- assertEquals(TEST_NAMESPACE, projectMetadata.getNamespace());
+ ProjectMetadata projectMetadata = getRepository( ).getProject( session, TEST_REPO_ID, TEST_NAMESPACE, TEST_PROJECT );
+ assertEquals( TEST_PROJECT, projectMetadata.getId( ) );
+ assertEquals( TEST_NAMESPACE, projectMetadata.getNamespace( ) );
- ProjectVersionMetadata projectVersionMetadata =
- repository.getProjectVersion(session, TEST_REPO_ID, TEST_NAMESPACE, TEST_PROJECT, TEST_PROJECT_VERSION);
- assertEquals(TEST_PROJECT_VERSION, projectVersionMetadata.getId());
+ ProjectVersionMetadata projectVersionMetadata =
+ getRepository( ).getProjectVersion( session, TEST_REPO_ID, TEST_NAMESPACE, TEST_PROJECT, TEST_PROJECT_VERSION );
+ assertEquals( TEST_PROJECT_VERSION, projectVersionMetadata.getId( ) );
+ } );
}
}
@Test
- public void testUpdateProjectVersionMetadataWithNoOtherArchives()
- throws Exception {
- try (RepositorySession session = sessionFactory.createSession()) {
+ public void testUpdateProjectVersionMetadataWithNoOtherArchives( )
+ throws Exception
+ {
+ try ( RepositorySession session = getSessionFactory( ).createSession( ) )
+ {
- ProjectVersionMetadata metadata = new ProjectVersionMetadata();
- metadata.setId(TEST_PROJECT_VERSION);
- MailingList mailingList = new MailingList();
- mailingList.setName("Foo List");
- mailingList.setOtherArchives(Collections.<String>emptyList());
- metadata.setMailingLists(Arrays.asList(mailingList));
- repository.updateProjectVersion(session, TEST_REPO_ID, TEST_NAMESPACE, TEST_PROJECT, metadata);
+ ProjectVersionMetadata metadata = new ProjectVersionMetadata( );
+ metadata.setId( TEST_PROJECT_VERSION );
+ MailingList mailingList = new MailingList( );
+ mailingList.setName( "Foo List" );
+ mailingList.setOtherArchives( Collections.<String>emptyList( ) );
+ metadata.setMailingLists( Arrays.asList( mailingList ) );
+ getRepository( ).updateProjectVersion( session, TEST_REPO_ID, TEST_NAMESPACE, TEST_PROJECT, metadata );
- metadata = repository.getProjectVersion(session, TEST_REPO_ID, TEST_NAMESPACE, TEST_PROJECT, TEST_PROJECT_VERSION);
- assertEquals(TEST_PROJECT_VERSION, metadata.getId());
+ metadata = getRepository( ).getProjectVersion( session, TEST_REPO_ID, TEST_NAMESPACE, TEST_PROJECT, TEST_PROJECT_VERSION );
+ assertEquals( TEST_PROJECT_VERSION, metadata.getId( ) );
- List<MailingList> mailingLists = metadata.getMailingLists();
+ List<MailingList> mailingLists = metadata.getMailingLists( );
- assertThat(mailingLists).isNotNull().isNotEmpty().hasSize(1);
+ assertThat( mailingLists ).isNotNull( ).isNotEmpty( ).hasSize( 1 );
- mailingList = metadata.getMailingLists().get(0);
- assertEquals("Foo List", mailingList.getName());
+ mailingList = metadata.getMailingLists( ).get( 0 );
+ assertEquals( "Foo List", mailingList.getName( ) );
- List<String> others = mailingList.getOtherArchives();
- assertThat(others).isNotNull().isEmpty();
+ List<String> others = mailingList.getOtherArchives( );
+ assertThat( others ).isNotNull( ).isEmpty( );
}
}
@Test
- public void testUpdateProjectVersionMetadataWithAllElements()
- throws Exception {
-
- try (RepositorySession session = sessionFactory.createSession()) {
-
- ProjectVersionMetadata metadata = new ProjectVersionMetadata();
- metadata.setId(TEST_PROJECT_VERSION);
+ public void testUpdateProjectVersionMetadataWithAllElements( )
+ throws Exception
+ {
- metadata.setName("project name");
- metadata.setDescription("project description");
- metadata.setUrl("the url");
+ try ( RepositorySession session = getSessionFactory( ).createSession( ) )
+ {
- MailingList mailingList = new MailingList();
- mailingList.setName("Foo List");
- mailingList.setUnsubscribeAddress("UnsubscribeAddress");
- mailingList.setSubscribeAddress("SubscribeAddress");
- mailingList.setPostAddress("PostAddress");
- mailingList.setMainArchiveUrl("MainArchiveUrl");
- mailingList.setOtherArchives(Arrays.asList("other archive"));
- metadata.setMailingLists(Arrays.asList(mailingList));
+ ProjectVersionMetadata metadata = new ProjectVersionMetadata( );
+ metadata.setId( TEST_PROJECT_VERSION );
- Scm scm = new Scm();
- scm.setConnection("connection");
- scm.setDeveloperConnection("dev conn");
- scm.setUrl("url");
- metadata.setScm(scm);
-
- CiManagement ci = new CiManagement();
- ci.setSystem("system");
- ci.setUrl("ci url");
- metadata.setCiManagement(ci);
-
- IssueManagement tracker = new IssueManagement();
- tracker.setSystem("system");
- tracker.setUrl("issue tracker url");
- metadata.setIssueManagement(tracker);
+ metadata.setName( "project name" );
+ metadata.setDescription( "project description" );
+ metadata.setUrl( "the url" );
- metadata.setOrganization(TEST_ORGANIZATION);
+ MailingList mailingList = new MailingList( );
+ mailingList.setName( "Foo List" );
+ mailingList.setUnsubscribeAddress( "UnsubscribeAddress" );
+ mailingList.setSubscribeAddress( "SubscribeAddress" );
+ mailingList.setPostAddress( "PostAddress" );
+ mailingList.setMainArchiveUrl( "MainArchiveUrl" );
+ mailingList.setOtherArchives( Arrays.asList( "other archive" ) );
+ metadata.setMailingLists( Arrays.asList( mailingList ) );
- License l = new License();
- l.setName("license name");
- l.setUrl("license url");
- metadata.addLicense(l);
+ Scm scm = new Scm( );
+ scm.setConnection( "connection" );
+ scm.setDeveloperConnection( "dev conn" );
+ scm.setUrl( "url" );
+ metadata.setScm( scm );
+
+ CiManagement ci = new CiManagement( );
+ ci.setSystem( "system" );
+ ci.setUrl( "ci url" );
+ metadata.setCiManagement( ci );
+
+ IssueManagement tracker = new IssueManagement( );
+ tracker.setSystem( "system" );
+ tracker.setUrl( "issue tracker url" );
+ metadata.setIssueManagement( tracker );
+
+ metadata.setOrganization( TEST_ORGANIZATION );
- Dependency d = new Dependency();
- d.setArtifactId("artifactId");
- d.setClassifier("classifier");
- d.setGroupId("groupId");
- d.setScope("scope");
- d.setSystemPath("system path");
- d.setType("type");
- d.setVersion("version");
- d.setOptional(true);
- metadata.addDependency(d);
+ License l = new License( );
+ l.setName( "license name" );
+ l.setUrl( "license url" );
+ metadata.addLicense( l );
+
+ Dependency d = new Dependency( );
+ d.setArtifactId( "artifactId" );
+ d.setClassifier( "classifier" );
+ d.setGroupId( "groupId" );
+ d.setScope( "scope" );
+ d.setSystemPath( "system path" );
+ d.setType( "type" );
+ d.setVersion( "version" );
+ d.setOptional( true );
+ metadata.addDependency( d );
+
+ getRepository( ).updateProjectVersion( session, TEST_REPO_ID, TEST_NAMESPACE, TEST_PROJECT, metadata );
+
+ metadata = getRepository( ).getProjectVersion( session, TEST_REPO_ID, TEST_NAMESPACE, TEST_PROJECT, TEST_PROJECT_VERSION );
+ assertEquals( TEST_PROJECT_VERSION, metadata.getId( ) );
+ assertEquals( TEST_PROJECT_VERSION, metadata.getVersion( ) );
+ assertEquals( "project name", metadata.getName( ) );
+ assertEquals( "project description", metadata.getDescription( ) );
+ assertEquals( "the url", metadata.getUrl( ) );
+
+ assertEquals( "connection", metadata.getScm( ).getConnection( ) );
+ assertEquals( "dev conn", metadata.getScm( ).getDeveloperConnection( ) );
+ assertEquals( "url", metadata.getScm( ).getUrl( ) );
+
+ assertEquals( "system", metadata.getCiManagement( ).getSystem( ) );
+ assertEquals( "ci url", metadata.getCiManagement( ).getUrl( ) );
+
+ assertEquals( "system", metadata.getIssueManagement( ).getSystem( ) );
+ assertEquals( "issue tracker url", metadata.getIssueManagement( ).getUrl( ) );
+
+ assertEquals( TEST_ORGANIZATION.getName( ), metadata.getOrganization( ).getName( ) );
+ assertEquals( TEST_ORGANIZATION.getUrl( ), metadata.getOrganization( ).getUrl( ) );
+
+ assertEquals( 1, metadata.getMailingLists( ).size( ) );
+ MailingList retrievedMailingList = metadata.getMailingLists( ).get( 0 );
+ assertEquals( mailingList.getName( ), retrievedMailingList.getName( ) );
+ assertEquals( mailingList.getMainArchiveUrl( ), retrievedMailingList.getMainArchiveUrl( ) );
+ assertEquals( mailingList.getPostAddress( ), retrievedMailingList.getPostAddress( ) );
+ assertEquals( mailingList.getSubscribeAddress( ), retrievedMailingList.getSubscribeAddress( ) );
+ assertEquals( mailingList.getUnsubscribeAddress( ), retrievedMailingList.getUnsubscribeAddress( ) );
+ assertThat( retrievedMailingList.getOtherArchives( ) ) //
+ .isNotNull( ) //
+ .isNotEmpty( ) //
+ .hasSize( 1 ) //
+ .contains( "other archive" );
+
+ assertEquals( 1, metadata.getLicenses( ).size( ) );
+ l = metadata.getLicenses( ).get( 0 );
+ assertEquals( "license name", l.getName( ) );
+ assertEquals( "license url", l.getUrl( ) );
+
+ assertEquals( 1, metadata.getDependencies( ).size( ) );
+ d = metadata.getDependencies( ).get( 0 );
+ assertEquals( "artifactId", d.getArtifactId( ) );
+ assertEquals( "classifier", d.getClassifier( ) );
+ assertEquals( "groupId", d.getGroupId( ) );
+ assertEquals( "scope", d.getScope( ) );
+ assertEquals( "system path", d.getSystemPath( ) );
+ assertEquals( "type", d.getType( ) );
+ assertEquals( "version", d.getVersion( ) );
+ assertTrue( d.isOptional( ) );
+ }
+ }
+
+ @Test
+ public void testUpdateProjectVersionMetadataIncomplete( )
+ throws Exception
+ {
+ try ( RepositorySession session = getSessionFactory( ).createSession( ) )
+ {
+
+ ProjectVersionMetadata metadata = new ProjectVersionMetadata( );
+ metadata.setId( TEST_PROJECT_VERSION );
+ metadata.setIncomplete( true );
+ getRepository( ).updateProjectVersion( session, TEST_REPO_ID, TEST_NAMESPACE, TEST_PROJECT, metadata );
- repository.updateProjectVersion(session, TEST_REPO_ID, TEST_NAMESPACE, TEST_PROJECT, metadata);
-
- metadata = repository.getProjectVersion(session, TEST_REPO_ID, TEST_NAMESPACE, TEST_PROJECT, TEST_PROJECT_VERSION);
- assertEquals(TEST_PROJECT_VERSION, metadata.getId());
- assertEquals(TEST_PROJECT_VERSION, metadata.getVersion());
- assertEquals("project name", metadata.getName());
- assertEquals("project description", metadata.getDescription());
- assertEquals("the url", metadata.getUrl());
+ tryAssert( ( ) -> {
+ ProjectVersionMetadata metadata1 = getRepository( ).getProjectVersion( session, TEST_REPO_ID, TEST_NAMESPACE, TEST_PROJECT, TEST_PROJECT_VERSION );
+ assertEquals( true, metadata1.isIncomplete( ) );
+ assertNull( metadata1.getCiManagement( ) );
+ assertNull( metadata1.getScm( ) );
+ assertNull( metadata1.getIssueManagement( ) );
+ assertNull( metadata1.getOrganization( ) );
+ assertEquals( "", metadata1.getDescription( ) );
+ assertEquals( "", metadata1.getName( ) );
+ assertEquals( TEST_PROJECT_VERSION, metadata1.getId( ) );
+ assertEquals( TEST_PROJECT_VERSION, metadata1.getVersion( ) );
+ assertTrue( metadata1.getMailingLists( ).isEmpty( ) );
+ assertTrue( metadata1.getLicenses( ).isEmpty( ) );
+ assertTrue( metadata1.getDependencies( ).isEmpty( ) );
+ } );
+ }
+ }
- assertEquals("connection", metadata.getScm().getConnection());
- assertEquals("dev conn", metadata.getScm().getDeveloperConnection());
- assertEquals("url", metadata.getScm().getUrl());
+ @Test
+ public void testUpdateProjectVersionMetadataWithExistingFacets( )
+ throws Exception
+ {
+ try ( RepositorySession session = getSessionFactory( ).createSession( ) )
+ {
- assertEquals("system", metadata.getCiManagement().getSystem());
- assertEquals("ci url", metadata.getCiManagement().getUrl());
+ ProjectVersionMetadata metadata = new ProjectVersionMetadata( );
+ metadata.setId( TEST_PROJECT_VERSION );
+ MetadataFacet facet = new TestMetadataFacet( "baz" );
+ metadata.addFacet( facet );
+ getRepository( ).updateProjectVersion( session, TEST_REPO_ID, TEST_NAMESPACE, TEST_PROJECT, metadata );
- assertEquals("system", metadata.getIssueManagement().getSystem());
- assertEquals("issue tracker url", metadata.getIssueManagement().getUrl());
+ tryAssert( ( ) -> {
- assertEquals(TEST_ORGANIZATION.getName(), metadata.getOrganization().getName());
- assertEquals(TEST_ORGANIZATION.getUrl(), metadata.getOrganization().getUrl());
+ ProjectVersionMetadata metadata1 = getRepository( ).getProjectVersion( session, TEST_REPO_ID, TEST_NAMESPACE, TEST_PROJECT, TEST_PROJECT_VERSION );
+ assertEquals( Collections.singleton( TEST_FACET_ID ), metadata1.getFacetIds( ) );
+ } );
- assertEquals(1, metadata.getMailingLists().size());
- MailingList retrievedMailingList = metadata.getMailingLists().get(0);
- assertEquals(mailingList.getName(), retrievedMailingList.getName());
- assertEquals(mailingList.getMainArchiveUrl(), retrievedMailingList.getMainArchiveUrl());
- assertEquals(mailingList.getPostAddress(), retrievedMailingList.getPostAddress());
- assertEquals(mailingList.getSubscribeAddress(), retrievedMailingList.getSubscribeAddress());
- assertEquals(mailingList.getUnsubscribeAddress(), retrievedMailingList.getUnsubscribeAddress());
- assertThat(retrievedMailingList.getOtherArchives()) //
- .isNotNull() //
- .isNotEmpty() //
- .hasSize(1) //
- .contains("other archive");
+ metadata = new ProjectVersionMetadata( );
+ metadata.setId( TEST_PROJECT_VERSION );
+ getRepository( ).updateProjectVersion( session, TEST_REPO_ID, TEST_NAMESPACE, TEST_PROJECT, metadata );
- assertEquals(1, metadata.getLicenses().size());
- l = metadata.getLicenses().get(0);
- assertEquals("license name", l.getName());
- assertEquals("license url", l.getUrl());
+ tryAssert( ( ) -> {
- assertEquals(1, metadata.getDependencies().size());
- d = metadata.getDependencies().get(0);
- assertEquals("artifactId", d.getArtifactId());
- assertEquals("classifier", d.getClassifier());
- assertEquals("groupId", d.getGroupId());
- assertEquals("scope", d.getScope());
- assertEquals("system path", d.getSystemPath());
- assertEquals("type", d.getType());
- assertEquals("version", d.getVersion());
- assertTrue(d.isOptional());
+ ProjectVersionMetadata metadata2 = getRepository( ).getProjectVersion( session, TEST_REPO_ID, TEST_NAMESPACE, TEST_PROJECT, TEST_PROJECT_VERSION );
+ assertEquals( Collections.singleton( TEST_FACET_ID ), metadata2.getFacetIds( ) );
+ TestMetadataFacet testFacet = (TestMetadataFacet) metadata2.getFacet( TEST_FACET_ID );
+ assertEquals( "baz", testFacet.getValue( ) );
+ } );
}
}
@Test
- public void testUpdateProjectVersionMetadataIncomplete()
- throws Exception {
- try (RepositorySession session = sessionFactory.createSession()) {
+ public void testUpdateProjectVersionMetadataWithNoExistingFacets( )
+ throws Exception
+ {
+ try ( RepositorySession session = getSessionFactory( ).createSession( ) )
+ {
- ProjectVersionMetadata metadata = new ProjectVersionMetadata();
- metadata.setId(TEST_PROJECT_VERSION);
- metadata.setIncomplete(true);
- repository.updateProjectVersion(session, TEST_REPO_ID, TEST_NAMESPACE, TEST_PROJECT, metadata);
+ ProjectVersionMetadata metadata = new ProjectVersionMetadata( );
+ metadata.setId( TEST_PROJECT_VERSION );
+ getRepository( ).updateProjectVersion( session, TEST_REPO_ID, TEST_NAMESPACE, TEST_PROJECT, metadata );
- metadata = repository.getProjectVersion(session, TEST_REPO_ID, TEST_NAMESPACE, TEST_PROJECT, TEST_PROJECT_VERSION);
- assertEquals(true, metadata.isIncomplete());
- assertNull(metadata.getCiManagement());
- assertNull(metadata.getScm());
- assertNull(metadata.getIssueManagement());
- assertNull(metadata.getOrganization());
- assertNull(metadata.getDescription());
- assertNull(metadata.getName());
- assertEquals(TEST_PROJECT_VERSION, metadata.getId());
- assertEquals(TEST_PROJECT_VERSION, metadata.getVersion());
- assertTrue(metadata.getMailingLists().isEmpty());
- assertTrue(metadata.getLicenses().isEmpty());
- assertTrue(metadata.getDependencies().isEmpty());
- }
- }
-
- @Test
- public void testUpdateProjectVersionMetadataWithExistingFacets()
- throws Exception {
- try (RepositorySession session = sessionFactory.createSession()) {
- ProjectVersionMetadata metadata = new ProjectVersionMetadata();
- metadata.setId(TEST_PROJECT_VERSION);
- MetadataFacet facet = new TestMetadataFacet("baz");
- metadata.addFacet(facet);
- repository.updateProjectVersion(session, TEST_REPO_ID, TEST_NAMESPACE, TEST_PROJECT, metadata);
+ tryAssert( ( ) -> {
+ ProjectVersionMetadata metadata1 = getRepository( ).getProjectVersion( session, TEST_REPO_ID, TEST_NAMESPACE, TEST_PROJECT, TEST_PROJECT_VERSION );
- metadata = repository.getProjectVersion(session, TEST_REPO_ID, TEST_NAMESPACE, TEST_PROJECT, TEST_PROJECT_VERSION);
- assertEquals(Collections.singleton(TEST_FACET_ID), metadata.getFacetIds());
+ assertThat( metadata1.getFacetIds( ) ).isNotNull( ).isEmpty( );
+ } );
- metadata = new ProjectVersionMetadata();
- metadata.setId(TEST_PROJECT_VERSION);
- repository.updateProjectVersion(session, TEST_REPO_ID, TEST_NAMESPACE, TEST_PROJECT, metadata);
+ ProjectVersionMetadata metadata1 = getRepository( ).getProjectVersion( session, TEST_REPO_ID, TEST_NAMESPACE, TEST_PROJECT, TEST_PROJECT_VERSION );
+ metadata = new ProjectVersionMetadata( );
+ metadata.setId( TEST_PROJECT_VERSION );
+ getRepository( ).updateProjectVersion( session, TEST_REPO_ID, TEST_NAMESPACE, TEST_PROJECT, metadata );
- metadata = repository.getProjectVersion(session, TEST_REPO_ID, TEST_NAMESPACE, TEST_PROJECT, TEST_PROJECT_VERSION);
- assertEquals(Collections.singleton(TEST_FACET_ID), metadata.getFacetIds());
- TestMetadataFacet testFacet = (TestMetadataFacet) metadata.getFacet(TEST_FACET_ID);
- assertEquals("baz", testFacet.getValue());
+ tryAssert( ( ) -> {
+ ProjectVersionMetadata metadata2 = getRepository( ).getProjectVersion( session, TEST_REPO_ID, TEST_NAMESPACE, TEST_PROJECT, TEST_PROJECT_VERSION );
+ assertThat( metadata2.getFacetIds( ) ).isNotNull( ).isEmpty( );
+ } );
}
}
@Test
- public void testUpdateProjectVersionMetadataWithNoExistingFacets()
- throws Exception {
- try (RepositorySession session = sessionFactory.createSession()) {
+ public void testUpdateProjectVersionMetadataWithExistingFacetsFacetPropertyWasRemoved( )
+ throws Exception
+ {
+ try ( RepositorySession session = getSessionFactory( ).createSession( ) )
+ {
- ProjectVersionMetadata metadata = new ProjectVersionMetadata();
- metadata.setId(TEST_PROJECT_VERSION);
- repository.updateProjectVersion(session, TEST_REPO_ID, TEST_NAMESPACE, TEST_PROJECT, metadata);
+ ProjectVersionMetadata metadata = new ProjectVersionMetadata( );
+ metadata.setId( TEST_PROJECT_VERSION );
- metadata = repository.getProjectVersion(session, TEST_REPO_ID, TEST_NAMESPACE, TEST_PROJECT, TEST_PROJECT_VERSION);
+ Map<String, String> additionalProps = new HashMap<>( );
+ additionalProps.put( "deleteKey", "deleteValue" );
- assertThat(metadata.getFacetIds()).isNotNull().isEmpty();
+ MetadataFacet facet = new TestMetadataFacet( TEST_FACET_ID, "baz", additionalProps );
+ metadata.addFacet( facet );
+ getRepository( ).updateProjectVersion( session, TEST_REPO_ID, TEST_NAMESPACE, TEST_PROJECT, metadata );
- metadata = new ProjectVersionMetadata();
- metadata.setId(TEST_PROJECT_VERSION);
- repository.updateProjectVersion(session, TEST_REPO_ID, TEST_NAMESPACE, TEST_PROJECT, metadata);
- metadata = repository.getProjectVersion(session, TEST_REPO_ID, TEST_NAMESPACE, TEST_PROJECT, TEST_PROJECT_VERSION);
- assertThat(metadata.getFacetIds()).isNotNull().isEmpty();
- }
- }
-
- @Test
- public void testUpdateProjectVersionMetadataWithExistingFacetsFacetPropertyWasRemoved()
- throws Exception {
- try (RepositorySession session = sessionFactory.createSession()) {
+ tryAssert( ( ) -> {
- ProjectVersionMetadata metadata = new ProjectVersionMetadata();
- metadata.setId(TEST_PROJECT_VERSION);
+ ProjectVersionMetadata metad = getRepository( ).getProjectVersion( session, TEST_REPO_ID, TEST_NAMESPACE, TEST_PROJECT, TEST_PROJECT_VERSION );
- Map<String, String> additionalProps = new HashMap<>();
- additionalProps.put("deleteKey", "deleteValue");
+ assertThat( metad.getFacetIds( ) ).isNotNull( ).isNotEmpty( ).hasSize( 1 ).contains( TEST_FACET_ID );
- MetadataFacet facet = new TestMetadataFacet(TEST_FACET_ID, "baz", additionalProps);
- metadata.addFacet(facet);
- repository.updateProjectVersion(session, TEST_REPO_ID, TEST_NAMESPACE, TEST_PROJECT, metadata);
- metadata = repository.getProjectVersion(session, TEST_REPO_ID, TEST_NAMESPACE, TEST_PROJECT, TEST_PROJECT_VERSION);
+ } );
- assertThat(metadata.getFacetIds()).isNotNull().isNotEmpty().hasSize(1).contains(TEST_FACET_ID);
+ ProjectVersionMetadata metad = getRepository( ).getProjectVersion( session, TEST_REPO_ID, TEST_NAMESPACE, TEST_PROJECT, TEST_PROJECT_VERSION );
+ TestMetadataFacet testFacet = (TestMetadataFacet) metad.getFacet( TEST_FACET_ID );
+ Map<String, String> facetProperties = testFacet.toProperties( );
- TestMetadataFacet testFacet = (TestMetadataFacet) metadata.getFacet(TEST_FACET_ID);
- Map<String, String> facetProperties = testFacet.toProperties();
+ assertEquals( "deleteValue", facetProperties.get( "deleteKey" ) );
- assertEquals("deleteValue", facetProperties.get("deleteKey"));
+ facetProperties.remove( "deleteKey" );
- facetProperties.remove("deleteKey");
+ TestMetadataFacet newTestFacet = new TestMetadataFacet( TEST_FACET_ID, testFacet.getValue( ), facetProperties );
+ metadata.addFacet( newTestFacet );
- TestMetadataFacet newTestFacet = new TestMetadataFacet(TEST_FACET_ID, testFacet.getValue(), facetProperties);
- metadata.addFacet(newTestFacet);
+ getRepository( ).updateProjectVersion( session, TEST_REPO_ID, TEST_NAMESPACE, TEST_PROJECT, metadata );
- repository.updateProjectVersion(session, TEST_REPO_ID, TEST_NAMESPACE, TEST_PROJECT, metadata);
- metadata = repository.getProjectVersion(session, TEST_REPO_ID, TEST_NAMESPACE, TEST_PROJECT, TEST_PROJECT_VERSION);
+ tryAssert( ( ) -> {
+ ProjectVersionMetadata metad2 = getRepository( ).getProjectVersion( session, TEST_REPO_ID, TEST_NAMESPACE, TEST_PROJECT, TEST_PROJECT_VERSION );
- assertThat(metadata.getFacetIds()).isNotNull().isNotEmpty().hasSize(1).contains(TEST_FACET_ID);
- testFacet = (TestMetadataFacet) metadata.getFacet(TEST_FACET_ID);
- assertFalse(testFacet.toProperties().containsKey("deleteKey"));
+ assertThat( metad2.getFacetIds( ) ).isNotNull( ).isNotEmpty( ).hasSize( 1 ).contains( TEST_FACET_ID );
+ TestMetadataFacet testFacet2 = (TestMetadataFacet) metad2.getFacet( TEST_FACET_ID );
+ assertFalse( testFacet2.toProperties( ).containsKey( "deleteKey" ) );
+ } );
}
}
@Test
- public void testGetArtifactsDoesntReturnProjectVersionMetadataFacets()
- throws Exception {
- try (RepositorySession session = sessionFactory.createSession()) {
+ public void testGetArtifactsDoesntReturnProjectVersionMetadataFacets( )
+ throws Exception
+ {
+ try ( RepositorySession session = getSessionFactory( ).createSession( ) )
+ {
- ProjectVersionMetadata versionMetadata = new ProjectVersionMetadata();
- versionMetadata.setId(TEST_PROJECT_VERSION);
+ ProjectVersionMetadata versionMetadata = new ProjectVersionMetadata( );
+ versionMetadata.setId( TEST_PROJECT_VERSION );
- MetadataFacet facet = new TestMetadataFacet(TEST_FACET_ID, "baz");
- versionMetadata.addFacet(facet);
- repository.updateProjectVersion(session, TEST_REPO_ID, TEST_NAMESPACE, TEST_PROJECT, versionMetadata);
+ MetadataFacet facet = new TestMetadataFacet( TEST_FACET_ID, "baz" );
+ versionMetadata.addFacet( facet );
+ getRepository( ).updateProjectVersion( session, TEST_REPO_ID, TEST_NAMESPACE, TEST_PROJECT, versionMetadata );
+ ArtifactMetadata artifactMetadata = createArtifact( );
+ getRepository( ).updateArtifact( session, TEST_REPO_ID, TEST_NAMESPACE, TEST_PROJECT, TEST_PROJECT_VERSION, artifactMetadata );
+ session.save( );
- ArtifactMetadata artifactMetadata = createArtifact();
- repository.updateArtifact(session, TEST_REPO_ID, TEST_NAMESPACE, TEST_PROJECT, TEST_PROJECT_VERSION, artifactMetadata);
- session.save();
+ tryAssert( ( ) -> {
- Collection<ArtifactMetadata> artifacts =
- repository.getArtifacts(session, TEST_REPO_ID, TEST_NAMESPACE, TEST_PROJECT, TEST_PROJECT_VERSION);
- assertEquals(Collections.singletonList(artifactMetadata), new ArrayList<>(artifacts));
- artifacts = repository.getArtifacts(session, TEST_REPO_ID);
- assertEquals(Collections.singletonList(artifactMetadata), new ArrayList<>(artifacts));
+ Collection<ArtifactMetadata> artifacts =
+ getRepository( ).getArtifacts( session, TEST_REPO_ID, TEST_NAMESPACE, TEST_PROJECT, TEST_PROJECT_VERSION );
+ assertEquals( Collections.singletonList( artifactMetadata ), new ArrayList<>( artifacts ) );
+
+ artifacts = getRepository( ).getArtifacts( session, TEST_REPO_ID );
+ assertEquals( Collections.singletonList( artifactMetadata ), new ArrayList<>( artifacts ) );
- artifacts = repository.getArtifactsByChecksum(session, TEST_REPO_ID, TEST_SHA1);
- assertEquals(Collections.singletonList(artifactMetadata), new ArrayList<>(artifacts));
+ artifacts = getRepository( ).getArtifactsByChecksum( session, TEST_REPO_ID, TEST_SHA1 );
+ assertEquals( Collections.singletonList( artifactMetadata ), new ArrayList<>( artifacts ) );
- artifacts = repository.getArtifactsByChecksum(session, TEST_REPO_ID, TEST_MD5);
- assertEquals(Collections.singletonList(artifactMetadata), new ArrayList<>(artifacts));
+ artifacts = getRepository( ).getArtifactsByChecksum( session, TEST_REPO_ID, TEST_MD5 );
+ assertEquals( Collections.singletonList( artifactMetadata ), new ArrayList<>( artifacts ) );
- artifacts = repository.getArtifactsByDateRange(session, TEST_REPO_ID, null, null);
- assertEquals(Collections.singletonList(artifactMetadata), new ArrayList<>(artifacts));
+ artifacts = getRepository( ).getArtifactsByDateRange( session, TEST_REPO_ID, null, null );
+ assertEquals( Collections.singletonList( artifactMetadata ), new ArrayList<>( artifacts ) );
+ } );
}
}
@Test
- public void testUpdateArtifactMetadataWithExistingFacetsFacetPropertyWasRemoved()
- throws Exception {
- try (RepositorySession session = sessionFactory.createSession()) {
+ public void testUpdateArtifactMetadataWithExistingFacetsFacetPropertyWasRemoved( )
+ throws Exception
+ {
+ try ( RepositorySession session = getSessionFactory( ).createSession( ) )
+ {
- ArtifactMetadata metadata = createArtifact();
+ ArtifactMetadata metadata = createArtifact( );
- Map<String, String> additionalProps = new HashMap<>();
- additionalProps.put("deleteKey", "deleteValue");
+ Map<String, String> additionalProps = new HashMap<>( );
+ additionalProps.put( "deleteKey", "deleteValue" );
- MetadataFacet facet = new TestMetadataFacet(TEST_FACET_ID, "baz", additionalProps);
- metadata.addFacet(facet);
- repository.updateArtifact(session, TEST_REPO_ID, TEST_NAMESPACE, TEST_PROJECT, TEST_PROJECT_VERSION, metadata);
+ MetadataFacet facet = new TestMetadataFacet( TEST_FACET_ID, "baz", additionalProps );
+ metadata.addFacet( facet );
+ getRepository( ).updateArtifact( session, TEST_REPO_ID, TEST_NAMESPACE, TEST_PROJECT, TEST_PROJECT_VERSION, metadata );
- Collection<ArtifactMetadata> artifacts =
- repository.getArtifacts(session, TEST_REPO_ID, TEST_NAMESPACE, TEST_PROJECT, TEST_PROJECT_VERSION);
+ tryAssert( ( ) -> {
+ Collection<ArtifactMetadata> artifacts =
+ getRepository( ).getArtifacts( session, TEST_REPO_ID, TEST_NAMESPACE, TEST_PROJECT, TEST_PROJECT_VERSION );
+
+ assertThat( artifacts ).isNotNull( ).isNotEmpty( ).hasSize( 1 );
+ } );
- assertThat(artifacts).isNotNull().isNotEmpty().hasSize(1);
- metadata = artifacts.iterator().next();
+ Collection<ArtifactMetadata> artifacts =
+ getRepository( ).getArtifacts( session, TEST_REPO_ID, TEST_NAMESPACE, TEST_PROJECT, TEST_PROJECT_VERSION );
+ metadata = artifacts.iterator( ).next( );
- Collection<String> ids = metadata.getFacetIds();
- assertThat(ids).isNotNull().isNotEmpty().hasSize(1).contains(TEST_FACET_ID);
+ Collection<String> ids = metadata.getFacetIds( );
+ assertThat( ids ).isNotNull( ).isNotEmpty( ).hasSize( 1 ).contains( TEST_FACET_ID );
- TestMetadataFacet testFacet = (TestMetadataFacet) metadata.getFacet(TEST_FACET_ID);
- Map<String, String> facetProperties = testFacet.toProperties();
+ TestMetadataFacet testFacet = (TestMetadataFacet) metadata.getFacet( TEST_FACET_ID );
+ Map<String, String> facetProperties = testFacet.toProperties( );
- assertEquals("deleteValue", facetProperties.get("deleteKey"));
+ assertEquals( "deleteValue", facetProperties.get( "deleteKey" ) );
- facetProperties.remove("deleteKey");
+ facetProperties.remove( "deleteKey" );
- TestMetadataFacet newTestFacet = new TestMetadataFacet(TEST_FACET_ID, testFacet.getValue(), facetProperties);
- metadata.addFacet(newTestFacet);
+ TestMetadataFacet newTestFacet = new TestMetadataFacet( TEST_FACET_ID, testFacet.getValue( ), facetProperties );
+ metadata.addFacet( newTestFacet );
- repository.updateArtifact(session, TEST_REPO_ID, TEST_NAMESPACE, TEST_PROJECT, TEST_PROJECT_VERSION, metadata);
+ getRepository( ).updateArtifact( session, TEST_REPO_ID, TEST_NAMESPACE, TEST_PROJECT, TEST_PROJECT_VERSION, metadata );
+ session.save( );
- artifacts = repository.getArtifacts(session, TEST_REPO_ID, TEST_NAMESPACE, TEST_PROJECT, TEST_PROJECT_VERSION);
+ tryAssert( ( ) -> {
+ Collection<ArtifactMetadata> artifacts1 = getRepository( ).getArtifacts( session, TEST_REPO_ID, TEST_NAMESPACE, TEST_PROJECT, TEST_PROJECT_VERSION );
- assertThat(artifacts).isNotNull().isNotEmpty().hasSize(1);
- metadata = artifacts.iterator().next();
+ assertThat( artifacts1 ).isNotNull( ).isNotEmpty( ).hasSize( 1 );
+ } );
+ Collection<ArtifactMetadata> artifacts1 = getRepository( ).getArtifacts( session, TEST_REPO_ID, TEST_NAMESPACE, TEST_PROJECT, TEST_PROJECT_VERSION );
+ metadata = artifacts.iterator( ).next( );
- ids = metadata.getFacetIds();
- assertThat(ids).isNotNull().isNotEmpty().hasSize(1).contains(TEST_FACET_ID);
+ ids = metadata.getFacetIds( );
+ assertThat( ids ).isNotNull( ).isNotEmpty( ).hasSize( 1 ).contains( TEST_FACET_ID );
- testFacet = (TestMetadataFacet) metadata.getFacet(TEST_FACET_ID);
+ testFacet = (TestMetadataFacet) metadata.getFacet( TEST_FACET_ID );
- Map<String, String> props = testFacet.toProperties();
- assertThat(props).isNotNull().doesNotContainKey("deleteKey");
+ Map<String, String> props = testFacet.toProperties( );
+ assertThat( props ).isNotNull( ).doesNotContainKey( "deleteKey" );
}
}
@Test
- public void testUpdateArtifactMetadataWithExistingFacets()
- throws Exception {
- try (RepositorySession session = sessionFactory.createSession()) {
+ public void testUpdateArtifactMetadataWithExistingFacets( )
+ throws Exception
+ {
+ try ( RepositorySession session = getSessionFactory( ).createSession( ) )
+ {
- ArtifactMetadata metadata = createArtifact();
- MetadataFacet facet = new TestMetadataFacet("baz");
- metadata.addFacet(facet);
- repository.updateArtifact(session, TEST_REPO_ID, TEST_NAMESPACE, TEST_PROJECT, TEST_PROJECT_VERSION, metadata);
+ ArtifactMetadata metadata = createArtifact( );
+ MetadataFacet facet = new TestMetadataFacet( "baz" );
+ metadata.addFacet( facet );
+ getRepository( ).updateArtifact( session, TEST_REPO_ID, TEST_NAMESPACE, TEST_PROJECT, TEST_PROJECT_VERSION, metadata );
- metadata = repository.getArtifacts(session, TEST_REPO_ID, TEST_NAMESPACE,
- TEST_PROJECT, TEST_PROJECT_VERSION).iterator().next();
- assertEquals(Collections.singleton(TEST_FACET_ID), metadata.getFacetIds());
+ metadata = getRepository( ).getArtifacts( session, TEST_REPO_ID, TEST_NAMESPACE,
+ TEST_PROJECT, TEST_PROJECT_VERSION ).iterator( ).next( );
+ assertEquals( Collections.singleton( TEST_FACET_ID ), metadata.getFacetIds( ) );
- metadata = createArtifact();
- repository.updateArtifact(session, TEST_REPO_ID, TEST_NAMESPACE, TEST_PROJECT, TEST_PROJECT_VERSION, metadata);
+ metadata = createArtifact( );
+ getRepository( ).updateArtifact( session, TEST_REPO_ID, TEST_NAMESPACE, TEST_PROJECT, TEST_PROJECT_VERSION, metadata );
- metadata = repository.getArtifacts(session, TEST_REPO_ID, TEST_NAMESPACE,
- TEST_PROJECT, TEST_PROJECT_VERSION).iterator().next();
- assertEquals(Collections.singleton(TEST_FACET_ID), metadata.getFacetIds());
- TestMetadataFacet testFacet = (TestMetadataFacet) metadata.getFacet(TEST_FACET_ID);
- assertEquals("baz", testFacet.getValue());
+ metadata = getRepository( ).getArtifacts( session, TEST_REPO_ID, TEST_NAMESPACE,
+ TEST_PROJECT, TEST_PROJECT_VERSION ).iterator( ).next( );
+ assertEquals( Collections.singleton( TEST_FACET_ID ), metadata.getFacetIds( ) );
+ TestMetadataFacet testFacet = (TestMetadataFacet) metadata.getFacet( TEST_FACET_ID );
+ assertEquals( "baz", testFacet.getValue( ) );
}
}
@Test
- public void testUpdateArtifactMetadataWithNoExistingFacets()
- throws Exception {
- try (RepositorySession session = sessionFactory.createSession()) {
- ArtifactMetadata metadata = createArtifact();
- repository.updateArtifact( session, TEST_REPO_ID, TEST_NAMESPACE, TEST_PROJECT, TEST_PROJECT_VERSION, metadata);
+ public void testUpdateArtifactMetadataWithNoExistingFacets( )
+ throws Exception
+ {
+ try ( RepositorySession session = getSessionFactory( ).createSession( ) )
+ {
+ ArtifactMetadata metadata = createArtifact( );
+ getRepository( ).updateArtifact( session, TEST_REPO_ID, TEST_NAMESPACE, TEST_PROJECT, TEST_PROJECT_VERSION, metadata );
+
+ tryAssert( ( ) -> {
+
+ ArtifactMetadata metadata2 = getRepository( ).getArtifacts( session, TEST_REPO_ID, TEST_NAMESPACE,
+ TEST_PROJECT, TEST_PROJECT_VERSION ).iterator( ).next( );
+ assertEquals( Collections.<String>emptyList( ), new ArrayList<String>( metadata2.getFacetIds( ) ) );
- metadata = repository.getArtifacts( session, TEST_REPO_ID, TEST_NAMESPACE,
- TEST_PROJECT, TEST_PROJECT_VERSION).iterator().next();
- assertEquals(Collections.<String>emptyList(), new ArrayList<String>(metadata.getFacetIds()));
+ } );
- metadata = createArtifact();
- repository.updateArtifact( session, TEST_REPO_ID, TEST_NAMESPACE, TEST_PROJECT, TEST_PROJECT_VERSION, metadata);
+ metadata = getRepository( ).getArtifacts( session, TEST_REPO_ID, TEST_NAMESPACE,
+ TEST_PROJECT, TEST_PROJECT_VERSION ).iterator( ).next( );
+ metadata = createArtifact( );
+ getRepository( ).updateArtifact( session, TEST_REPO_ID, TEST_NAMESPACE, TEST_PROJECT, TEST_PROJECT_VERSION, metadata );
- metadata = repository.getArtifacts( session, TEST_REPO_ID, TEST_NAMESPACE,
- TEST_PROJECT, TEST_PROJECT_VERSION).iterator().next();
- assertEquals(Collections.<String>emptyList(), new ArrayList<String>(metadata.getFacetIds()));
+ tryAssert( ( ) -> {
+ ArtifactMetadata metadata3 = getRepository( ).getArtifacts( session, TEST_REPO_ID, TEST_NAMESPACE,
+ TEST_PROJECT, TEST_PROJECT_VERSION ).iterator( ).next( );
+ assertEquals( Collections.<String>emptyList( ), new ArrayList<String>( metadata3.getFacetIds( ) ) );
+ } );
}
}
@Test
- public void testGetMetadataFacet()
- throws Exception {
- try (RepositorySession session = sessionFactory.createSession()) {
- repository.addMetadataFacet( session, TEST_REPO_ID, new TestMetadataFacet(TEST_VALUE));
+ public void testGetMetadataFacet( )
+ throws Exception
+ {
+ try ( RepositorySession session = getSessionFactory( ).createSession( ) )
+ {
+ getRepository( ).addMetadataFacet( session, TEST_REPO_ID, new TestMetadataFacet( TEST_VALUE ) );
TestMetadataFacet test =
- (TestMetadataFacet) repository.getMetadataFacet( session, TEST_REPO_ID, TEST_FACET_ID, TEST_NAME);
+ (TestMetadataFacet) getRepository( ).getMetadataFacet( session, TEST_REPO_ID, TEST_FACET_ID, TEST_NAME );
- assertEquals(new TestMetadataFacet(TEST_VALUE), test);
+ assertEquals( new TestMetadataFacet( TEST_VALUE ), test );
}
}
@Test
- public void testGetMetadataFacetWhenEmpty()
- throws Exception {
- try (RepositorySession session = sessionFactory.createSession()) {
- assertNull(repository.getMetadataFacet( session, TEST_REPO_ID, TEST_FACET_ID, TEST_NAME));
-
+ public void testGetMetadataFacetWhenEmpty( )
+ throws Exception
+ {
+ try ( RepositorySession session = getSessionFactory( ).createSession( ) )
+ {
+ tryAssert( ( ) -> assertNull( getRepository( ).getMetadataFacet( session, TEST_REPO_ID, TEST_FACET_ID, TEST_NAME ) ) );
}
}
@Test
- public void testGetMetadataFacetWhenUnknownName()
- throws Exception {
- try (RepositorySession session = sessionFactory.createSession()) {
- repository.addMetadataFacet( session, TEST_REPO_ID, new TestMetadataFacet(TEST_VALUE));
-
- assertNull(repository.getMetadataFacet( session, TEST_REPO_ID, TEST_FACET_ID, UNKNOWN));
+ public void testGetMetadataFacetWhenUnknownName( )
+ throws Exception
+ {
+ try ( RepositorySession session = getSessionFactory( ).createSession( ) )
+ {
+ getRepository( ).addMetadataFacet( session, TEST_REPO_ID, new TestMetadataFacet( TEST_VALUE ) );
+ tryAssert( ( ) -> assertNull( getRepository( ).getMetadataFacet( session, TEST_REPO_ID, TEST_FACET_ID, UNKNOWN ) ) );
}
}
@Test
- public void testGetMetadataFacetWhenDefaultValue()
- throws Exception {
- try (RepositorySession session = sessionFactory.createSession()) {
- repository.addMetadataFacet( session, TEST_REPO_ID, new TestMetadataFacet(null));
+ public void testGetMetadataFacetWhenDefaultValue( )
+ throws Exception
+ {
+ try ( RepositorySession session = getSessionFactory( ).createSession( ) )
+ {
+ getRepository( ).addMetadataFacet( session, TEST_REPO_ID, new TestMetadataFacet( null ) );
- MetadataFacet metadataFacet = repository.getMetadataFacet( session, TEST_REPO_ID, TEST_FACET_ID, TEST_NAME);
+ tryAssert( ( ) -> {
+ MetadataFacet metadataFacet = getRepository( ).getMetadataFacet( session, TEST_REPO_ID, TEST_FACET_ID, TEST_NAME );
- assertEquals(new TestMetadataFacet(TEST_METADATA_VALUE), metadataFacet);
+ assertEquals( new TestMetadataFacet( TEST_METADATA_VALUE ), metadataFacet );
+ } );
}
}
@Test
- public void testGetMetadataFacetWhenUnknownFacetId()
- throws Exception {
- try (RepositorySession session = sessionFactory.createSession()) {
- assertNull(repository.getMetadataFacet( session, TEST_REPO_ID, UNKNOWN, TEST_NAME));
+ public void testGetMetadataFacetWhenUnknownFacetId( )
+ throws Exception
+ {
+ try ( RepositorySession session = getSessionFactory( ).createSession( ) )
+ {
+ assertNull( getRepository( ).getMetadataFacet( session, TEST_REPO_ID, UNKNOWN, TEST_NAME ) );
}
}
@Test
- public void testGetMetadataFacets()
- throws Exception {
- try (RepositorySession session = sessionFactory.createSession()) {
- repository.addMetadataFacet( session, TEST_REPO_ID, new TestMetadataFacet(TEST_VALUE));
+ public void testGetMetadataFacets( )
+ throws Exception
+ {
+ try ( RepositorySession session = getSessionFactory( ).createSession( ) )
+ {
+ getRepository( ).addMetadataFacet( session, TEST_REPO_ID, new TestMetadataFacet( TEST_VALUE ) );
- assertEquals(Collections.singletonList(TEST_NAME),
- repository.getMetadataFacets( session, TEST_REPO_ID, TEST_FACET_ID));
+ assertEquals( Collections.singletonList( TEST_NAME ),
+ getRepository( ).getMetadataFacets( session, TEST_REPO_ID, TEST_FACET_ID ) );
}
}
@Test
- public void testGetMetadataFacetsWhenEmpty()
- throws Exception {
+ public void testGetMetadataFacetsWhenEmpty( )
+ throws Exception
+ {
- try (RepositorySession session = sessionFactory.createSession()) {
- List<String> facets = repository.getMetadataFacets( session, TEST_REPO_ID, TEST_FACET_ID);
- assertTrue(facets.isEmpty());
+ try ( RepositorySession session = getSessionFactory( ).createSession( ) )
+ {
+ tryAssert( ( ) -> {
+ List<String> facets = getRepository( ).getMetadataFacets( session, TEST_REPO_ID, TEST_FACET_ID );
+ assertTrue( facets.isEmpty( ) );
+ } );
}
}
@Test
- public void testRemoveFacets()
- throws Exception {
- try (RepositorySession session = sessionFactory.createSession()) {
- repository.addMetadataFacet( session, TEST_REPO_ID, new TestMetadataFacet(TEST_VALUE));
+ public void testRemoveFacets( )
+ throws Exception
+ {
+ try ( RepositorySession session = getSessionFactory( ).createSession( ) )
+ {
+ getRepository( ).addMetadataFacet( session, TEST_REPO_ID, new TestMetadataFacet( TEST_VALUE ) );
- List<String> facets = repository.getMetadataFacets( session, TEST_REPO_ID, TEST_FACET_ID);
- assertFalse(facets.isEmpty());
+ List<String> facets = getRepository( ).getMetadataFacets( session, TEST_REPO_ID, TEST_FACET_ID );
+ assertFalse( facets.isEmpty( ) );
- repository.removeMetadataFacets( session, TEST_REPO_ID, TEST_FACET_ID);
+ getRepository( ).removeMetadataFacets( session, TEST_REPO_ID, TEST_FACET_ID );
- facets = repository.getMetadataFacets( session, TEST_REPO_ID, TEST_FACET_ID);
- assertTrue(facets.isEmpty());
+ facets = getRepository( ).getMetadataFacets( session, TEST_REPO_ID, TEST_FACET_ID );
+ assertTrue( facets.isEmpty( ) );
}
}
@Test
- public void testRemoveFacetsWhenEmpty()
- throws Exception {
- try (RepositorySession session = sessionFactory.createSession()) {
- List<String> facets = repository.getMetadataFacets( session, TEST_REPO_ID, TEST_FACET_ID);
- assertTrue(facets.isEmpty());
-
- repository.removeMetadataFacets( session, TEST_REPO_ID, TEST_FACET_ID);
+ public void testRemoveFacetsWhenEmpty( )
+ throws Exception
+ {
+ try ( RepositorySession session = getSessionFactory( ).createSession( ) )
+ {
+ List<String> facets = getRepository( ).getMetadataFacets( session, TEST_REPO_ID, TEST_FACET_ID );
+ assertTrue( facets.isEmpty( ) );
- facets = repository.getMetadataFacets( session, TEST_REPO_ID, TEST_FACET_ID);
- assertTrue(facets.isEmpty());
+ getRepository( ).removeMetadataFacets( session, TEST_REPO_ID, TEST_FACET_ID );
+ tryAssert( ( ) -> {
+ List<String> facets1 = getRepository( ).getMetadataFacets( session, TEST_REPO_ID, TEST_FACET_ID );
+ assertTrue( facets1.isEmpty( ) );
+ } );
}
}
@Test
- public void testRemoveFacetsWhenUnknown()
- throws Exception {
- try (RepositorySession session = sessionFactory.createSession()) {
+ public void testRemoveFacetsWhenUnknown( )
+ throws Exception
+ {
+ try ( RepositorySession session = getSessionFactory( ).createSession( ) )
+ {
// testing no exception
- repository.removeMetadataFacets( session, TEST_REPO_ID, UNKNOWN);
+ getRepository( ).removeMetadataFacets( session, TEST_REPO_ID, UNKNOWN );
}
}
@Test
- public void testRemoveFacetWhenUnknown()
- throws Exception {
- try (RepositorySession session = sessionFactory.createSession()) {
+ public void testRemoveFacetWhenUnknown( )
+ throws Exception
+ {
+ try ( RepositorySession session = getSessionFactory( ).createSession( ) )
+ {
// testing no exception
- repository.removeMetadataFacet( session, TEST_REPO_ID, UNKNOWN, TEST_NAME);
+ getRepository( ).removeMetadataFacet( session, TEST_REPO_ID, UNKNOWN, TEST_NAME );
}
}
@Test
- public void testRemoveFacet()
- throws Exception {
- try (RepositorySession session = sessionFactory.createSession()) {
- TestMetadataFacet metadataFacet = new TestMetadataFacet(TEST_VALUE);
- repository.addMetadataFacet( session, TEST_REPO_ID, metadataFacet);
+ public void testRemoveFacet( )
+ throws Exception
+ {
+ try ( RepositorySession session = getSessionFactory( ).createSession( ) )
+ {
+ TestMetadataFacet metadataFacet = new TestMetadataFacet( TEST_VALUE );
+ getRepository( ).addMetadataFacet( session, TEST_REPO_ID, metadataFacet );
- assertEquals(metadataFacet, repository.getMetadataFacet( session, TEST_REPO_ID, TEST_FACET_ID, TEST_NAME));
- List<String> facets = repository.getMetadataFacets( session, TEST_REPO_ID, TEST_FACET_ID);
- assertFalse(facets.isEmpty());
+ assertEquals( metadataFacet, getRepository( ).getMetadataFacet( session, TEST_REPO_ID, TEST_FACET_ID, TEST_NAME ) );
+ List<String> facets = getRepository( ).getMetadataFacets( session, TEST_REPO_ID, TEST_FACET_ID );
+ assertFalse( facets.isEmpty( ) );
- repository.removeMetadataFacet( session, TEST_REPO_ID, TEST_FACET_ID, TEST_NAME);
+ getRepository( ).removeMetadataFacet( session, TEST_REPO_ID, TEST_FACET_ID, TEST_NAME );
- assertNull(repository.getMetadataFacet( session, TEST_REPO_ID, TEST_FACET_ID, TEST_NAME));
- facets = repository.getMetadataFacets( session, TEST_REPO_ID, TEST_FACET_ID);
- assertTrue(facets.isEmpty());
+ assertNull( getRepository( ).getMetadataFacet( session, TEST_REPO_ID, TEST_FACET_ID, TEST_NAME ) );
+ facets = getRepository( ).getMetadataFacets( session, TEST_REPO_ID, TEST_FACET_ID );
+ assertTrue( facets.isEmpty( ) );
}
}
@Test
- public void testRemoveFacetWhenEmpty()
- throws Exception {
- try (RepositorySession session = sessionFactory.createSession()) {
- List<String> facets = repository.getMetadataFacets( session, TEST_REPO_ID, TEST_FACET_ID);
- assertThat(facets).isNotNull().isEmpty();
- assertThat(repository.getMetadataFacet( session, TEST_REPO_ID, TEST_FACET_ID, TEST_NAME)).isNull();
+ public void testRemoveFacetWhenEmpty( )
+ throws Exception
+ {
+ try ( RepositorySession session = getSessionFactory( ).createSession( ) )
+ {
+ tryAssert( ( ) -> {
+
+ List<String> facets = getRepository( ).getMetadataFacets( session, TEST_REPO_ID, TEST_FACET_ID );
+ assertThat( facets ).isNotNull( ).isEmpty( );
+ assertThat( getRepository( ).getMetadataFacet( session, TEST_REPO_ID, TEST_FACET_ID, TEST_NAME ) ).isNull( );
+
+ } );
+ getRepository( ).removeMetadataFacet( session, TEST_REPO_ID, TEST_FACET_ID, TEST_NAME );
- repository.removeMetadataFacet( session, TEST_REPO_ID, TEST_FACET_ID, TEST_NAME);
+ tryAssert( ( ) -> {
- facets = repository.getMetadataFacets( session, TEST_REPO_ID, TEST_FACET_ID);
- assertThat(facets).isNotNull().isEmpty();
- assertThat(repository.getMetadataFacet( session, TEST_REPO_ID, TEST_FACET_ID, TEST_NAME)).isNull();
+ List<String> facets2 = getRepository( ).getMetadataFacets( session, TEST_REPO_ID, TEST_FACET_ID );
+ assertThat( facets2 ).isNotNull( ).isEmpty( );
+ assertThat( getRepository( ).getMetadataFacet( session, TEST_REPO_ID, TEST_FACET_ID, TEST_NAME ) ).isNull( );
+ } );
}
}
@Test
- public void hasMetadataFacetStart()
- throws Exception {
- try (RepositorySession session = sessionFactory.createSession()) {
- assertFalse(repository.hasMetadataFacet( session, TEST_REPO_ID, KindOfRepositoryStatistics.class.getName()));
+ public void hasMetadataFacetStart( )
+ throws Exception
+ {
+ try ( RepositorySession session = getSessionFactory( ).createSession( ) )
+ {
+ assertFalse( getRepository( ).hasMetadataFacet( session, TEST_REPO_ID, KindOfRepositoryStatistics.class.getName( ) ) );
}
}
@Test
- public void hasMetadataFacet()
- throws Exception {
+ public void hasMetadataFacet( )
+ throws Exception
+ {
- try (RepositorySession session = sessionFactory.createSession()) {
- assertFalse(repository.hasMetadataFacet( session, TEST_REPO_ID, KindOfRepositoryStatistics.class.getName()));
+ try ( RepositorySession session = getSessionFactory( ).createSession( ) )
+ {
+ assertFalse( getRepository( ).hasMetadataFacet( session, TEST_REPO_ID, KindOfRepositoryStatistics.class.getName( ) ) );
- Calendar cal = Calendar.getInstance();
+ Calendar cal = Calendar.getInstance( );
- repository.addMetadataFacet( session, TEST_REPO_ID, new KindOfRepositoryStatistics("first", cal.getTime()));
+ getRepository( ).addMetadataFacet( session, TEST_REPO_ID, new KindOfRepositoryStatistics( "first", cal.getTime( ) ) );
- assertTrue(repository.hasMetadataFacet( session, TEST_REPO_ID, KindOfRepositoryStatistics.class.getName()));
+ assertTrue( getRepository( ).hasMetadataFacet( session, TEST_REPO_ID, KindOfRepositoryStatistics.class.getName( ) ) );
- cal.add(Calendar.MINUTE, 2);
+ cal.add( Calendar.MINUTE, 2 );
- repository.addMetadataFacet( session, TEST_REPO_ID, new KindOfRepositoryStatistics("second", cal.getTime()));
+ getRepository( ).addMetadataFacet( session, TEST_REPO_ID, new KindOfRepositoryStatistics( "second", cal.getTime( ) ) );
- cal.add(Calendar.MINUTE, 2);
+ cal.add( Calendar.MINUTE, 2 );
- repository.addMetadataFacet( session, TEST_REPO_ID, new KindOfRepositoryStatistics("third", cal.getTime()));
+ getRepository( ).addMetadataFacet( session, TEST_REPO_ID, new KindOfRepositoryStatistics( "third", cal.getTime( ) ) );
- List<String> facets = repository.getMetadataFacets( session, TEST_REPO_ID, KindOfRepositoryStatistics.class.getName());
+ List<String> facets = getRepository( ).getMetadataFacets( session, TEST_REPO_ID, KindOfRepositoryStatistics.class.getName( ) );
- assertThat(facets).isNotNull().isNotEmpty().hasSize(3);
+ assertThat( facets ).isNotNull( ).isNotEmpty( ).hasSize( 3 );
- assertTrue(repository.hasMetadataFacet( session, TEST_REPO_ID, KindOfRepositoryStatistics.class.getName()));
+ assertTrue( getRepository( ).hasMetadataFacet( session, TEST_REPO_ID, KindOfRepositoryStatistics.class.getName( ) ) );
- repository.removeMetadataFacets( session, TEST_REPO_ID, KindOfRepositoryStatistics.class.getName());
+ getRepository( ).removeMetadataFacets( session, TEST_REPO_ID, KindOfRepositoryStatistics.class.getName( ) );
- assertFalse(repository.hasMetadataFacet( session, TEST_REPO_ID, KindOfRepositoryStatistics.class.getName()));
+ assertFalse( getRepository( ).hasMetadataFacet( session, TEST_REPO_ID, KindOfRepositoryStatistics.class.getName( ) ) );
- facets = repository.getMetadataFacets( session, TEST_REPO_ID, KindOfRepositoryStatistics.class.getName());
+ facets = getRepository( ).getMetadataFacets( session, TEST_REPO_ID, KindOfRepositoryStatistics.class.getName( ) );
- assertThat(facets).isNotNull().isEmpty();
+ assertThat( facets ).isNotNull( ).isEmpty( );
}
@Test
- public void testGetArtifacts()
- throws Exception {
- try (RepositorySession session = sessionFactory.createSession()) {
- ArtifactMetadata artifact1 = createArtifact();
- ArtifactMetadata artifact2 = createArtifact("pom");
- repository.updateArtifact( session, TEST_REPO_ID, TEST_NAMESPACE, TEST_PROJECT, TEST_PROJECT_VERSION, artifact1);
- repository.updateArtifact( session, TEST_REPO_ID, TEST_NAMESPACE, TEST_PROJECT, TEST_PROJECT_VERSION, artifact2);
+ public void testGetArtifacts( )
+ throws Exception
+ {
+ try ( RepositorySession session = getSessionFactory( ).createSession( ) )
+ {
+ ArtifactMetadata artifact1 = createArtifact( );
+ ArtifactMetadata artifact2 = createArtifact( "pom" );
+ getRepository( ).updateArtifact( session, TEST_REPO_ID, TEST_NAMESPACE, TEST_PROJECT, TEST_PROJECT_VERSION, artifact1 );
+ getRepository( ).updateArtifact( session, TEST_REPO_ID, TEST_NAMESPACE, TEST_PROJECT, TEST_PROJECT_VERSION, artifact2 );
- Collection<ArtifactMetadata> artifacts =
- repository.getArtifacts( session, TEST_REPO_ID, TEST_NAMESPACE, TEST_PROJECT, TEST_PROJECT_VERSION);
- ArrayList<ArtifactMetadata> actual = new ArrayList<>(artifacts);
- Collections.sort(actual, (o1, o2) -> o1.getId().compareTo(o2.getId()));
- assertEquals(Arrays.asList(artifact1, artifact2), actual);
+ tryAssert( ( ) -> {
+ Collection<ArtifactMetadata> artifacts =
+ getRepository( ).getArtifacts( session, TEST_REPO_ID, TEST_NAMESPACE, TEST_PROJECT, TEST_PROJECT_VERSION );
+ ArrayList<ArtifactMetadata> actual = new ArrayList<>( artifacts );
+ Collections.sort( actual, ( o1, o2 ) -> o1.getId( ).compareTo( o2.getId( ) ) );
+ assertEquals( Arrays.asList( artifact1, artifact2 ), actual );
+ } );
}
}
@Test
- public void testGetArtifactVersions()
- throws Exception {
- try (RepositorySession session = sessionFactory.createSession()) {
- ArtifactMetadata artifact1 = createArtifact();
+ public void testGetArtifactVersions( )
+ throws Exception
+ {
+ try ( RepositorySession session = getSessionFactory( ).createSession( ) )
+ {
+ ArtifactMetadata artifact1 = createArtifact( );
String version1 = "1.0-20091212.012345-1";
- artifact1.setId(artifact1.getProject() + "-" + version1 + ".jar");
- artifact1.setVersion(version1);
- ArtifactMetadata artifact2 = createArtifact();
+ artifact1.setId( artifact1.getProject( ) + "-" + version1 + ".jar" );
+ artifact1.setVersion( version1 );
+ ArtifactMetadata artifact2 = createArtifact( );
String version2 = "1.0-20091212.123456-2";
- artifact2.setId(artifact2.getProject() + "-" + version2 + ".jar");
- artifact2.setVersion(version2);
- repository.updateArtifact( session, TEST_REPO_ID, TEST_NAMESPACE, TEST_PROJECT, TEST_PROJECT_VERSION, artifact1);
- repository.updateArtifact( session, TEST_REPO_ID, TEST_NAMESPACE, TEST_PROJECT, TEST_PROJECT_VERSION, artifact2);
+ artifact2.setId( artifact2.getProject( ) + "-" + version2 + ".jar" );
+ artifact2.setVersion( version2 );
+ getRepository( ).updateArtifact( session, TEST_REPO_ID, TEST_NAMESPACE, TEST_PROJECT, TEST_PROJECT_VERSION, artifact1 );
+ getRepository( ).updateArtifact( session, TEST_REPO_ID, TEST_NAMESPACE, TEST_PROJECT, TEST_PROJECT_VERSION, artifact2 );
- Collection<String> versions =
- repository.getArtifactVersions( session, TEST_REPO_ID, TEST_NAMESPACE, TEST_PROJECT, TEST_PROJECT_VERSION);
+ tryAssert( ( ) -> {
+ Collection<String> versions =
+ getRepository( ).getArtifactVersions( session, TEST_REPO_ID, TEST_NAMESPACE, TEST_PROJECT, TEST_PROJECT_VERSION );
- assertThat(versions).isNotNull().isNotEmpty().contains(version1, version2);
+ assertThat( versions ).isNotNull( ).isNotEmpty( ).contains( version1, version2 );
+ } );
}
}
@Test
- public void testGetArtifactVersionsMultipleArtifactsSingleVersion()
- throws Exception {
- try (RepositorySession session = sessionFactory.createSession()) {
- ArtifactMetadata artifact1 = createArtifact();
- artifact1.setId(TEST_PROJECT + "-" + TEST_PROJECT_VERSION + ".jar");
- ArtifactMetadata artifact2 = createArtifact();
- artifact2.setId(TEST_PROJECT + "-" + TEST_PROJECT_VERSION + "-sources.jar");
- repository.updateArtifact( session, TEST_REPO_ID, TEST_NAMESPACE, TEST_PROJECT, TEST_PROJECT_VERSION, artifact1);
- repository.updateArtifact( session, TEST_REPO_ID, TEST_NAMESPACE, TEST_PROJECT, TEST_PROJECT_VERSION, artifact2);
+ public void testGetArtifactVersionsMultipleArtifactsSingleVersion( )
+ throws Exception
+ {
+ try ( RepositorySession session = getSessionFactory( ).createSession( ) )
+ {
+ ArtifactMetadata artifact1 = createArtifact( );
+ artifact1.setId( TEST_PROJECT + "-" + TEST_PROJECT_VERSION + ".jar" );
+ ArtifactMetadata artifact2 = createArtifact( );
+ artifact2.setId( TEST_PROJECT + "-" + TEST_PROJECT_VERSION + "-sources.jar" );
+ getRepository( ).updateArtifact( session, TEST_REPO_ID, TEST_NAMESPACE, TEST_PROJECT, TEST_PROJECT_VERSION, artifact1 );
+ getRepository( ).updateArtifact( session, TEST_REPO_ID, TEST_NAMESPACE, TEST_PROJECT, TEST_PROJECT_VERSION, artifact2 );
- Collection<String> versions =
- repository.getArtifactVersions( session, TEST_REPO_ID, TEST_NAMESPACE, TEST_PROJECT, TEST_PROJECT_VERSION);
+ tryAssert( ( ) -> {
+ Collection<String> versions =
+ getRepository( ).getArtifactVersions( session, TEST_REPO_ID, TEST_NAMESPACE, TEST_PROJECT, TEST_PROJECT_VERSION );
- assertThat(versions).isNotNull().isNotEmpty().hasSize(1).containsExactly(TEST_PROJECT_VERSION);
+ assertThat( versions ).isNotNull( ).isNotEmpty( ).hasSize( 1 ).containsExactly( TEST_PROJECT_VERSION );
+ } );
}
}
@Test
- public void testGetArtifactsByDateRangeOpen()
- throws Exception {
- try (RepositorySession session = sessionFactory.createSession()) {
- ArtifactMetadata artifact = createArtifact();
- repository.updateArtifact( session, TEST_REPO_ID, TEST_NAMESPACE, TEST_PROJECT, TEST_PROJECT_VERSION, artifact);
- session.save();
+ public void testGetArtifactsByDateRangeOpen( )
+ throws Exception
+ {
+ try ( RepositorySession session = getSessionFactory( ).createSession( ) )
+ {
+ ArtifactMetadata artifact = createArtifact( );
+ getRepository( ).updateArtifact( session, TEST_REPO_ID, TEST_NAMESPACE, TEST_PROJECT, TEST_PROJECT_VERSION, artifact );
+ session.save( );
- List<ArtifactMetadata> artifacts = repository.getArtifactsByDateRange( session, TEST_REPO_ID, null, null);
-
- assertEquals(Collections.singletonList(artifact), artifacts);
+ tryAssert( ( ) -> {
+ List<ArtifactMetadata> artifacts = getRepository( ).getArtifactsByDateRange( session, TEST_REPO_ID, null, null );
+ assertEquals( Collections.singletonList( artifact ), artifacts );
+ } );
}
}
@Test
- public void testGetArtifactsByDateRangeSparseNamespace()
- throws Exception {
- try (RepositorySession session = sessionFactory.createSession()) {
+ public void testGetArtifactsByDateRangeSparseNamespace( )
+ throws Exception
+ {
+ try ( RepositorySession session = getSessionFactory( ).createSession( ) )
+ {
String namespace = "org.apache.archiva";
- ArtifactMetadata artifact = createArtifact();
- artifact.setNamespace(namespace);
- repository.updateArtifact( session, TEST_REPO_ID, namespace, TEST_PROJECT, TEST_PROJECT_VERSION, artifact);
- session.save();
-
- List<ArtifactMetadata> artifacts = repository.getArtifactsByDateRange( session, TEST_REPO_ID, null, null);
+ ArtifactMetadata artifact = createArtifact( );
+ artifact.setNamespace( namespace );
+ getRepository( ).updateArtifact( session, TEST_REPO_ID, namespace, TEST_PROJECT, TEST_PROJECT_VERSION, artifact );
+ session.save( );
- tryAssert(() -> assertEquals(Collections.singletonList(artifact), artifacts));
+ tryAssert( ( ) -> {
+ List<ArtifactMetadata> artifacts = getRepository( ).getArtifactsByDateRange( session, TEST_REPO_ID, null, null );
+ tryAssert( ( ) -> assertEquals( Collections.singletonList( artifact ), artifacts ) );
+ } );
}
}
@Test
- public void testGetArtifactsByDateRangeLowerBound()
- throws Exception {
- try (RepositorySession session = sessionFactory.createSession()) {
- ArtifactMetadata artifact = createArtifact();
- repository.updateArtifact( session, TEST_REPO_ID, TEST_NAMESPACE, TEST_PROJECT, TEST_PROJECT_VERSION, artifact);
- session.save();
+ public void testGetArtifactsByDateRangeLowerBound( )
+ throws Exception
+ {
+ try ( RepositorySession session = getSessionFactory( ).createSession( ) )
+ {
+ ArtifactMetadata artifact = createArtifact( );
+ getRepository( ).updateArtifact( session, TEST_REPO_ID, TEST_NAMESPACE, TEST_PROJECT, TEST_PROJECT_VERSION, artifact );
+ session.save( );
- Date date = new Date(artifact.getWhenGathered().getTime() - 10000);
+ Date date = new Date( artifact.getWhenGathered( ).getTime( ) - 10000 );
- List<ArtifactMetadata> artifacts = repository.getArtifactsByDateRange( session, TEST_REPO_ID, date, null);
-
- assertEquals(Collections.singletonList(artifact), artifacts);
+ tryAssert( ( ) -> {
+ List<ArtifactMetadata> artifacts = getRepository( ).getArtifactsByDateRange( session, TEST_REPO_ID, date, null );
+ assertEquals( Collections.singletonList( artifact ), artifacts );
+ } );
}
}
@Test
- public void testGetArtifactsByDateRangeLowerBoundOutOfRange()
- throws Exception {
- try (RepositorySession session = sessionFactory.createSession()) {
- ArtifactMetadata artifact = createArtifact();
- repository.updateArtifact( session, TEST_REPO_ID, TEST_NAMESPACE, TEST_PROJECT, TEST_PROJECT_VERSION, artifact);
-
- Date date = new Date(artifact.getWhenGathered().getTime() + 10000);
+ public void testGetArtifactsByDateRangeLowerBoundOutOfRange( )
+ throws Exception
+ {
+ try ( RepositorySession session = getSessionFactory( ).createSession( ) )
+ {
+ ArtifactMetadata artifact = createArtifact( );
+ getRepository( ).updateArtifact( session, TEST_REPO_ID, TEST_NAMESPACE, TEST_PROJECT, TEST_PROJECT_VERSION, artifact );
- List<ArtifactMetadata> artifacts = repository.getArtifactsByDateRange( session, TEST_REPO_ID, date, null);
+ Date date = new Date( artifact.getWhenGathered( ).getTime( ) + 10000 );
- assertThat(artifacts).isNotNull().isEmpty();
+ tryAssert( ( ) -> {
+ List<ArtifactMetadata> artifacts = getRepository( ).getArtifactsByDateRange( session, TEST_REPO_ID, date, null );
+ assertThat( artifacts ).isNotNull( ).isEmpty( );
+ } );
}
}
@Test
- public void testGetArtifactsByDateRangeLowerAndUpperBound()
- throws Exception {
- try (RepositorySession session = sessionFactory.createSession()) {
- ArtifactMetadata artifact = createArtifact();
- repository.updateArtifact( session, TEST_REPO_ID, TEST_NAMESPACE, TEST_PROJECT, TEST_PROJECT_VERSION, artifact);
- session.save();
-
- Date lower = new Date(artifact.getWhenGathered().getTime() - 10000);
- Date upper = new Date(artifact.getWhenGathered().getTime() + 10000);
+ public void testGetArtifactsByDateRangeLowerAndUpperBound( )
+ throws Exception
+ {
+ try ( RepositorySession session = getSessionFactory( ).createSession( ) )
+ {
+ ArtifactMetadata artifact = createArtifact( );
+ getRepository( ).updateArtifact( session, TEST_REPO_ID, TEST_NAMESPACE, TEST_PROJECT, TEST_PROJECT_VERSION, artifact );
+ session.save( );
- List<ArtifactMetadata> artifacts = repository.getArtifactsByDateRange( session, TEST_REPO_ID, lower, upper);
+ Date lower = new Date( artifact.getWhenGathered( ).getTime( ) - 10000 );
+ Date upper = new Date( artifact.getWhenGathered( ).getTime( ) + 10000 );
- assertEquals(Collections.singletonList(artifact), artifacts);
+ tryAssert( ( ) -> {
+ List<ArtifactMetadata> artifacts = getRepository( ).getArtifactsByDateRange( session, TEST_REPO_ID, lower, upper );
+ assertEquals( Collections.singletonList( artifact ), artifacts );
+ } );
}
}
@Test
- public void testGetArtifactsByDateRangeUpperBound()
- throws Exception {
- try (RepositorySession session = sessionFactory.createSession()) {
- ArtifactMetadata artifact = createArtifact();
- repository.updateArtifact( session, TEST_REPO_ID, TEST_NAMESPACE, TEST_PROJECT, TEST_PROJECT_VERSION, artifact);
- session.save();
+ public void testGetArtifactsByDateRangeUpperBound( )
+ throws Exception
+ {
+ try ( RepositorySession session = getSessionFactory( ).createSession( ) )
+ {
+ ArtifactMetadata artifact = createArtifact( );
+ getRepository( ).updateArtifact( session, TEST_REPO_ID, TEST_NAMESPACE, TEST_PROJECT, TEST_PROJECT_VERSION, artifact );
+ session.save( );
- Date upper = new Date(artifact.getWhenGathered().getTime() + 10000);
+ Date upper = new Date( artifact.getWhenGathered( ).getTime( ) + 10000 );
- List<ArtifactMetadata> artifacts = repository.getArtifactsByDateRange( session, TEST_REPO_ID, null, upper);
-
- assertEquals(Collections.singletonList(artifact), artifacts);
+ tryAssert( ( ) -> {
+ List<ArtifactMetadata> artifacts = getRepository( ).getArtifactsByDateRange( session, TEST_REPO_ID, null, upper );
+ assertEquals( Collections.singletonList( artifact ), artifacts );
+ } );
}
}
@Test
- public void testGetArtifactsByDateRangeUpperBoundOutOfRange()
- throws Exception {
- try (RepositorySession session = sessionFactory.createSession()) {
- ArtifactMetadata artifact = createArtifact();
- repository.updateArtifact( session, TEST_REPO_ID, TEST_NAMESPACE, TEST_PROJECT, TEST_PROJECT_VERSION, artifact);
- session.save();
-
- Date upper = new Date(artifact.getWhenGathered().getTime() - 10000);
+ public void testGetArtifactsByDateRangeUpperBoundOutOfRange( )
+ throws Exception
+ {
+ try ( RepositorySession session = getSessionFactory( ).createSession( ) )
+ {
+ ArtifactMetadata artifact = createArtifact( );
+ getRepository( ).updateArtifact( session, TEST_REPO_ID, TEST_NAMESPACE, TEST_PROJECT, TEST_PROJECT_VERSION, artifact );
+ session.save( );
- List<ArtifactMetadata> artifacts = repository.getArtifactsByDateRange( session, TEST_REPO_ID, null, upper);
+ Date upper = new Date( artifact.getWhenGathered( ).getTime( ) - 10000 );
- assertThat(artifacts).isNotNull().isEmpty();
+ tryAssert( ( ) -> {
+ List<ArtifactMetadata> artifacts = getRepository( ).getArtifactsByDateRange( session, TEST_REPO_ID, null, upper );
+ assertThat( artifacts ).isNotNull( ).isEmpty( );
+ } );
}
}
@Test
- public void testGetArtifactsByRepoId()
- throws Exception {
- try (RepositorySession session = sessionFactory.createSession()) {
- ArtifactMetadata artifact = createArtifact();
- repository.updateArtifact(session, TEST_REPO_ID, TEST_NAMESPACE, TEST_PROJECT, TEST_PROJECT_VERSION, artifact);
- session.save();
-
- tryAssert(() -> {
- List<ArtifactMetadata> artifacts = repository.getArtifacts(session, TEST_REPO_ID);
- assertEquals(Collections.singletonList(artifact), artifacts);
- }
+ public void testGetArtifactsByRepoId( )
+ throws Exception
+ {
+ ArtifactMetadata artifact;
+ try ( RepositorySession session = getSessionFactory( ).createSession( ) )
+ {
+ artifact = createArtifact( );
+ getRepository( ).updateArtifact( session, TEST_REPO_ID, TEST_NAMESPACE, TEST_PROJECT, TEST_PROJECT_VERSION, artifact );
+ session.save( );
+ }
+ try ( RepositorySession session = getSessionFactory( ).createSession( ) )
+ {
+ tryAssert( ( ) -> {
+ session.refreshAndDiscard( );
+ List<ArtifactMetadata> artifacts = getRepository( ).getArtifacts( session, TEST_REPO_ID );
+ assertEquals( Collections.singletonList( artifact ), artifacts );
+ }
);
}
}
@Test
- public void testGetArtifactsByRepoIdMultipleCopies()
- throws Exception {
- try (RepositorySession session = sessionFactory.createSession()) {
- ArtifactMetadata artifact = createArtifact();
- repository.updateArtifact( session, TEST_REPO_ID, TEST_NAMESPACE, TEST_PROJECT, TEST_PROJECT_VERSION, artifact);
+ public void testGetArtifactsByRepoIdMultipleCopies( )
+ throws Exception
+ {
+ try ( RepositorySession session = getSessionFactory( ).createSession( ) )
+ {
+ ArtifactMetadata artifact = createArtifact( );
+ getRepository( ).updateArtifact( session, TEST_REPO_ID, TEST_NAMESPACE, TEST_PROJECT, TEST_PROJECT_VERSION, artifact );
- ArtifactMetadata secondArtifact = createArtifact();
- secondArtifact.setRepositoryId(OTHER_REPO_ID);
- repository.updateArtifact( session, OTHER_REPO_ID, TEST_NAMESPACE, TEST_PROJECT, TEST_PROJECT_VERSION, secondArtifact);
- session.save();
+ ArtifactMetadata secondArtifact = createArtifact( );
+ secondArtifact.setRepositoryId( OTHER_REPO_ID );
+ getRepository( ).updateArtifact( session, OTHER_REPO_ID, TEST_NAMESPACE, TEST_PROJECT, TEST_PROJECT_VERSION, secondArtifact );
+ session.save( );
// test it restricts to the appropriate repository
- tryAssert(() -> assertEquals(Collections.singletonList(artifact), repository.getArtifacts( session, TEST_REPO_ID)));
- tryAssert(() -> assertEquals(Collections.singletonList(secondArtifact), repository.getArtifacts( session, OTHER_REPO_ID)));
+ tryAssert( ( ) -> assertEquals( Collections.singletonList( artifact ), getRepository( ).getArtifacts( session, TEST_REPO_ID ) ) );
+ tryAssert( ( ) -> assertEquals( Collections.singletonList( secondArtifact ), getRepository( ).getArtifacts( session, OTHER_REPO_ID ) ) );
}
}
@Test
- public void testGetArtifactsByDateRangeMultipleCopies()
- throws Exception {
- try (RepositorySession session = sessionFactory.createSession()) {
- ArtifactMetadata artifact = createArtifact();
- repository.updateArtifact( session, TEST_REPO_ID, TEST_NAMESPACE, TEST_PROJECT, TEST_PROJECT_VERSION, artifact);
+ public void testGetArtifactsByDateRangeMultipleCopies( )
+ throws Exception
+ {
+ try ( RepositorySession session = getSessionFactory( ).createSession( ) )
+ {
+ ArtifactMetadata artifact = createArtifact( );
+ getRepository( ).updateArtifact( session, TEST_REPO_ID, TEST_NAMESPACE, TEST_PROJECT, TEST_PROJECT_VERSION, artifact );
- ArtifactMetadata secondArtifact = createArtifact();
- secondArtifact.setRepositoryId(OTHER_REPO_ID);
- repository.updateArtifact( session, OTHER_REPO_ID, TEST_NAMESPACE, TEST_PROJECT, TEST_PROJECT_VERSION, secondArtifact);
- session.save();
-
- // test it restricts to the appropriate repository
- assertEquals(Collections.singletonList(artifact),
- repository.getArtifactsByDateRange( session, TEST_REPO_ID, null, null));
- assertEquals(Collections.singletonList(secondArtifact),
- repository.getArtifactsByDateRange( session, OTHER_REPO_ID, null, null));
+ ArtifactMetadata secondArtifact = createArtifact( );
+ secondArtifact.setRepositoryId( OTHER_REPO_ID );
+ getRepository( ).updateArtifact( session, OTHER_REPO_ID, TEST_NAMESPACE, TEST_PROJECT, TEST_PROJECT_VERSION, secondArtifact );
+ session.save( );
+ tryAssert( ( ) -> {
+ // test it restricts to the appropriate repository
+ assertEquals( Collections.singletonList( artifact ),
+ getRepository( ).getArtifactsByDateRange( session, TEST_REPO_ID, null, null ) );
+ } );
+ tryAssert( ( ) -> {
+ assertEquals( Collections.singletonList( secondArtifact ),
+ getRepository( ).getArtifactsByDateRange( session, OTHER_REPO_ID, null, null ) );
+ } );
}
}
@Test
- public void testGetArtifactsByChecksumMultipleCopies()
- throws Exception {
- try (RepositorySession session = sessionFactory.createSession()) {
- ArtifactMetadata artifact = createArtifact();
- repository.updateArtifact( session, TEST_REPO_ID, TEST_NAMESPACE, TEST_PROJECT, TEST_PROJECT_VERSION, artifact);
+ public void testGetArtifactsByChecksumMultipleCopies( )
+ throws Exception
+ {
+ try ( RepositorySession session = getSessionFactory( ).createSession( ) )
+ {
+ ArtifactMetadata artifact = createArtifact( );
+ getRepository( ).updateArtifact( session, TEST_REPO_ID, TEST_NAMESPACE, TEST_PROJECT, TEST_PROJECT_VERSION, artifact );
- ArtifactMetadata secondArtifact = createArtifact();
- secondArtifact.setRepositoryId(OTHER_REPO_ID);
- repository.updateArtifact( session, OTHER_REPO_ID, TEST_NAMESPACE, TEST_PROJECT, TEST_PROJECT_VERSION, secondArtifact);
- session.save();
+ ArtifactMetadata secondArtifact = createArtifact( );
+ secondArtifact.setRepositoryId( OTHER_REPO_ID );
+ getRepository( ).updateArtifact( session, OTHER_REPO_ID, TEST_NAMESPACE, TEST_PROJECT, TEST_PROJECT_VERSION, secondArtifact );
+ session.save( );
- // test it restricts to the appropriate repository
- assertEquals(Collections.singletonList(artifact),
- new ArrayList<>(repository.getArtifactsByChecksum( session, TEST_REPO_ID, TEST_SHA1)));
- assertEquals(Collections.singletonList(secondArtifact), new ArrayList<>(
- repository.getArtifactsByChecksum( session, OTHER_REPO_ID, TEST_SHA1)));
- assertEquals(Collections.singletonList(artifact),
- new ArrayList<>(repository.getArtifactsByChecksum( session, TEST_REPO_ID, TEST_MD5)));
- assertEquals(Collections.singletonList(secondArtifact),
- new ArrayList<>(repository.getArtifactsByChecksum( session, OTHER_REPO_ID, TEST_MD5)));
+ tryAssert( ( ) -> {
+ // test it restricts to the appropriate repository
+ assertEquals( Collections.singletonList( artifact ),
+ new ArrayList<>( getRepository( ).getArtifactsByChecksum( session, TEST_REPO_ID, TEST_SHA1 ) ) );
+ } );
+ tryAssert( ( ) -> {
+ assertEquals( Collections.singletonList( secondArtifact ), new ArrayList<>(
+ getRepository( ).getArtifactsByChecksum( session, OTHER_REPO_ID, TEST_SHA1 ) ) );
+ } );
+ tryAssert( ( ) -> {
+ assertEquals( Collections.singletonList( artifact ),
+ new ArrayList<>( getRepository( ).getArtifactsByChecksum( session, TEST_REPO_ID, TEST_MD5 ) ) );
+ } );
+ tryAssert( ( ) -> {
+ assertEquals( Collections.singletonList( secondArtifact ),
+ new ArrayList<>( getRepository( ).getArtifactsByChecksum( session, OTHER_REPO_ID, TEST_MD5 ) ) );
+ } );
}
}
@Test
- public void testGetNamespacesWithSparseDepth()
- throws Exception {
- try (RepositorySession session = sessionFactory.createSession()) {
- repository.updateNamespace( session, TEST_REPO_ID, "org.apache.maven.shared");
+ public void testGetNamespacesWithSparseDepth( )
+ throws Exception
+ {
+ try ( RepositorySession session = getSessionFactory( ).createSession( ) )
+ {
+ getRepository( ).updateNamespace( session, TEST_REPO_ID, "org.apache.maven.shared" );
+
+ tryAssert( ( ) -> {
- Collection<String> namespaces = repository.getRootNamespaces( session, TEST_REPO_ID);
+ Collection<String> namespaces = getRepository( ).getRootNamespaces( session, TEST_REPO_ID );
- assertThat(namespaces).isNotNull().isNotEmpty().hasSize(1).contains("org");
+ assertThat( namespaces ).isNotNull( ).isNotEmpty( ).hasSize( 1 ).contains( "org" );
- namespaces = repository.getNamespaces( session, TEST_REPO_ID, "org");
- assertThat(namespaces).isNotNull().isNotEmpty().hasSize(1).contains("apache");
+ namespaces = getRepository( ).getNamespaces( session, TEST_REPO_ID, "org" );
+ assertThat( namespaces ).isNotNull( ).isNotEmpty( ).hasSize( 1 ).contains( "apache" );
- namespaces = repository.getNamespaces( session, TEST_REPO_ID, "org.apache");
- assertThat(namespaces).isNotNull().isNotEmpty().hasSize(1).contains("maven");
+ namespaces = getRepository( ).getNamespaces( session, TEST_REPO_ID, "org.apache" );
+ assertThat( namespaces ).isNotNull( ).isNotEmpty( ).hasSize( 1 ).contains( "maven" );
- namespaces = repository.getNamespaces( session, TEST_REPO_ID, "org.apache.maven");
- assertThat(namespaces).isNotNull().isNotEmpty().hasSize(1).contains("shared");
+ namespaces = getRepository( ).getNamespaces( session, TEST_REPO_ID, "org.apache.maven" );
+ assertThat( namespaces ).isNotNull( ).isNotEmpty( ).hasSize( 1 ).contains( "shared" );
+ } );
}
}
@Test
- public void testGetNamespacesWithProjectsPresent()
- throws Exception {
- try (RepositorySession session = sessionFactory.createSession()) {
+ public void testGetNamespacesWithProjectsPresent( )
+ throws Exception
+ {
+ try ( RepositorySession session = getSessionFactory( ).createSession( ) )
+ {
String namespace = "org.apache.maven.shared";
- repository.updateNamespace( session, TEST_REPO_ID, namespace);
+ getRepository( ).updateNamespace( session, TEST_REPO_ID, namespace );
- ProjectVersionMetadata metadata = new ProjectVersionMetadata();
- metadata.setId(TEST_PROJECT_VERSION);
- repository.updateProjectVersion( session, TEST_REPO_ID, namespace, TEST_PROJECT, metadata);
+ ProjectVersionMetadata metadata = new ProjectVersionMetadata( );
+ metadata.setId( TEST_PROJECT_VERSION );
+ getRepository( ).updateProjectVersion( session, TEST_REPO_ID, namespace, TEST_PROJECT, metadata );
- Collection<String> namespaces = repository.getNamespaces( session, TEST_REPO_ID, namespace);
+ Collection<String> namespaces = getRepository( ).getNamespaces( session, TEST_REPO_ID, namespace );
- assertThat(namespaces).isNotNull().isEmpty();
+ assertThat( namespaces ).isNotNull( ).isEmpty( );
}
}
@Test
- public void testGetProjectsWithOtherNamespacesPresent()
- throws Exception {
- try (RepositorySession session = sessionFactory.createSession()) {
- ProjectMetadata projectMetadata = new ProjectMetadata();
- projectMetadata.setId(TEST_PROJECT);
- projectMetadata.setNamespace("org.apache.maven");
- repository.updateProject( session, TEST_REPO_ID, projectMetadata);
+ public void testGetProjectsWithOtherNamespacesPresent( )
+ throws Exception
+ {
+ try ( RepositorySession session = getSessionFactory( ).createSession( ) )
+ {
+ ProjectMetadata projectMetadata = new ProjectMetadata( );
+ projectMetadata.setId( TEST_PROJECT );
+ projectMetadata.setNamespace( "org.apache.maven" );
+ getRepository( ).updateProject( session, TEST_REPO_ID, projectMetadata );
- repository.updateNamespace( session, TEST_REPO_ID, "org.apache.maven.shared");
+ getRepository( ).updateNamespace( session, TEST_REPO_ID, "org.apache.maven.shared" );
- Collection<String> projects = repository.getProjects( session, TEST_REPO_ID, "org.apache.maven");
+ Collection<String> projects = getRepository( ).getProjects( session, TEST_REPO_ID, "org.apache.maven" );
- assertThat(projects).isNotNull().isNotEmpty().hasSize(1).contains(TEST_PROJECT);
+ assertThat( projects ).isNotNull( ).isNotEmpty( ).hasSize( 1 ).contains( TEST_PROJECT );
}
}
@Test
- public void testGetProjectVersionsWithOtherNamespacesPresent()
- throws Exception {
- try (RepositorySession session = sessionFactory.createSession()) {
+ public void testGetProjectVersionsWithOtherNamespacesPresent( )
+ throws Exception
+ {
+ try ( RepositorySession session = getSessionFactory( ).createSession( ) )
+ {
// an unusual case but technically possible where a project namespace matches another project's name
- ProjectVersionMetadata versionMetadata = new ProjectVersionMetadata();
- versionMetadata.setId(TEST_PROJECT_VERSION);
- repository.updateProjectVersion( session, TEST_REPO_ID, "org.apache.maven", TEST_PROJECT, versionMetadata);
+ ProjectVersionMetadata versionMetadata = new ProjectVersionMetadata( );
+ versionMetadata.setId( TEST_PROJECT_VERSION );
+ getRepository( ).updateProjectVersion( session, TEST_REPO_ID, "org.apache.maven", TEST_PROJECT, versionMetadata );
- repository.updateProjectVersion( session, TEST_REPO_ID, "org.apache.maven." + TEST_PROJECT,
- "other-project", versionMetadata);
+ getRepository( ).updateProjectVersion( session, TEST_REPO_ID, "org.apache.maven." + TEST_PROJECT,
+ "other-project", versionMetadata );
Collection<String> versions =
- repository.getProjectVersions( session, TEST_REPO_ID, "org.apache.maven." + TEST_PROJECT, "other-project");
- assertThat(versions).isNotNull().isNotEmpty().contains(TEST_PROJECT_VERSION);
+ getRepository( ).getProjectVersions( session, TEST_REPO_ID, "org.apache.maven." + TEST_PROJECT, "other-project" );
+ assertThat( versions ).isNotNull( ).isNotEmpty( ).contains( TEST_PROJECT_VERSION );
- versions = repository.getProjectVersions( session, TEST_REPO_ID, "org.apache.maven", TEST_PROJECT);
+ versions = getRepository( ).getProjectVersions( session, TEST_REPO_ID, "org.apache.maven", TEST_PROJECT );
- assertThat(versions).isNotNull().isNotEmpty().contains(TEST_PROJECT_VERSION);
+ assertThat( versions ).isNotNull( ).isNotEmpty( ).contains( TEST_PROJECT_VERSION );
}
}
@Test
- public void testGetArtifactsByChecksumSingleResultMd5()
- throws Exception {
- try (RepositorySession session = sessionFactory.createSession()) {
- ArtifactMetadata artifact = createArtifact();
- repository.updateArtifact( session, TEST_REPO_ID, TEST_NAMESPACE, TEST_PROJECT, TEST_PROJECT_VERSION, artifact);
- session.save();
+ public void testGetArtifactsByChecksumSingleResultMd5( )
+ throws Exception
+ {
+ try ( RepositorySession session = getSessionFactory( ).createSession( ) )
+ {
+ ArtifactMetadata artifact = createArtifact( );
+ getRepository( ).updateArtifact( session, TEST_REPO_ID, TEST_NAMESPACE, TEST_PROJECT, TEST_PROJECT_VERSION, artifact );
+ session.save( );
- assertEquals(Collections.singletonList(artifact),
- new ArrayList<>(repository.getArtifactsByChecksum( session, TEST_REPO_ID, TEST_MD5)));
+ assertEquals( Collections.singletonList( artifact ),
+ new ArrayList<>( getRepository( ).getArtifactsByChecksum( session, TEST_REPO_ID, TEST_MD5 ) ) );
}
}
@Test
- public void testGetArtifactsByChecksumSingleResultSha1()
- throws Exception {
- try (RepositorySession session = sessionFactory.createSession()) {
- ArtifactMetadata artifact = createArtifact();
- repository.updateArtifact( session, TEST_REPO_ID, TEST_NAMESPACE, TEST_PROJECT, TEST_PROJECT_VERSION, artifact);
- session.save();
+ public void testGetArtifactsByChecksumSingleResultSha1( )
+ throws Exception
+ {
+ try ( RepositorySession session = getSessionFactory( ).createSession( ) )
+ {
+ ArtifactMetadata artifact = createArtifact( );
+ getRepository( ).updateArtifact( session, TEST_REPO_ID, TEST_NAMESPACE, TEST_PROJECT, TEST_PROJECT_VERSION, artifact );
+ session.save( );
- assertEquals(Collections.singletonList(artifact),
- new ArrayList<>(repository.getArtifactsByChecksum( session, TEST_REPO_ID, TEST_SHA1)));
+ assertEquals( Collections.singletonList( artifact ),
+ new ArrayList<>( getRepository( ).getArtifactsByChecksum( session, TEST_REPO_ID, TEST_SHA1 ) ) );
}
}
@Test
- public void testGetArtifactsByChecksumDeepNamespace()
- throws Exception {
- try (RepositorySession session = sessionFactory.createSession()) {
- ArtifactMetadata artifact = createArtifact();
+ public void testGetArtifactsByChecksumDeepNamespace( )
+ throws Exception
+ {
+ try ( RepositorySession session = getSessionFactory( ).createSession( ) )
+ {
+ ArtifactMetadata artifact = createArtifact( );
String namespace = "multi.level.ns";
- artifact.setNamespace(namespace);
- repository.updateArtifact( session, TEST_REPO_ID, namespace, TEST_PROJECT, TEST_PROJECT_VERSION, artifact);
- session.save();
+ artifact.setNamespace( namespace );
+ getRepository( ).updateArtifact( session, TEST_REPO_ID, namespace, TEST_PROJECT, TEST_PROJECT_VERSION, artifact );
+ session.save( );
- tryAssert(() -> assertEquals(Collections.singletonList(artifact),
- new ArrayList<>(repository.getArtifactsByChecksum( session, TEST_REPO_ID, TEST_SHA1))));
- tryAssert(() -> assertEquals(Collections.singletonList(artifact),
- new ArrayList<>(repository.getArtifactsByChecksum( session, TEST_REPO_ID, TEST_MD5))));
+ tryAssert( ( ) -> assertEquals( Collections.singletonList( artifact ),
+ new ArrayList<>( getRepository( ).getArtifactsByChecksum( session, TEST_REPO_ID, TEST_SHA1 ) ) ) );
+ tryAssert( ( ) -> assertEquals( Collections.singletonList( artifact ),
+ new ArrayList<>( getRepository( ).getArtifactsByChecksum( session, TEST_REPO_ID, TEST_MD5 ) ) ) );
}
}
@Test
- public void testGetArtifactsByChecksumMultipleResult()
- throws Exception {
+ public void testGetArtifactsByChecksumMultipleResult( )
+ throws Exception
+ {
- try (RepositorySession session = sessionFactory.createSession()) {
- ArtifactMetadata artifact1 = createArtifact();
- repository.updateArtifact(session, TEST_REPO_ID, TEST_NAMESPACE, TEST_PROJECT, TEST_PROJECT_VERSION, artifact1);
+ try ( RepositorySession session = getSessionFactory( ).createSession( ) )
+ {
+ ArtifactMetadata artifact1 = createArtifact( );
+ getRepository( ).updateArtifact( session, TEST_REPO_ID, TEST_NAMESPACE, TEST_PROJECT, TEST_PROJECT_VERSION, artifact1 );
String newProjectId = "another-project";
- ArtifactMetadata artifact2 = createArtifact();
- artifact2.setProject(newProjectId);
- repository.updateArtifact(session, TEST_REPO_ID, TEST_NAMESPACE, newProjectId, TEST_PROJECT_VERSION, artifact2);
- session.save();
+ ArtifactMetadata artifact2 = createArtifact( );
+ artifact2.setProject( newProjectId );
+ getRepository( ).updateArtifact( session, TEST_REPO_ID, TEST_NAMESPACE, newProjectId, TEST_PROJECT_VERSION, artifact2 );
+ session.save( );
- tryAssert(() -> {
+ tryAssert( ( ) -> {
List<ArtifactMetadata> artifacts =
- new ArrayList<>(repository.getArtifactsByChecksum(session, TEST_REPO_ID, TEST_SHA1));
- Collections.sort(artifacts, new ArtifactMetadataComparator());
- assertEquals(Arrays.asList(artifact2, artifact1), artifacts);
- });
+ new ArrayList<>( getRepository( ).getArtifactsByChecksum( session, TEST_REPO_ID, TEST_SHA1 ) );
+ Collections.sort( artifacts, new ArtifactMetadataComparator( ) );
+ assertEquals( Arrays.asList( artifact2, artifact1 ), artifacts );
+ } );
- tryAssert(() -> {
- ArrayList<ArtifactMetadata> artifacts = new ArrayList<>(repository.getArtifactsByChecksum(session, TEST_REPO_ID, TEST_MD5));
- Collections.sort(artifacts, new ArtifactMetadataComparator());
- assertEquals(Arrays.asList(artifact2, artifact1), artifacts);
- });
+ tryAssert( ( ) -> {
+ ArrayList<ArtifactMetadata> artifacts = new ArrayList<>( getRepository( ).getArtifactsByChecksum( session, TEST_REPO_ID, TEST_MD5 ) );
+ Collections.sort( artifacts, new ArtifactMetadataComparator( ) );
+ assertEquals( Arrays.asList( artifact2, artifact1 ), artifacts );
+ } );
}
}
@Test
- public void testGetArtifactsByChecksumNoResult()
- throws Exception {
- try (RepositorySession session = sessionFactory.createSession()) {
- ArtifactMetadata artifact = createArtifact();
- repository.updateArtifact( session, TEST_REPO_ID, TEST_NAMESPACE, TEST_PROJECT, TEST_PROJECT_VERSION, artifact);
-
- Collection<ArtifactMetadata> artifactsByChecksum =
- repository.getArtifactsByChecksum( session, TEST_REPO_ID, "not checksum");
- assertThat(artifactsByChecksum).isNotNull().isEmpty();
+ public void testGetArtifactsByChecksumNoResult( )
+ throws Exception
+ {
+ try ( RepositorySession session = getSessionFactory( ).createSession( ) )
+ {
+ ArtifactMetadata artifact = createArtifact( );
+ getRepository( ).updateArtifact( session, TEST_REPO_ID, TEST_NAMESPACE, TEST_PROJECT, TEST_PROJECT_VERSION, artifact );
- }
- }
+ tryAssert( ( ) -> {
+ Collection<ArtifactMetadata> artifactsByChecksum =
+ getRepository( ).getArtifactsByChecksum( session, TEST_REPO_ID, "not checksum" );
- @Test
- public void testGetArtifactsByProjectVersionMetadata()
- throws Exception {
- try (RepositorySession session = sessionFactory.createSession()) {
- createArtifactWithGenericMetadataFacet( session,10);
- Collection<ArtifactMetadata> artifactsByMetadata =
- repository.getArtifactsByProjectVersionMetadata( session, TEST_METADATA_KEY, TEST_METADATA_VALUE, TEST_REPO_ID);
- assertThat(artifactsByMetadata).hasSize(1);
- ArtifactMetadata artifactMetadata = artifactsByMetadata.iterator().next();
- assertThat(artifactMetadata.getId()).isEqualTo("projectId-1.0.jar");
- assertThat(artifactMetadata.getSha1()).isEqualTo(TEST_SHA1);
- assertThat(artifactMetadata.getRepositoryId()).isEqualTo(TEST_REPO_ID);
+ assertThat( artifactsByChecksum ).isNotNull( ).isEmpty( );
+ } );
}
}
@Test
- public void testGetArtifactsByProjectVersionMetadataNoRepository()
- throws Exception {
- try (RepositorySession session = sessionFactory.createSession()) {
- createArtifactWithGenericMetadataFacet(session);
- Collection<ArtifactMetadata> artifactsByMetadata =
- repository.getArtifactsByProjectVersionMetadata( session, TEST_METADATA_KEY, TEST_METADATA_VALUE, null);
- assertThat(artifactsByMetadata).hasSize(1);
- assertThat(artifactsByMetadata.iterator().next().getRepositoryId()).isNotNull().isNotEmpty();
+ public void testGetArtifactsByProjectVersionMetadata( )
+ throws Exception
+ {
+ try ( RepositorySession session = getSessionFactory( ).createSession( ) )
+ {
+ createArtifactWithGenericMetadataFacet( session, 10 );
+
+ tryAssert( ( ) -> {
+ Collection<ArtifactMetadata> artifactsByMetadata =
+ getRepository( ).getArtifactsByProjectVersionMetadata( session, TEST_METADATA_KEY, TEST_METADATA_VALUE, TEST_REPO_ID );
+ assertThat( artifactsByMetadata ).hasSize( 1 );
+ ArtifactMetadata artifactMetadata = artifactsByMetadata.iterator( ).next( );
+ assertThat( artifactMetadata.getId( ) ).isEqualTo( TEST_PROJECT + "-" + TEST_PROJECT_VERSION + ".jar" );
+ assertThat( artifactMetadata.getSha1( ) ).isEqualTo( TEST_SHA1 );
+ assertThat( artifactMetadata.getRepositoryId( ) ).isEqualTo( TEST_REPO_ID );
+ } );
}
}
@Test
- public void testGetArtifactsByProjectVersionMetadataAllRepositories()
- throws Exception {
- try (RepositorySession session = sessionFactory.createSession()) {
- createArtifactWithGenericMetadataFacet(session);
- Collection<ArtifactMetadata> artifactsByMetadata =
- repository.getArtifactsByProjectVersionMetadata( session, TEST_METADATA_KEY, TEST_METADATA_VALUE, null);
- assertThat(artifactsByMetadata).hasSize(1);
+ public void testGetArtifactsByProjectVersionMetadataNoRepository( )
+ throws Exception
+ {
+ try ( RepositorySession session = getSessionFactory( ).createSession( ) )
+ {
+ createArtifactWithGenericMetadataFacet( session );
+ tryAssert( ( ) -> {
+ Collection<ArtifactMetadata> artifactsByMetadata =
+ getRepository( ).getArtifactsByProjectVersionMetadata( session, TEST_METADATA_KEY, TEST_METADATA_VALUE, null );
+ assertThat( artifactsByMetadata ).hasSize( 1 );
+ assertThat( artifactsByMetadata.iterator( ).next( ).getRepositoryId( ) ).isNotNull( ).isNotEmpty( );
+ } );
}
}
@Test
- public void testGetArtifactsByMetadataAllRepositories()
- throws Exception {
- try (RepositorySession session = sessionFactory.createSession()) {
- createArtifactWithMavenArtifactFacet(session);
- tryAssert(() -> {
+ public void testGetArtifactsByProjectVersionMetadataAllRepositories( )
+ throws Exception
+ {
+ try ( RepositorySession session = getSessionFactory( ).createSession( ) )
+ {
+ createArtifactWithGenericMetadataFacet( session );
+ tryAssert( ( ) -> {
+
Collection<ArtifactMetadata> artifactsByMetadata =
- repository.getArtifactsByMetadata(session, "foo", TEST_METADATA_VALUE, null);
- assertThat(artifactsByMetadata).hasSize(1);
- ArtifactMetadata artifactMetadata = artifactsByMetadata.iterator().next();
- assertThat(artifactMetadata.getId()).isEqualTo("projectId-1.0.jar");
- assertThat(artifactMetadata.getSha1()).isEqualTo(TEST_SHA1);
- assertThat(artifactMetadata.getRepositoryId()).isEqualTo(TEST_REPO_ID);
- MetadataFacet facet = artifactMetadata.getFacet(TEST_FACET_ID);
- assertThat(facet).isNotNull();
- assertThat(facet.toProperties()).isEqualTo(Collections.singletonMap("foo", TEST_METADATA_VALUE));
- });
+ getRepository( ).getArtifactsByProjectVersionMetadata( session, TEST_METADATA_KEY, TEST_METADATA_VALUE, null );
+ assertThat( artifactsByMetadata ).hasSize( 1 );
+ } );
}
}
@Test
- public void testGetArtifactsByPropertySingleResult()
- throws Exception {
- try (RepositorySession session = sessionFactory.createSession()) {
- createArtifactWithData(session);
+ public void testGetArtifactsByMetadataAllRepositories( )
+ throws Exception
+ {
+ try ( RepositorySession session = getSessionFactory( ).createSession( ) )
+ {
+ createArtifactWithMavenArtifactFacet( session );
+ tryAssert( ( ) -> {
+ Collection<ArtifactMetadata> artifactsByMetadata =
+ getRepository( ).getArtifactsByMetadata( session, "foo", TEST_METADATA_VALUE, null );
+ assertThat( artifactsByMetadata ).hasSize( 1 );
+ ArtifactMetadata artifactMetadata = artifactsByMetadata.iterator( ).next( );
+ assertThat( artifactMetadata.getId( ) ).isEqualTo( TEST_PROJECT + "-" + TEST_PROJECT_VERSION + ".jar" );
+ assertThat( artifactMetadata.getSha1( ) ).isEqualTo( TEST_SHA1 );
+ assertThat( artifactMetadata.getRepositoryId( ) ).isEqualTo( TEST_REPO_ID );
+ MetadataFacet facet = artifactMetadata.getFacet( TEST_FACET_ID );
+ assertThat( facet ).isNotNull( );
+ assertThat( facet.toProperties( ) ).isEqualTo( Collections.singletonMap( "foo", TEST_METADATA_VALUE ) );
+ } );
+ }
+ }
+
+ @Test
+ public void testGetArtifactsByPropertySingleResult( )
+ throws Exception
+ {
+ try ( RepositorySession session = getSessionFactory( ).createSession( ) )
+ {
+ createArtifactWithData( session );
// only works on JCR implementation
- // Collection<ArtifactMetadata> artifactsByProperty = repository.getArtifactsByProperty( "org.name", TEST_ORGANIZATION.getName(), TEST_REPO_ID );
- Collection<ArtifactMetadata> artifactsByProperty = repository.getArtifactsByProperty( session, "url", TEST_URL, TEST_REPO_ID);
- assertThat(artifactsByProperty).hasSize(1);
- ArtifactMetadata artifactMetadata = artifactsByProperty.iterator().next();
- assertThat(artifactMetadata.getId()).isEqualTo("projectId-1.0.jar");
- assertThat(artifactMetadata.getSha1()).isEqualTo(TEST_SHA1);
- assertThat(artifactMetadata.getRepositoryId()).isEqualTo(TEST_REPO_ID);
+ // Collection<ArtifactMetadata> artifactsByProperty = getRepository().getArtifactsByProperty( "org.name", TEST_ORGANIZATION.getName(), TEST_REPO_ID );
+ tryAssert( ( ) -> {
+
+ Collection<ArtifactMetadata> artifactsByProperty = getRepository( ).getArtifactsByProperty( session, "url", TEST_URL, TEST_REPO_ID );
+ assertThat( artifactsByProperty ).hasSize( 1 );
+ ArtifactMetadata artifactMetadata = artifactsByProperty.iterator( ).next( );
+ assertThat( artifactMetadata.getId( ) ).isEqualTo( TEST_PROJECT + "-" + TEST_PROJECT_VERSION + ".jar" );
+ assertThat( artifactMetadata.getSha1( ) ).isEqualTo( TEST_SHA1 );
+ assertThat( artifactMetadata.getRepositoryId( ) ).isEqualTo( TEST_REPO_ID );
+ } );
}
}
@Test
- public void testDeleteRepository()
- throws Exception {
- try (RepositorySession session = sessionFactory.createSession()) {
+ public void testDeleteRepository( )
+ throws Exception
+ {
+ try ( RepositorySession session = getSessionFactory( ).createSession( ) )
+ {
- repository.updateNamespace(session, TEST_REPO_ID, TEST_NAMESPACE);
+ getRepository( ).updateNamespace( session, TEST_REPO_ID, TEST_NAMESPACE );
- ProjectMetadata project1 = new ProjectMetadata();
- project1.setNamespace(TEST_NAMESPACE);
- project1.setId("project1");
- repository.updateProject(session, TEST_REPO_ID, project1);
- ProjectMetadata project2 = new ProjectMetadata();
- project2.setNamespace(TEST_NAMESPACE);
- project2.setId("project2");
- repository.updateProject(session, TEST_REPO_ID, project2);
+ ProjectMetadata project1 = new ProjectMetadata( );
+ project1.setNamespace( TEST_NAMESPACE );
+ project1.setId( "project1" );
+ getRepository( ).updateProject( session, TEST_REPO_ID, project1 );
+ ProjectMetadata project2 = new ProjectMetadata( );
+ project2.setNamespace( TEST_NAMESPACE );
+ project2.setId( "project2" );
+ getRepository( ).updateProject( session, TEST_REPO_ID, project2 );
- ArtifactMetadata artifact1 = createArtifact();
- artifact1.setProject("project1");
- repository.updateArtifact(session, TEST_REPO_ID, TEST_NAMESPACE, "project1", TEST_PROJECT_VERSION, artifact1);
- ArtifactMetadata artifact2 = createArtifact();
- artifact2.setProject("project2");
- repository.updateArtifact(session, TEST_REPO_ID, TEST_NAMESPACE, "project2", TEST_PROJECT_VERSION, artifact2);
- session.save();
+ ArtifactMetadata artifact1 = createArtifact( );
+ artifact1.setProject( "project1" );
+ getRepository( ).updateArtifact( session, TEST_REPO_ID, TEST_NAMESPACE, "project1", TEST_PROJECT_VERSION, artifact1 );
+ ArtifactMetadata artifact2 = createArtifact( );
+ artifact2.setProject( "project2" );
+ getRepository( ).updateArtifact( session, TEST_REPO_ID, TEST_NAMESPACE, "project2", TEST_PROJECT_VERSION, artifact2 );
+ session.save( );
- List<ArtifactMetadata> expected = Arrays.asList(artifact1, artifact2);
- Collections.sort(expected, new ArtifactMetadataComparator());
+ List<ArtifactMetadata> expected = Arrays.asList( artifact1, artifact2 );
+ Collections.sort( expected, new ArtifactMetadataComparator( ) );
- tryAssert(() -> {
+ tryAssert( ( ) -> {
List<ArtifactMetadata> actual =
- new ArrayList<>(repository.getArtifactsByDateRange(session, TEST_REPO_ID, null, null));
- Collections.sort(actual, new ArtifactMetadataComparator());
- assertEquals(expected, actual);
- });
+ new ArrayList<>( getRepository( ).getArtifactsByDateRange( session, TEST_REPO_ID, null, null ) );
+ Collections.sort( actual, new ArtifactMetadataComparator( ) );
+ assertEquals( expected, actual );
+ } );
- repository.removeRepository(session, TEST_REPO_ID);
+ getRepository( ).removeRepository( session, TEST_REPO_ID );
- assertTrue(repository.getArtifacts(session, TEST_REPO_ID).isEmpty());
- assertTrue(repository.getRootNamespaces(session, TEST_REPO_ID).isEmpty());
+ tryAssert( ( ) -> {
+ assertTrue( getRepository( ).getArtifacts( session, TEST_REPO_ID ).isEmpty( ) );
+ assertTrue( getRepository( ).getRootNamespaces( session, TEST_REPO_ID ).isEmpty( ) );
+ } );
}
}
@Test
- public void testDeleteArtifact()
- throws Exception {
- try (RepositorySession session = sessionFactory.createSession()) {
+ public void testDeleteArtifact( )
+ throws Exception
+ {
+ try ( RepositorySession session = getSessionFactory( ).createSession( ) )
+ {
- ArtifactMetadata artifact = createArtifact();
- artifact.addFacet(new TestMetadataFacet("value"));
+ ArtifactMetadata artifact = createArtifact( );
+ artifact.addFacet( new TestMetadataFacet( "value" ) );
- repository.updateArtifact(session, TEST_REPO_ID, TEST_NAMESPACE, TEST_PROJECT, TEST_PROJECT_VERSION, artifact);
+ getRepository( ).updateArtifact( session, TEST_REPO_ID, TEST_NAMESPACE, TEST_PROJECT, TEST_PROJECT_VERSION, artifact );
- assertThat(repository.getArtifacts(session, TEST_REPO_ID, TEST_NAMESPACE,
- TEST_PROJECT, TEST_PROJECT_VERSION)).containsExactly(artifact);
+ assertThat( getRepository( ).getArtifacts( session, TEST_REPO_ID, TEST_NAMESPACE,
+ TEST_PROJECT, TEST_PROJECT_VERSION ) ).containsExactly( artifact );
- repository.updateArtifact(session, TEST_REPO_ID, TEST_NAMESPACE, TEST_PROJECT, TEST_PROJECT_VERSION_2_0, artifact);
+ getRepository( ).updateArtifact( session, TEST_REPO_ID, TEST_NAMESPACE, TEST_PROJECT, TEST_PROJECT_VERSION_2_0, artifact );
- Collection<String> versions = repository.getProjectVersions(session, TEST_REPO_ID, TEST_NAMESPACE, TEST_PROJECT);
+ Collection<String> versions = getRepository( ).getProjectVersions( session, TEST_REPO_ID, TEST_NAMESPACE, TEST_PROJECT );
- log.info("versions {}", versions);
+ log.info( "versions {}", versions );
- assertThat(versions).isNotNull().isNotEmpty().hasSize(2).contains("1.0", "2.0");
+ assertThat( versions ).isNotNull( ).isNotEmpty( ).hasSize( 2 ).contains( "1.0", "2.0" );
- repository.removeArtifact(session, TEST_REPO_ID, TEST_NAMESPACE, TEST_PROJECT, TEST_PROJECT_VERSION, artifact.getId());
+ getRepository( ).removeArtifact( session, TEST_REPO_ID, TEST_NAMESPACE, TEST_PROJECT, TEST_PROJECT_VERSION, artifact.getId( ) );
- versions = repository.getProjectVersions(session, TEST_REPO_ID, TEST_NAMESPACE, TEST_PROJECT);
+ versions = getRepository( ).getProjectVersions( session, TEST_REPO_ID, TEST_NAMESPACE, TEST_PROJECT );
- log.info("versions {}", versions);
+ log.info( "versions {}", versions );
- assertThat(versions).isNotNull().isNotEmpty().hasSize(1).contains("2.0");
+ assertThat( versions ).isNotNull( ).isNotEmpty( ).hasSize( 1 ).contains( "2.0" );
- assertThat(repository.getArtifacts(session, TEST_REPO_ID, TEST_NAMESPACE,
- TEST_PROJECT, TEST_PROJECT_VERSION)).isNotNull().isEmpty();
+ assertThat( getRepository( ).getArtifacts( session, TEST_REPO_ID, TEST_NAMESPACE,
+ TEST_PROJECT, TEST_PROJECT_VERSION ) ).isNotNull( ).isEmpty( );
- assertThat(repository.getArtifacts(session, TEST_REPO_ID, TEST_NAMESPACE,
- TEST_PROJECT, TEST_PROJECT_VERSION_2_0)).isNotEmpty().hasSize(1);
+ assertThat( getRepository( ).getArtifacts( session, TEST_REPO_ID, TEST_NAMESPACE,
+ TEST_PROJECT, TEST_PROJECT_VERSION_2_0 ) ).isNotEmpty( ).hasSize( 1 );
}
}
@Test
- public void deleteArtifact()
- throws Exception {
- try (RepositorySession session = sessionFactory.createSession()) {
- ArtifactMetadata artifact = createArtifact();
- artifact.addFacet(new TestMetadataFacet("value"));
+ public void deleteArtifact( )
+ throws Exception
+ {
+ try ( RepositorySession session = getSessionFactory( ).createSession( ) )
+ {
+ ArtifactMetadata artifact = createArtifact( );
+ artifact.addFacet( new TestMetadataFacet( "value" ) );
- repository.updateArtifact( session, TEST_REPO_ID, TEST_NAMESPACE, TEST_PROJECT, TEST_PROJECT_VERSION, artifact);
+ getRepository( ).updateArtifact( session, TEST_REPO_ID, TEST_NAMESPACE, TEST_PROJECT, TEST_PROJECT_VERSION, artifact );
- repository.updateArtifact( session, TEST_REPO_ID, TEST_NAMESPACE, TEST_PROJECT, TEST_PROJECT_VERSION, artifact);
+ getRepository( ).updateArtifact( session, TEST_REPO_ID, TEST_NAMESPACE, TEST_PROJECT, TEST_PROJECT_VERSION, artifact );
- Collection<ArtifactMetadata> artifacts =
- repository.getArtifacts( session, TEST_REPO_ID, TEST_NAMESPACE, TEST_PROJECT, TEST_PROJECT_VERSION);
+ tryAssert( ( ) -> {
+ Collection<ArtifactMetadata> artifacts =
+ getRepository( ).getArtifacts( session, TEST_REPO_ID, TEST_NAMESPACE, TEST_PROJECT, TEST_PROJECT_VERSION );
- assertEquals(Collections.singletonList(artifact), new ArrayList<>(artifacts));
+ assertEquals( Collections.singletonList( artifact ), new ArrayList<>( artifacts ) );
- repository.removeArtifact( session, TEST_REPO_ID, TEST_NAMESPACE, TEST_PROJECT, TEST_PROJECT_VERSION, artifact.getId());
+ } );
- artifacts = repository.getArtifacts( session, TEST_REPO_ID, TEST_NAMESPACE, TEST_PROJECT, TEST_PROJECT_VERSION);
+ getRepository( ).removeArtifact( session, TEST_REPO_ID, TEST_NAMESPACE, TEST_PROJECT, TEST_PROJECT_VERSION, artifact.getId( ) );
- assertThat(artifacts).isNotNull().isEmpty();
+ tryAssert( ( ) -> {
+ Collection<ArtifactMetadata> artifacts = getRepository( ).getArtifacts( session, TEST_REPO_ID, TEST_NAMESPACE, TEST_PROJECT, TEST_PROJECT_VERSION );
+
+ assertThat( artifacts ).isNotNull( ).isEmpty( );
+ } );
}
}
@Test
- public void deleteVersion()
- throws Exception {
- try (RepositorySession session = sessionFactory.createSession()) {
- ArtifactMetadata artifact = createArtifact();
- artifact.addFacet(new TestMetadataFacet("value"));
+ public void deleteVersion( )
+ throws Exception
+ {
+ try ( RepositorySession session = getSessionFactory( ).createSession( ) )
+ {
+ ArtifactMetadata artifact = createArtifact( );
+ artifact.addFacet( new TestMetadataFacet( "value" ) );
+
+ getRepository( ).updateArtifact( session, TEST_REPO_ID, TEST_NAMESPACE, TEST_PROJECT, TEST_PROJECT_VERSION, artifact );
- repository.updateArtifact( session, TEST_REPO_ID, TEST_NAMESPACE, TEST_PROJECT, TEST_PROJECT_VERSION, artifact);
+ getRepository( ).updateArtifact( session, TEST_REPO_ID, TEST_NAMESPACE, TEST_PROJECT, TEST_PROJECT_VERSION, artifact );
- repository.updateArtifact( session, TEST_REPO_ID, TEST_NAMESPACE, TEST_PROJECT, TEST_PROJECT_VERSION, artifact);
+ tryAssert( ( ) -> {
- Collection<String> versions = repository.getProjectVersions( session, TEST_REPO_ID, TEST_NAMESPACE, TEST_PROJECT);
+ Collection<String> versions = getRepository( ).getProjectVersions( session, TEST_REPO_ID, TEST_NAMESPACE, TEST_PROJECT );
- assertThat(versions).isNotNull().isNotEmpty().hasSize(1);
+ assertThat( versions ).isNotNull( ).isNotEmpty( ).hasSize( 1 );
+ } );
- repository.removeProjectVersion( session, TEST_REPO_ID, TEST_NAMESPACE, TEST_PROJECT, TEST_PROJECT_VERSION);
+ getRepository( ).removeProjectVersion( session, TEST_REPO_ID, TEST_NAMESPACE, TEST_PROJECT, TEST_PROJECT_VERSION );
- versions = repository.getProjectVersions( session, TEST_REPO_ID, TEST_NAMESPACE, TEST_PROJECT);
+ tryAssert( ( ) -> {
- assertThat(versions).isNotNull().isEmpty();
+ Collection<String> versions1 = getRepository( ).getProjectVersions( session, TEST_REPO_ID, TEST_NAMESPACE, TEST_PROJECT );
+ assertThat( versions1 ).isNotNull( ).isEmpty( );
+ } );
}
}
@Test
- public void deleteProject()
- throws Exception {
- try (RepositorySession session = sessionFactory.createSession()) {
- ArtifactMetadata artifact = createArtifact();
- artifact.addFacet(new TestMetadataFacet("value"));
+ public void deleteProject( )
+ throws Exception
+ {
+ try ( RepositorySession session = getSessionFactory( ).createSession( ) )
+ {
+ ArtifactMetadata artifact = createArtifact( );
+ artifact.addFacet( new TestMetadataFacet( "value" ) );
- repository.updateArtifact( session, TEST_REPO_ID, TEST_NAMESPACE, TEST_PROJECT, TEST_PROJECT_VERSION, artifact);
+ getRepository( ).updateArtifact( session, TEST_REPO_ID, TEST_NAMESPACE, TEST_PROJECT, TEST_PROJECT_VERSION, artifact );
- repository.updateArtifact( session, TEST_REPO_ID, TEST_NAMESPACE, TEST_PROJECT, TEST_PROJECT_VERSION, artifact);
+ getRepository( ).updateArtifact( session, TEST_REPO_ID, TEST_NAMESPACE, TEST_PROJECT, TEST_PROJECT_VERSION, artifact );
- assertEquals(1, repository.getProjectVersions( session, TEST_REPO_ID, TEST_NAMESPACE, TEST_PROJECT).size());
+ assertEquals( 1, getRepository( ).getProjectVersions( session, TEST_REPO_ID, TEST_NAMESPACE, TEST_PROJECT ).size( ) );
- repository.removeProject( session, TEST_REPO_ID, TEST_NAMESPACE, TEST_PROJECT);
+ getRepository( ).removeProject( session, TEST_REPO_ID, TEST_NAMESPACE, TEST_PROJECT );
- Collection<String> versions = repository.getProjectVersions( session, TEST_REPO_ID, TEST_NAMESPACE, TEST_PROJECT);
+ Collection<String> versions = getRepository( ).getProjectVersions( session, TEST_REPO_ID, TEST_NAMESPACE, TEST_PROJECT );
- assertThat(versions).isNotNull().isEmpty();
+ assertThat( versions ).isNotNull( ).isEmpty( );
}
}
@Test
- public void deleteSnapshotVersion()
- throws Exception {
- try (RepositorySession session = sessionFactory.createSession()) {
+ public void deleteSnapshotVersion( )
+ throws Exception
+ {
+ try ( RepositorySession session = getSessionFactory( ).createSession( ) )
+ {
- ArtifactMetadata artifactOne = createArtifact();
- artifactOne.setVersion("2.0-20120618.214127-1");
- artifactOne.setProjectVersion("2.0-SNAPSHOT");
- artifactOne.addFacet(new TestMetadataFacet("value"));
- artifactOne.setId(TEST_PROJECT + "-" + "2.0-20120618.214127-1" + "." + "jar");
+ ArtifactMetadata artifactOne = createArtifact( );
+ artifactOne.setVersion( "2.0-20120618.214127-1" );
+ artifactOne.setProjectVersion( "2.0-SNAPSHOT" );
+ artifactOne.addFacet( new TestMetadataFacet( "value" ) );
+ artifactOne.setId( TEST_PROJECT + "-" + "2.0-20120618.214127-1" + "." + "jar" );
- repository.updateArtifact(session, TEST_REPO_ID, TEST_NAMESPACE, TEST_PROJECT, "2.0-SNAPSHOT", artifactOne);
+ getRepository( ).updateArtifact( session, TEST_REPO_ID, TEST_NAMESPACE, TEST_PROJECT, "2.0-SNAPSHOT", artifactOne );
- ArtifactMetadata artifactTwo = createArtifact();
- artifactTwo.setVersion("2.0-20120618.214135-2");
- artifactTwo.setProjectVersion("2.0-SNAPSHOT");
- artifactTwo.addFacet(new TestMetadataFacet("value"));
- artifactTwo.setId(TEST_PROJECT + "-" + "2.0-20120618.214135-2" + "." + "jar");
+ ArtifactMetadata artifactTwo = createArtifact( );
+ artifactTwo.setVersion( "2.0-20120618.214135-2" );
+ artifactTwo.setProjectVersion( "2.0-SNAPSHOT" );
+ artifactTwo.addFacet( new TestMetadataFacet( "value" ) );
+ artifactTwo.setId( TEST_PROJECT + "-" + "2.0-20120618.214135-2" + "." + "jar" );
- repository.updateArtifact(session, TEST_REPO_ID, TEST_NAMESPACE, TEST_PROJECT, "2.0-SNAPSHOT", artifactTwo);
+ getRepository( ).updateArtifact( session, TEST_REPO_ID, TEST_NAMESPACE, TEST_PROJECT, "2.0-SNAPSHOT", artifactTwo );
Collection<ArtifactMetadata> artifactMetadatas =
- repository.getArtifacts(session, TEST_REPO_ID, TEST_NAMESPACE, TEST_PROJECT, "2.0-SNAPSHOT");
+ getRepository( ).getArtifacts( session, TEST_REPO_ID, TEST_NAMESPACE, TEST_PROJECT, "2.0-SNAPSHOT" );
- assertThat(artifactMetadatas).isNotNull().isNotEmpty().hasSize(2);
+ assertThat( artifactMetadatas ).isNotNull( ).isNotEmpty( ).hasSize( 2 );
- log.info("artifactMetadatas: {}", artifactMetadatas);
+ log.info( "artifactMetadatas: {}", artifactMetadatas );
- repository.removeArtifact(session, artifactOne, "2.0-SNAPSHOT");
+ getRepository( ).removeArtifact( session, artifactOne, "2.0-SNAPSHOT" );
- artifactMetadatas = repository.getArtifacts(session, TEST_REPO_ID, TEST_NAMESPACE, TEST_PROJECT, "2.0-SNAPSHOT");
+ artifactMetadatas = getRepository( ).getArtifacts( session, TEST_REPO_ID, TEST_NAMESPACE, TEST_PROJECT, "2.0-SNAPSHOT" );
- assertThat(artifactMetadatas).isNotNull().isNotEmpty().hasSize(1);
+ assertThat( artifactMetadatas ).isNotNull( ).isNotEmpty( ).hasSize( 1 );
- repository.removeArtifact(session, artifactTwo, "2.0-SNAPSHOT");
+ getRepository( ).removeArtifact( session, artifactTwo, "2.0-SNAPSHOT" );
- artifactMetadatas = repository.getArtifacts(session, TEST_REPO_ID, TEST_NAMESPACE, TEST_PROJECT, "2.0-SNAPSHOT");
+ artifactMetadatas = getRepository( ).getArtifacts( session, TEST_REPO_ID, TEST_NAMESPACE, TEST_PROJECT, "2.0-SNAPSHOT" );
- assertThat(artifactMetadatas).isNotNull().isEmpty();
+ assertThat( artifactMetadatas ).isNotNull( ).isEmpty( );
}
}
@Test
- public void testgetProjectReferences()
- throws Exception {
- try (RepositorySession session = sessionFactory.createSession()) {
+ public void testgetProjectReferences( )
+ throws Exception
+ {
+ try ( RepositorySession session = getSessionFactory( ).createSession( ) )
+ {
- ProjectVersionMetadata metadata = new ProjectVersionMetadata();
- metadata.setId(TEST_PROJECT_VERSION);
+ ProjectVersionMetadata metadata = new ProjectVersionMetadata( );
+ metadata.setId( TEST_PROJECT_VERSION );
- metadata.setName("project name");
- metadata.setDescription("project description");
- metadata.setUrl("the url");
+ metadata.setName( "project name" );
+ metadata.setDescription( "project description" );
+ metadata.setUrl( "the url" );
- Dependency d = new Dependency();
- d.setArtifactId("artifactId");
- d.setClassifier("classifier");
- d.setGroupId("groupId");
- d.setScope("scope");
- d.setSystemPath("system path");
- d.setType("type");
- d.setVersion("version");
- d.setOptional(true);
- metadata.addDependency(d);
+ Dependency d = new Dependency( );
+ d.setArtifactId( "artifactId" );
+ d.setClassifier( "classifier" );
+ d.setGroupId( "groupId" );
+ d.setScope( "scope" );
+ d.setSystemPath( "system path" );
+ d.setType( "type" );
+ d.setVersion( "version" );
+ d.setOptional( true );
+ metadata.addDependency( d );
- d = new Dependency();
- d.setArtifactId("artifactId1");
- d.setClassifier("classifier");
- d.setGroupId("groupId");
- d.setScope("scope");
- d.setSystemPath("system path");
- d.setType("type");
- d.setVersion("version1");
- d.setOptional(true);
- metadata.addDependency(d);
+ d = new Dependency( );
+ d.setArtifactId( "artifactId1" );
+ d.setClassifier( "classifier" );
+ d.setGroupId( "groupId" );
+ d.setScope( "scope" );
+ d.setSystemPath( "system path" );
+ d.setType( "type" );
+ d.setVersion( "version1" );
+ d.setOptional( true );
+ metadata.addDependency( d );
- repository.updateProjectVersion(session, TEST_REPO_ID, TEST_NAMESPACE, TEST_PROJECT, metadata);
+ getRepository( ).updateProjectVersion( session, TEST_REPO_ID, TEST_NAMESPACE, TEST_PROJECT, metadata );
- session.save();
+ session.save( );
- metadata = repository.getProjectVersion(session, TEST_REPO_ID, TEST_NAMESPACE, TEST_PROJECT, TEST_PROJECT_VERSION);
+ metadata = getRepository( ).getProjectVersion( session, TEST_REPO_ID, TEST_NAMESPACE, TEST_PROJECT, TEST_PROJECT_VERSION );
+ final Dependency dd = d;
- Collection<ProjectVersionReference> references =
- repository.getProjectReferences(session, TEST_REPO_ID, d.getGroupId(), d.getArtifactId(), d.getVersion());
- log.info("references: {}", references);
+ tryAssert( ( ) -> {
- assertThat(references).isNotNull().hasSize(1).contains(
- new ProjectVersionReference(ProjectVersionReference.ReferenceType.DEPENDENCY, TEST_PROJECT, TEST_NAMESPACE,
- TEST_PROJECT_VERSION));
+ Collection<ProjectVersionReference> references =
+ getRepository( ).getProjectReferences( session, TEST_REPO_ID, dd.getGroupId( ), dd.getArtifactId( ), dd.getVersion( ) );
+ log.info( "references: {}", references );
+ assertThat( references ).isNotNull( ).hasSize( 1 ).contains(
+ new ProjectVersionReference( ProjectVersionReference.ReferenceType.DEPENDENCY, TEST_PROJECT, TEST_NAMESPACE,
+ TEST_PROJECT_VERSION ));
+ }
+ );
}
}
@Test
- public void testSearchArtifactsByKey()
- throws Exception {
- try (RepositorySession session = sessionFactory.createSession()) {
- createArtifactWithData(session);
- session.refreshAndDiscard();
- Collection<ArtifactMetadata> artifactsByProperty = repository.searchArtifacts( session, TEST_REPO_ID, "url", TEST_URL, false);
- assertThat(artifactsByProperty).isNotNull().isNotEmpty();
+ public void testSearchArtifactsByKey( )
+ throws Exception
+ {
+ try ( RepositorySession session = getSessionFactory( ).createSession( ) )
+ {
+ createArtifactWithData( session );
+ }
+ try ( RepositorySession session = getSessionFactory( ).createSession( ) )
+ {
+ session.refreshAndDiscard( );
+ tryAssert( ( ) -> {
+ Collection<ArtifactMetadata> artifactsByProperty = getRepository( ).searchArtifacts( session, TEST_REPO_ID, "url", TEST_URL, false );
+ assertThat( artifactsByProperty ).isNotNull( ).isNotEmpty( );
+ } );
}
}
@Test
- public void testSearchArtifactsByKeyExact()
- throws Exception {
- try (RepositorySession session = sessionFactory.createSession()) {
- createArtifactWithData(session);
- Collection<ArtifactMetadata> artifactsByProperty = repository.searchArtifacts( session, TEST_REPO_ID, "url", TEST_URL, true);
- assertThat(artifactsByProperty).isNotNull().isNotEmpty();
- artifactsByProperty = repository.searchArtifacts( session, TEST_REPO_ID, "org.name", "pache", true);
- assertThat(artifactsByProperty).isNotNull().isEmpty();
-
+ public void testSearchArtifactsByKeyExact( )
+ throws Exception
+ {
+ try ( RepositorySession session = getSessionFactory( ).createSession( ) )
+ {
+ createArtifactWithData( session );
+ }
+ try ( RepositorySession session = getSessionFactory( ).createSession( ) )
+ {
+ session.refreshAndDiscard( );
+ tryAssert( ( ) -> {
+ Collection<ArtifactMetadata> artifactsByProperty = getRepository( ).searchArtifacts( session, TEST_REPO_ID, "url", TEST_URL, true );
+ assertThat( artifactsByProperty ).describedAs( "Artifact search by url=%s must give a result.", TEST_URL ).isNotNull( ).isNotEmpty( );
+ artifactsByProperty = getRepository( ).searchArtifacts( session, TEST_REPO_ID, "org.name", "pache", true );
+ assertThat( artifactsByProperty ).describedAs( "Artifact search by text org.name='pache' must be empty" ).isNotNull( ).isEmpty( );
+ } );
}
}
@Test
- public void testSearchArtifactsByFacetKey()
- throws Exception {
- try (RepositorySession session = sessionFactory.createSession()) {
- createArtifactWithGenericMetadataFacet(session);
- }
- // Thread.currentThread().sleep(5000);
- try (RepositorySession session = sessionFactory.createSession()) {
- session.refresh();
- System.out.println(repository.getRootNamespaces(session, TEST_REPO_ID));
-
- Collection<ArtifactMetadata> artifactsByProperty = repository.searchArtifacts( session, TEST_REPO_ID, TEST_METADATA_KEY, TEST_METADATA_VALUE, false);
- assertThat(artifactsByProperty).isNotNull().isNotEmpty();
+ public void testSearchArtifactsByFacetKey( )
+ throws Exception
+ {
+ try ( RepositorySession session = getSessionFactory( ).createSession( ) )
+ {
+ createArtifactWithGenericMetadataFacet( session );
+ tryAssert( ( ) -> {
+ Collection<ArtifactMetadata> artifactsByProperty = getRepository( ).searchArtifacts( session, TEST_REPO_ID, TEST_METADATA_KEY, TEST_METADATA_VALUE, false );
+ assertThat( artifactsByProperty ).isNotNull( ).isNotEmpty( );
+ } );
}
}
@Test
- public void testSearchArtifactsByFacetKeyAllRepos()
- throws Exception {
- try (RepositorySession session = sessionFactory.createSession()) {
+ public void testSearchArtifactsByFacetKeyAllRepos( )
+ throws Exception
+ {
+ try ( RepositorySession session = getSessionFactory( ).createSession( ) )
+ {
- createArtifactWithGenericMetadataFacet(session);
- tryAssert(() -> {
- Collection<ArtifactMetadata> artifactsByProperty = repository.searchArtifacts(session, null, TEST_METADATA_KEY, TEST_METADATA_VALUE, false);
- assertThat(artifactsByProperty).isNotNull().isNotEmpty();
- });
+ createArtifactWithGenericMetadataFacet( session );
+ tryAssert( ( ) -> {
+ Collection<ArtifactMetadata> artifactsByProperty = getRepository( ).searchArtifacts( session, null, TEST_METADATA_KEY, TEST_METADATA_VALUE, false );
+ assertThat( artifactsByProperty ).isNotNull( ).isNotEmpty( );
+ } );
}
}
@Test
- public void testSearchArtifactsFullText()
- throws Exception {
- try (RepositorySession session = sessionFactory.createSession()) {
- createArtifactWithGenericMetadataFacet(session);
+ public void testSearchArtifactsFullText( )
+ throws Exception
+ {
+ try ( RepositorySession session = getSessionFactory( ).createSession( ) )
+ {
+ createArtifactWithGenericMetadataFacet( session );
// only works in JCR
- // Collection<ArtifactMetadata> artifactsByProperty = repository.searchArtifacts( TEST_URL, TEST_REPO_ID, false );
- Collection<ArtifactMetadata> artifactsByProperty =
- repository.searchArtifacts( session, TEST_REPO_ID, TEST_METADATA_VALUE, false);
- assertThat(artifactsByProperty).isNotNull().isNotEmpty();
+ // Collection<ArtifactMetadata> artifactsByProperty = getRepository().searchArtifacts( TEST_URL, TEST_REPO_ID, false );
+ tryAssert( ( ) -> {
+ Collection<ArtifactMetadata> artifactsByProperty =
+ getRepository( ).searchArtifacts( session, TEST_REPO_ID, TEST_METADATA_VALUE, false );
+ assertThat( artifactsByProperty ).isNotNull( ).isNotEmpty( );
+ } );
}
}
@Test
- public void testSearchArtifactsFullTextExact()
- throws Exception {
- try (RepositorySession session = sessionFactory.createSession()) {
- createArtifactWithGenericMetadataFacet(session);
+ public void testSearchArtifactsFullTextExact( )
+ throws Exception
+ {
+ try ( RepositorySession session = getSessionFactory( ).createSession( ) )
+ {
+ createArtifactWithGenericMetadataFacet( session );
// only works in JCR
- // Collection<ArtifactMetadata> artifactsByProperty = repository.searchArtifacts( TEST_URL, TEST_REPO_ID, true );
- Collection<ArtifactMetadata> artifactsByProperty =
- repository.searchArtifacts( session, TEST_REPO_ID, TEST_METADATA_VALUE, true);
- assertThat(artifactsByProperty).isNotNull().isNotEmpty();
- artifactsByProperty = repository.searchArtifacts( session, TEST_REPO_ID, TEST_METADATA_VALUE.substring(2), true);
- assertThat(artifactsByProperty).isNotNull().isEmpty();
+ // Collection<ArtifactMetadata> artifactsByProperty = getRepository().searchArtifacts( TEST_URL, TEST_REPO_ID, true );
+
+ tryAssert( ( ) -> {
+ Collection<ArtifactMetadata> artifactsByProperty =
+ getRepository( ).searchArtifacts( session, TEST_REPO_ID, TEST_METADATA_VALUE, true );
+ assertThat( artifactsByProperty ).isNotNull( ).isNotEmpty( );
+ } );
+ tryAssert( ( ) -> {
+ Collection<ArtifactMetadata> artifactsByProperty = getRepository( ).searchArtifacts( session, TEST_REPO_ID, TEST_METADATA_VALUE.substring( 2 ), true );
+ assertThat( artifactsByProperty ).isNotNull( ).isEmpty( );
+ } );
}
}
@Test
- public void testSearchArtifactsFullTextByFacet()
- throws Exception {
- try (RepositorySession session = sessionFactory.createSession()) {
- createArtifactWithGenericMetadataFacet(session);
- Collection<ArtifactMetadata> artifactsByProperty = repository.searchArtifacts( session, TEST_REPO_ID, TEST_METADATA_VALUE, false);
- assertThat(artifactsByProperty).isNotNull().isNotEmpty();
-
+ public void testSearchArtifactsFullTextByFacet( )
+ throws Exception
+ {
+ try ( RepositorySession session = getSessionFactory( ).createSession( ) )
+ {
+ createArtifactWithGenericMetadataFacet( session );
+ tryAssert( ( ) -> {
+ Collection<ArtifactMetadata> artifactsByProperty = getRepository( ).searchArtifacts( session, TEST_REPO_ID, TEST_METADATA_VALUE, false );
+ assertThat( artifactsByProperty ).isNotNull( ).isNotEmpty( );
+ } );
+
}
}
- private static ProjectMetadata createProject() {
- return createProject(TEST_NAMESPACE);
+ private static ProjectMetadata createProject( )
+ {
+ return createProject( TEST_NAMESPACE );
}
- private static ProjectMetadata createProject(String ns) {
- ProjectMetadata project = new ProjectMetadata();
- project.setId(TEST_PROJECT);
- project.setNamespace(ns);
+ private static ProjectMetadata createProject( String ns )
+ {
+ ProjectMetadata project = new ProjectMetadata( );
+ project.setId( TEST_PROJECT );
+ project.setNamespace( ns );
return project;
}
- private void createArtifactWithGenericMetadataFacet(RepositorySession session)
- throws MetadataRepositoryException, MetadataResolutionException, MetadataSessionException {
- createArtifactWithGenericMetadataFacet( session,1);
+ private void createArtifactWithGenericMetadataFacet( RepositorySession session )
+ throws MetadataRepositoryException, MetadataResolutionException, MetadataSessionException
+ {
+ createArtifactWithGenericMetadataFacet( session, 1 );
}
- private void createArtifactWithGenericMetadataFacet(RepositorySession session, int artifacts)
- throws MetadataRepositoryException, MetadataResolutionException, MetadataSessionException {
- MetadataFacet metadataFacet = new GenericMetadataFacet();
- Map<String, String> properties = new HashMap<>();
- properties.put(TEST_METADATA_KEY, TEST_METADATA_VALUE);
- metadataFacet.fromProperties(properties);
- createArtifactWithFacet(session, artifacts, null, metadataFacet);
+ private void createArtifactWithGenericMetadataFacet( RepositorySession session, int artifacts )
+ throws MetadataRepositoryException, MetadataResolutionException, MetadataSessionException
+ {
+ MetadataFacet metadataFacet = new GenericMetadataFacet( );
+ Map<String, String> properties = new HashMap<>( );
+ properties.put( TEST_METADATA_KEY, TEST_METADATA_VALUE );
+ metadataFacet.fromProperties( properties );
+ createArtifactWithFacet( session, artifacts, null, metadataFacet );
}
- private void createArtifactWithMavenArtifactFacet(RepositorySession session)
- throws MetadataRepositoryException, MetadataResolutionException, MetadataSessionException {
- createArtifactWithMavenArtifactFacet(session, 1);
+ private void createArtifactWithMavenArtifactFacet( RepositorySession session )
+ throws MetadataRepositoryException, MetadataResolutionException, MetadataSessionException
+ {
+ createArtifactWithMavenArtifactFacet( session, 1 );
}
- private void createArtifactWithMavenArtifactFacet(RepositorySession session, int artifacts)
- throws MetadataRepositoryException, MetadataResolutionException, MetadataSessionException {
- TestMetadataFacet facet = new TestMetadataFacet(TEST_METADATA_VALUE);
- createArtifactWithFacet(session, artifacts, facet, null);
+ private void createArtifactWithMavenArtifactFacet( RepositorySession session, int artifacts )
+ throws MetadataRepositoryException, MetadataResolutionException, MetadataSessionException
+ {
+ TestMetadataFacet facet = new TestMetadataFacet( TEST_METADATA_VALUE );
+ createArtifactWithFacet( session, artifacts, facet, null );
}
- private void createArtifactWithFacet(RepositorySession session, int artifacts, MetadataFacet artifactFacet,
- MetadataFacet projectVersionMetadataFacet)
- throws MetadataRepositoryException, MetadataResolutionException, MetadataSessionException {
- for (int i = 0; i < artifacts; i++) {
- ArtifactMetadata artifact = createArtifact();
- if (artifactFacet != null) {
- artifact.addFacet(artifactFacet);
- }
- repository.updateArtifact(session, TEST_REPO_ID, TEST_NAMESPACE, TEST_PROJECT, TEST_PROJECT_VERSION, artifact);
- }
- if (projectVersionMetadataFacet != null) {
- ProjectVersionMetadata metadata =
- repository.getProjectVersion(session, TEST_REPO_ID, TEST_NAMESPACE, TEST_PROJECT, TEST_PROJECT_VERSION);
- metadata.addFacet(projectVersionMetadataFacet);
- metadata.setOrganization(TEST_ORGANIZATION);
- metadata.setUrl(TEST_URL);
- repository.updateProjectVersion(session, TEST_REPO_ID, TEST_NAMESPACE, TEST_PROJECT, metadata);
+ private void createArtifactWithFacet( RepositorySession session, int artifacts, MetadataFacet artifactFacet,
+ MetadataFacet projectVersionMetadataFacet )
+ throws MetadataRepositoryException, MetadataResolutionException, MetadataSessionException
+ {
+ for ( int i = 0; i < artifacts; i++ )
+ {
+ ArtifactMetadata artifact = createArtifact( );
+ if ( artifactFacet != null )
+ {
+ artifact.addFacet( artifactFacet );
}
- session.save();
- }
-
- private void createArtifactWithData(RepositorySession session)
- throws MetadataRepositoryException, MetadataResolutionException, MetadataSessionException {
- ArtifactMetadata artifact = createArtifact();
- repository.updateArtifact(session, TEST_REPO_ID, TEST_NAMESPACE, TEST_PROJECT, TEST_PROJECT_VERSION, artifact);
+ getRepository( ).updateArtifact( session, TEST_REPO_ID, TEST_NAMESPACE, TEST_PROJECT, TEST_PROJECT_VERSION, artifact );
+ }
+ if ( projectVersionMetadataFacet != null )
+ {
ProjectVersionMetadata metadata =
- repository.getProjectVersion(session, TEST_REPO_ID, TEST_NAMESPACE, TEST_PROJECT, TEST_PROJECT_VERSION);
- metadata.setOrganization(TEST_ORGANIZATION);
- metadata.setUrl(TEST_URL);
-
- repository.updateProjectVersion(session, TEST_REPO_ID, TEST_NAMESPACE, TEST_PROJECT, metadata);
- session.save();
- }
-
- private static ArtifactMetadata createArtifact() {
- return createArtifact("jar");
- }
-
- private static ArtifactMetadata createArtifact(String type) {
- ArtifactMetadata artifact = new ArtifactMetadata();
- artifact.setId(TEST_PROJECT + "-" + TEST_PROJECT_VERSION + "." + type);
- artifact.setWhenGathered(new Date());
- artifact.setNamespace(TEST_NAMESPACE);
- artifact.setProject(TEST_PROJECT);
- artifact.setRepositoryId(TEST_REPO_ID);
- artifact.setFileLastModified(System.currentTimeMillis());
- artifact.setVersion(TEST_PROJECT_VERSION);
- artifact.setProjectVersion(TEST_PROJECT_VERSION);
- artifact.setMd5(TEST_MD5);
- artifact.setSha1(TEST_SHA1);
+ getRepository( ).getProjectVersion( session, TEST_REPO_ID, TEST_NAMESPACE, TEST_PROJECT, TEST_PROJECT_VERSION );
+ metadata.addFacet( projectVersionMetadataFacet );
+ metadata.setOrganization( TEST_ORGANIZATION );
+ metadata.setUrl( TEST_URL );
+ getRepository( ).updateProjectVersion( session, TEST_REPO_ID, TEST_NAMESPACE, TEST_PROJECT, metadata );
+ }
+ session.save( );
+ }
+
+ protected void createArtifactWithData( RepositorySession session )
+ throws MetadataRepositoryException, MetadataResolutionException, MetadataSessionException
+ {
+ ArtifactMetadata artifact = createArtifact( );
+ getRepository( ).updateArtifact( session, TEST_REPO_ID, TEST_NAMESPACE, TEST_PROJECT, TEST_PROJECT_VERSION, artifact );
+ ProjectVersionMetadata metadata =
+ getRepository( ).getProjectVersion( session, TEST_REPO_ID, TEST_NAMESPACE, TEST_PROJECT, TEST_PROJECT_VERSION );
+ metadata.setOrganization( TEST_ORGANIZATION );
+ metadata.setUrl( TEST_URL );
+
+ getRepository( ).updateProjectVersion( session, TEST_REPO_ID, TEST_NAMESPACE, TEST_PROJECT, metadata );
+ session.save( );
+ }
+
+ private static ArtifactMetadata createArtifact( )
+ {
+ return createArtifact( "jar" );
+ }
+
+ private static ArtifactMetadata createArtifact( String type )
+ {
+ ArtifactMetadata artifact = new ArtifactMetadata( );
+ artifact.setId( TEST_PROJECT + "-" + TEST_PROJECT_VERSION + "." + type );
+ artifact.setWhenGathered( new Date( ) );
+ artifact.setNamespace( TEST_NAMESPACE );
+ artifact.setProject( TEST_PROJECT );
+ artifact.setRepositoryId( TEST_REPO_ID );
+ artifact.setFileLastModified( System.currentTimeMillis( ) );
+ artifact.setVersion( TEST_PROJECT_VERSION );
+ artifact.setProjectVersion( TEST_PROJECT_VERSION );
+ artifact.setMd5( TEST_MD5 );
+ artifact.setSha1( TEST_SHA1 );
return artifact;
}
private static class ArtifactMetadataComparator
- implements Comparator<ArtifactMetadata> {
+ implements Comparator<ArtifactMetadata>
+ {
@Override
- public final int compare(ArtifactMetadata a, ArtifactMetadata b) {
- return a.getProject().compareTo(b.getProject());
+ public final int compare( ArtifactMetadata a, ArtifactMetadata b )
+ {
+ return a.getProject( ).compareTo( b.getProject( ) );
}
}
private static class KindOfRepositoryStatistics
- implements MetadataFacet {
+ implements MetadataFacet
+ {
private String value;
private Date date;
static final String SCAN_TIMESTAMP_FORMAT = "yyyy/MM/dd/HHmmss.SSS";
- private static final TimeZone UTC_TIME_ZONE = TimeZone.getTimeZone("UTC");
+ private static final TimeZone UTC_TIME_ZONE = TimeZone.getTimeZone( "UTC" );
- private KindOfRepositoryStatistics(String value, Date date) {
+ private KindOfRepositoryStatistics( String value, Date date )
+ {
this.value = value;
this.date = date;
}
@Override
- public String getName() {
- return createNameFormat().format(date);
+ public String getName( )
+ {
+ return createNameFormat( ).format( date );
}
- private static SimpleDateFormat createNameFormat() {
- SimpleDateFormat fmt = new SimpleDateFormat(SCAN_TIMESTAMP_FORMAT);
- fmt.setTimeZone(UTC_TIME_ZONE);
+ private static SimpleDateFormat createNameFormat( )
+ {
+ SimpleDateFormat fmt = new SimpleDateFormat( SCAN_TIMESTAMP_FORMAT );
+ fmt.setTimeZone( UTC_TIME_ZONE );
return fmt;
}
@Override
- public String getFacetId() {
- return KindOfRepositoryStatistics.class.getName();
+ public String getFacetId( )
+ {
+ return KindOfRepositoryStatistics.class.getName( );
}
@Override
- public Map<String, String> toProperties() {
- return Collections.emptyMap();
+ public Map<String, String> toProperties( )
+ {
+ return Collections.emptyMap( );
}
@Override
- public void fromProperties(Map<String, String> properties) {
+ public void fromProperties( Map<String, String> properties )
+ {
// no op
}
}
private static class TestMetadataFacet
- implements MetadataFacet {
+ implements MetadataFacet
+ {
private String testFacetId;
private Map<String, String> additionalProps;
private String value;
- private TestMetadataFacet(String value) {
+ private TestMetadataFacet( String value )
+ {
this.value = value;
testFacetId = TEST_FACET_ID;
}
- private TestMetadataFacet(String facetId, String value) {
+ private TestMetadataFacet( String facetId, String value )
+ {
this.value = value;
testFacetId = facetId;
}
- private TestMetadataFacet(String facetId, String value, Map<String, String> additionalProps) {
- this(facetId, value);
+ private TestMetadataFacet( String facetId, String value, Map<String, String> additionalProps )
+ {
+ this( facetId, value );
this.additionalProps = additionalProps;
}
@Override
- public String getFacetId() {
+ public String getFacetId( )
+ {
return testFacetId;
}
@Override
- public String getName() {
+ public String getName( )
+ {
return TEST_NAME;
}
@Override
- public Map<String, String> toProperties() {
- if (value != null) {
- if (additionalProps == null) {
- return Collections.singletonMap("foo", value);
- } else {
- Map<String, String> props = new HashMap<>();
- props.put("foo", value);
-
- for (String key : additionalProps.keySet()) {
- props.put(key, additionalProps.get(key));
+ public Map<String, String> toProperties( )
+ {
+ if ( value != null )
+ {
+ if ( additionalProps == null )
+ {
+ return Collections.singletonMap( "foo", value );
+ }
+ else
+ {
+ Map<String, String> props = new HashMap<>( );
+ props.put( "foo", value );
+
+ for ( String key : additionalProps.keySet( ) )
+ {
+ props.put( key, additionalProps.get( key ) );
}
return props;
}
- } else {
- return Collections.emptyMap();
+ }
+ else
+ {
+ return Collections.emptyMap( );
}
}
@Override
- public void fromProperties(Map<String, String> properties) {
- String value = properties.get("foo");
- if (value != null) {
+ public void fromProperties( Map<String, String> properties )
+ {
+ String value = properties.get( "foo" );
+ if ( value != null )
+ {
this.value = value;
}
- properties.remove("foo");
+ properties.remove( "foo" );
- if (additionalProps == null) {
- additionalProps = new HashMap<>();
+ if ( additionalProps == null )
+ {
+ additionalProps = new HashMap<>( );
}
- for (String key : properties.keySet()) {
- additionalProps.put(key, properties.get(key));
+ for ( String key : properties.keySet( ) )
+ {
+ additionalProps.put( key, properties.get( key ) );
}
}
- public String getValue() {
+ public String getValue( )
+ {
return value;
}
@Override
- public String toString() {
+ public String toString( )
+ {
return "TestMetadataFacet{" + "value='" + value + '\'' + '}';
}
@Override
- public boolean equals(Object o) {
- if (this == o) {
+ public boolean equals( Object o )
+ {
+ if ( this == o )
+ {
return true;
}
- if (o == null || getClass() != o.getClass()) {
+ if ( o == null || getClass( ) != o.getClass( ) )
+ {
return false;
}
TestMetadataFacet that = (TestMetadataFacet) o;
- if (value != null ? !value.equals(that.value) : that.value != null) {
+ if ( value != null ? !value.equals( that.value ) : that.value != null )
+ {
return false;
}
}
@Override
- public int hashCode() {
- return value != null ? value.hashCode() : 0;
+ public int hashCode( )
+ {
+ return value != null ? value.hashCode( ) : 0;
}
}
}