コード例 #1
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);
 }
コード例 #2
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());
 }