### Question:
ArtifactoryPromotionSyncServiceImpl implements ArtifactoryPromotionSyncService, JobOrchestratorSupplier, ConfigurationServiceListener<ArtifactoryConfiguration> { @Override public Stream<JobRegistration> collectJobRegistrations() { if (artifactoryConfProperties.isBuildSyncDisabled()) { return Stream.empty(); } else { return securityService.asAdmin(() -> structureService.getProjectList().stream() .flatMap(project -> structureService.getBranchesForProject(project.getId()).stream()) .filter(branch -> branch.getType() != BranchType.TEMPLATE_DEFINITION) .filter(branch -> propertyService.hasProperty(branch, ArtifactoryPromotionSyncPropertyType.class)) .map(this::scheduleArtifactoryBuildSync) ); } } @Autowired  ArtifactoryPromotionSyncServiceImpl(StructureService structureService, PropertyService propertyService, ArtifactoryClientFactory artifactoryClientFactory, ArtifactoryConfigurationService configurationService, ArtifactoryConfProperties artifactoryConfProperties, SecurityService securityService); @Override Stream<JobRegistration> collectJobRegistrations(); JobRegistration scheduleArtifactoryBuildSync(Branch branch);  }### Answer:
@Test public void syncBuildJobs_one_per_configured_branch() { when(propertyService.hasProperty(branch, ArtifactoryPromotionSyncPropertyType.class)).thenReturn(true); Property<ArtifactoryPromotionSyncProperty> property = Property.of( new ArtifactoryPromotionSyncPropertyType( new ArtifactoryExtensionFeature(), null ), new ArtifactoryPromotionSyncProperty( null, "", "", 10 ) ); when(propertyService.getProperty(branch, ArtifactoryPromotionSyncPropertyType.class)).thenReturn(property); when(structureService.getProjectList()).thenReturn(Collections.singletonList(project)); when(structureService.getBranchesForProject(project.getId())).thenReturn(Collections.singletonList(branch)); assertEquals(1, service.collectJobRegistrations().count()); }
@Test public void syncBuildJobs_ignoring_templates() { branch = branch.withType(BranchType.TEMPLATE_DEFINITION); when(propertyService.hasProperty(branch, ArtifactoryPromotionSyncPropertyType.class)).thenReturn(true); when(structureService.getProjectList()).thenReturn(Collections.singletonList(project)); when(structureService.getBranchesForProject(project.getId())).thenReturn(Collections.singletonList(branch)); assertEquals(0, service.collectJobRegistrations().count()); }