use of net.nemerosa.ontrack.extension.artifactory.ArtifactoryConfProperties in project ontrack by nemerosa.
the class ArtifactoryPromotionSyncServiceImplTest method setup.
@Before
public void setup() {
structureService = mock(StructureService.class);
propertyService = mock(PropertyService.class);
ArtifactoryClientFactory artifactoryClientFactory = mock(ArtifactoryClientFactory.class);
ArtifactoryConfigurationService configurationService = mock(ArtifactoryConfigurationService.class);
ArtifactoryConfProperties artifactoryConfProperties = new ArtifactoryConfProperties();
SecurityService securityService = mock(SecurityService.class);
doAnswer(invocation -> {
Supplier run = (Supplier) invocation.getArguments()[0];
return run.get();
}).when(securityService).asAdmin(any(Supplier.class));
service = new ArtifactoryPromotionSyncServiceImpl(structureService, propertyService, artifactoryClientFactory, configurationService, artifactoryConfProperties, securityService);
// Fake Artifactory client
artifactoryClient = mock(ArtifactoryClient.class);
when(artifactoryClientFactory.getClient(any())).thenReturn(artifactoryClient);
// Branch to sync
project = Project.of(new NameDescription("P", "Project")).withId(ID.of(1));
branch = Branch.of(project, new NameDescription("B", "Branch")).withId(ID.of(10));
// Existing build
build = Build.of(branch, new NameDescription("1.0.0", "Build 1.0.0"), Signature.of("test")).withId(ID.of(100));
when(structureService.findBuildByName("P", "B", "1.0.0")).thenReturn(Optional.of(build));
// Existing promotions
when(artifactoryClient.getStatuses(any())).thenReturn(Collections.singletonList(new ArtifactoryStatus("COPPER", "x", Time.now())));
// Existing promotion level
promotionLevel = PromotionLevel.of(branch, new NameDescription("COPPER", "Copper level")).withId(ID.of(100));
when(structureService.findPromotionLevelByName("P", "B", "COPPER")).thenReturn(Optional.of(promotionLevel));
}
Aggregations