Ejemplo n.º 1
0
 @Before
 public void before() {
   SecurityService securityService = mock(SecurityService.class);
   ValidationRunStatusService validationRunStatusService = mock(ValidationRunStatusService.class);
   structureRepository = mock(StructureRepository.class);
   EventPostService eventService = mock(EventPostService.class);
   EventFactory eventFactory = mock(EventFactory.class);
   ExtensionManager extensionManager = mock(ExtensionManager.class);
   PropertyService propertyService = mock(PropertyService.class);
   PredefinedPromotionLevelService predefinedPromotionLevelService =
       mock(PredefinedPromotionLevelService.class);
   PredefinedValidationStampService predefinedValidationStampService =
       mock(PredefinedValidationStampService.class);
   DecorationService decorationService = mock(DecorationService.class);
   ProjectFavouriteService projectFavouriteService = mock(ProjectFavouriteService.class);
   service =
       new StructureServiceImpl(
           securityService,
           eventService,
           eventFactory,
           validationRunStatusService,
           structureRepository,
           extensionManager,
           propertyService,
           predefinedPromotionLevelService,
           predefinedValidationStampService,
           decorationService,
           projectFavouriteService);
   // Model
   Project project = Project.of(nd("P", "Project")).withId(ID.of(1));
   Branch branch = Branch.of(project, nd("B", "Branch")).withId(ID.of(1));
   copper = PromotionLevel.of(branch, nd("COPPER", "")).withId(ID.of(1));
   build = Build.of(branch, nd("1", "Build 1"), Signature.of("test")).withId(ID.of(1));
 }
Ejemplo n.º 2
0
 @Test
 public void newPromotionRun_with_date() throws Exception {
   PromotionRun promotionRunToCreate =
       PromotionRun.of(
           build,
           copper,
           Signature.of("test").withTime(LocalDateTime.of(2014, 9, 13, 18, 24)),
           "");
   when(structureRepository.newPromotionRun(promotionRunToCreate))
       .thenReturn(promotionRunToCreate.withId(ID.of(1)));
   service.newPromotionRun(promotionRunToCreate);
   verify(structureRepository, times(1)).newPromotionRun(promotionRunToCreate);
 }
Ejemplo n.º 3
0
 @Test
 public void newPromotionRun_with_no_date() throws Exception {
   AtomicReference<PromotionRun> ref = new AtomicReference<>();
   when(structureRepository.newPromotionRun(any(PromotionRun.class)))
       .then(
           invocation -> {
             PromotionRun run = (PromotionRun) invocation.getArguments()[0];
             ref.set(run);
             return run;
           });
   service.newPromotionRun(
       PromotionRun.of(build, copper, Signature.of("test").withTime(null), ""));
   // Checks the signature's time
   assertNotNull(ref.get());
   assertNotNull(ref.get().getSignature().getTime());
 }