private JUnit4Mockery context = new JUnit4Mockery();
@Test
public void testAddArtifacts() {
final PublishArtifact publishArtifactConf1 = createNamedPublishArtifact("conf1");
Configuration configurationStub1 = createConfigurationStub(publishArtifactConf1);
final PublishArtifact publishArtifactConf2 = createNamedPublishArtifact("conf2");
Configuration configurationStub2 = createConfigurationStub(publishArtifactConf2);
final ArtifactsExtraAttributesStrategy artifactsExtraAttributesStrategyMock = context.mock(ArtifactsExtraAttributesStrategy.class);
final Map<String, String> extraAttributesArtifact1 = WrapUtil.toMap("name", publishArtifactConf1.getName());
final Map<String, String> extraAttributesArtifact2 = WrapUtil.toMap("name", publishArtifactConf2.getName());
context.checking(new Expectations() {{
one(artifactsExtraAttributesStrategyMock).createExtraAttributes(publishArtifactConf1);
will(returnValue(extraAttributesArtifact1));
one(artifactsExtraAttributesStrategyMock).createExtraAttributes(publishArtifactConf2);
will(returnValue(extraAttributesArtifact2));
}});
DefaultModuleDescriptor moduleDescriptor = HelperUtil.createModuleDescriptor(WrapUtil.toSet(configurationStub1.getName(),
configurationStub2.getName()));
DefaultArtifactsToModuleDescriptorConverter artifactsToModuleDescriptorConverter =
new DefaultArtifactsToModuleDescriptorConverter(artifactsExtraAttributesStrategyMock);
artifactsToModuleDescriptorConverter.addArtifacts(moduleDescriptor, WrapUtil.toSet(configurationStub1, configurationStub2));