當前位置: 首頁>>代碼示例>>Java>>正文


Java DateTimeUtils.setCurrentMillisFixed方法代碼示例

本文整理匯總了Java中org.joda.time.DateTimeUtils.setCurrentMillisFixed方法的典型用法代碼示例。如果您正苦於以下問題:Java DateTimeUtils.setCurrentMillisFixed方法的具體用法?Java DateTimeUtils.setCurrentMillisFixed怎麽用?Java DateTimeUtils.setCurrentMillisFixed使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在org.joda.time.DateTimeUtils的用法示例。


在下文中一共展示了DateTimeUtils.setCurrentMillisFixed方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: redeem_willThrowError_whenCodeIsExpired

import org.joda.time.DateTimeUtils; //導入方法依賴的package包/類
@Test
public void redeem_willThrowError_whenCodeIsExpired() {
    thrown.expect(IllegalArgumentException.class);
    thrown.expectMessage("Invite code has expired. Please ask your administrator to issue you an new one.");

    String code = "invalid";
    String email = "[email protected]";
    AppUser issuer = user("[email protected]");
    Roles roles = new Roles(Roles.User);
    UserInviteLink inviteLink = new UserInviteLink(code, issuer, email, roles);

    DateTimeUtils.setCurrentMillisFixed(DateTime.now().plusDays(2).getMillis() + 1);

    String hashedCode = UserInviteLink.hash(code);
    when(userInviteLinkRepository.get(hashedCode)).thenReturn(inviteLink);

    userInviteService.redeem(code, "name", "password");
}
 
開發者ID:3wks,項目名稱:generator-thundr-gae-react,代碼行數:19,代碼來源:UserInviteServiceTest.java

示例2: setup

import org.joda.time.DateTimeUtils; //導入方法依賴的package包/類
@Before
public void setup() {
    DateTimeUtils.setCurrentMillisFixed(TIMESTAMP.getMillis());
    service = new AuthnResponseFromCountryService(
        samlEngineProxy,
        samlSoapProxyProxy,
        matchingServiceConfigProxy,
        policyConfiguration,
        sessionRepository,
        samlAuthnResponseTranslatorDtoFactory,
        countriesService,
        assertionRestrictionFactory);
    when(sessionRepository.getStateController(SESSION_ID, CountrySelectedState.class)).thenReturn(stateController);
    when(stateController.getAssertionConsumerServiceUri()).thenReturn(ASSERTION_CONSUMER_SERVICE_URI);
    when(stateController.getRequestIssuerEntityId()).thenReturn(TEST_RP);
    when(stateController.getMatchingServiceEntityId()).thenReturn(TEST_RP_MS);
    when(stateController.getRequestId()).thenReturn(REQUEST_ID);
    when(samlAuthnResponseTranslatorDtoFactory.fromSamlAuthnResponseContainerDto(SAML_AUTHN_RESPONSE_CONTAINER_DTO, TEST_RP_MS)).thenReturn(SAML_AUTHN_RESPONSE_TRANSLATOR_DTO);
    when(samlEngineProxy.translateAuthnResponseFromCountry(SAML_AUTHN_RESPONSE_TRANSLATOR_DTO)).thenReturn(INBOUND_RESPONSE_FROM_COUNTRY);
    when(samlEngineProxy.generateEidasAttributeQuery(EIDAS_ATTRIBUTE_QUERY_REQUEST_DTO)).thenReturn(ATTRIBUTE_QUERY_CONTAINER_DTO);
    when(matchingServiceConfigProxy.getMatchingService(TEST_RP_MS)).thenReturn(MATCHING_SERVICE_CONFIG_ENTITY_DATA_DTO);
    when(policyConfiguration.getMatchingServiceResponseWaitPeriod()).thenReturn(MATCHING_SERVICE_RESPONSE_WAIT_PERIOD);
    when(assertionRestrictionFactory.getAssertionExpiry()).thenReturn(TIMESTAMP.plus(ASSERTION_EXPIRY));
}
 
開發者ID:alphagov,項目名稱:verify-hub,代碼行數:25,代碼來源:AuthnResponseFromCountryServiceTest.java

示例3: testTriggerAlreadyRunningRun

import org.joda.time.DateTimeUtils; //導入方法依賴的package包/類
@Test
public void testTriggerAlreadyRunningRun() throws InterruptedException, ReaperException {
  DateTimeUtils.setCurrentMillisFixed(TIME_CREATE);

  context.repairManager
      .initializeThreadPool(THREAD_CNT, REPAIR_TIMEOUT_S, TimeUnit.SECONDS, RETRY_DELAY_S, TimeUnit.SECONDS);

  RepairRunResource resource = new RepairRunResource(context);
  Response response = addDefaultRepairRun(resource);
  assertTrue(response.getEntity().toString(), response.getEntity() instanceof RepairRunStatus);
  RepairRunStatus repairRunStatus = (RepairRunStatus) response.getEntity();
  UUID runId = repairRunStatus.getId();

  DateTimeUtils.setCurrentMillisFixed(TIME_START);
  Optional<String> newState = Optional.of(RepairRun.RunState.RUNNING.toString());
  resource.modifyRunState(uriInfo, runId, newState);
  Thread.sleep(1000);
  response = resource.modifyRunState(uriInfo, runId, newState);
  assertEquals(Response.Status.NOT_MODIFIED.getStatusCode(), response.getStatus());
}
 
開發者ID:thelastpickle,項目名稱:cassandra-reaper,代碼行數:21,代碼來源:RepairRunResourceTest.java

示例4: testHarvestReminderIsSentButNowTooEarly

import org.joda.time.DateTimeUtils; //導入方法依賴的package包/類
@Test
public void testHarvestReminderIsSentButNowTooEarly() {
    try {
        final Harvest harvest = createHarvest(HarvestReportRequired.REQUIRED, AuthorIsRegistered.REGISTERED);
        harvest.setEmailReminderSentTime(getTestStartTime());

        persistInNewTransaction();

        final DateTime fakeNow = getTestStartTime().plus(HarvestReportReminderFeature.REMINDER_INTERVAL).minusSeconds(1);
        DateTimeUtils.setCurrentMillisFixed(fakeNow.getMillis());

        runInTransaction(() -> {
            final Map<Long, Set<String>> res = harvestReportReminder.sendReminders();
            assertEquals(0, res.size());
        });

    } finally {
        DateTimeUtils.setCurrentMillisSystem();
    }
}
 
開發者ID:suomenriistakeskus,項目名稱:oma-riista-web,代碼行數:21,代碼來源:HarvestReportReminderTest.java

示例5: testUpdateOnlyThoseWhichEmailIsSent

import org.joda.time.DateTimeUtils; //導入方法依賴的package包/類
@Test
public void testUpdateOnlyThoseWhichEmailIsSent() {
    try {
        final Harvest harvest = createHarvest(HarvestReportRequired.REQUIRED, AuthorIsRegistered.REGISTERED);
        final Harvest harvest2 = createHarvest(HarvestReportRequired.REQUIRED, AuthorIsRegistered.NOT_REGISTERED);

        persistInNewTransaction();

        final DateTime fakeNow = getTestStartTime().plus(HarvestReportReminderFeature.FIRST_REMINDER_DELAY).plusSeconds(1);
        DateTimeUtils.setCurrentMillisFixed(fakeNow.getMillis());

        runInTransaction(() -> {
            final Map<Long, Set<String>> res = harvestReportReminder.sendReminders();

            assertEquals(1, res.size());
            assertThat(res, hasKey(harvest.getId()));
        });

        runInTransaction(() -> assertNull(harvestRepository.getOne(harvest2.getId()).getEmailReminderSentTime()));

    } finally {
        DateTimeUtils.setCurrentMillisSystem();
    }
}
 
開發者ID:suomenriistakeskus,項目名稱:oma-riista-web,代碼行數:25,代碼來源:HarvestReportReminderTest.java

示例6: testPauseNotRunningRun

import org.joda.time.DateTimeUtils; //導入方法依賴的package包/類
@Test
public void testPauseNotRunningRun() throws InterruptedException, ReaperException {
  DateTimeUtils.setCurrentMillisFixed(TIME_CREATE);
  context.repairManager.initializeThreadPool(THREAD_CNT, REPAIR_TIMEOUT_S, TimeUnit.SECONDS,
      RETRY_DELAY_S, TimeUnit.SECONDS);
  RepairRunResource resource = new RepairRunResource(context);
  Response response = addDefaultRepairRun(resource);
  assertTrue(response.getEntity().toString(), response.getEntity() instanceof RepairRunStatus);
  RepairRunStatus repairRunStatus = (RepairRunStatus) response.getEntity();
  UUID runId = repairRunStatus.getId();

  response = resource.modifyRunState(uriInfo, runId,
      Optional.of(RepairRun.RunState.PAUSED.toString()));
  Thread.sleep(200);

  assertEquals(405, response.getStatus());
  RepairRun repairRun = context.storage.getRepairRun(runId).get();
  // the run should be paused
  assertEquals(RepairRun.RunState.NOT_STARTED, repairRun.getRunState());
  // but the running segment should be untouched
  assertEquals(0,
      context.storage.getSegmentAmountForRepairRunWithState(runId,
          RepairSegment.State.RUNNING));
}
 
開發者ID:thelastpickle,項目名稱:cassandra-reaper,代碼行數:25,代碼來源:RepairRunResourceTest.java

示例7: testModifyIntensity

import org.joda.time.DateTimeUtils; //導入方法依賴的package包/類
@Test
public void testModifyIntensity() throws ReaperException {
  DateTimeUtils.setCurrentMillisFixed(TIME_CREATE);

  context.repairManager
      .initializeThreadPool(THREAD_CNT, REPAIR_TIMEOUT_S, TimeUnit.SECONDS, RETRY_DELAY_S, TimeUnit.SECONDS);

  RepairRunResource resource = new RepairRunResource(context);
  Response response = addDefaultRepairRun(resource);
  assertTrue(response.getEntity().toString(), response.getEntity() instanceof RepairRunStatus);
  RepairRunStatus repairRunStatus = (RepairRunStatus) response.getEntity();
  UUID runId = repairRunStatus.getId();

  response = resource.modifyRunState(uriInfo, runId, Optional.of(RepairRun.RunState.RUNNING.toString()));
  assertEquals(200, response.getStatus());
  response = resource.modifyRunState(uriInfo, runId, Optional.of(RepairRun.RunState.PAUSED.toString()));
  assertEquals(200, response.getStatus());
  response = resource.modifyRunIntensity(uriInfo, runId, Optional.of("0.1"));
  assertTrue(response.getEntity() instanceof RepairRunStatus);
  repairRunStatus = (RepairRunStatus) response.getEntity();
  assertEquals(0.1, repairRunStatus.getIntensity(), 0.09);
}
 
開發者ID:thelastpickle,項目名稱:cassandra-reaper,代碼行數:23,代碼來源:RepairRunResourceTest.java

示例8: setupTest

import org.joda.time.DateTimeUtils; //導入方法依賴的package包/類
@BeforeTest
public void setupTest() {

	// now = 01/15/2015 12:00:00
	DateTime now = new DateTime()
			.withYear(2015)
			.withMonthOfYear(1)
			.withDayOfMonth(15)
			.withHourOfDay(12)
			.withMinuteOfHour(0)
			.withSecondOfMinute(0);

	DateTimeUtils.setCurrentMillisFixed(now.getMillis());


	testPipeline = new CronPipeline(CRON_EXP);

	Assert.assertEquals(testPipeline.getCurrentIterationNumber().intValue(), -1);
}
 
開發者ID:turn,項目名稱:sorcerer,代碼行數:20,代碼來源:CronPipelineTest.java

示例9: refreshesCredentialsAfterFourteenMinutes

import org.joda.time.DateTimeUtils; //導入方法依賴的package包/類
@Test
public void refreshesCredentialsAfterFourteenMinutes() {
    // given
    final com.amazonaws.auth.AWSSessionCredentials firstCredentials = credentialsProvider.getCredentials();
    DateTimeUtils.setCurrentMillisFixed(Duration.standardMinutes(14).getMillis());
    final com.amazonaws.auth.AWSSessionCredentials secondCredentials = credentialsProvider.getCredentials();
    DateTimeUtils.setCurrentMillisFixed(Duration.standardMinutes(14).getMillis() + 1);

    // when
    final com.amazonaws.auth.AWSSessionCredentials thirdCredentials = credentialsProvider.getCredentials();

    // then
    verify(codePipelineClient, times(2)).getJobDetails(getJobDetailsRequestCaptor.capture());

    assertSame(firstCredentials, secondCredentials);
    assertNotSame(firstCredentials, thirdCredentials);
}
 
開發者ID:awslabs,項目名稱:aws-codepipeline-plugin-for-jenkins,代碼行數:18,代碼來源:AWSCodePipelineJobCredentialsProviderTest.java

示例10: shouldAddExpenseAndNotify

import org.joda.time.DateTimeUtils; //導入方法依賴的package包/類
@Test
public void shouldAddExpenseAndNotify() throws Exception {
  DateTimeUtils.setCurrentMillisFixed(new DateTime("2015-09-06").getMillis());
  when(view.getAmount()).thenReturn("123");
  when(view.getType()).thenReturn("Food");

  ArgumentCaptor<Expense> expenseCaptor = ArgumentCaptor.forClass(Expense.class);

  assertTrue(presenter.addExpense());
  verify(database).addExpense(expenseCaptor.capture());

  Expense actualExpense = expenseCaptor.getValue();
  assertThat(actualExpense.getAmount(), is(123l));
  assertThat(actualExpense.getType(), is("Food"));
  assertThat(actualExpense.getDate(), is("06-09-2015"));
  DateTimeUtils.setCurrentMillisSystem();
}
 
開發者ID:ajitsing,項目名稱:ExpenseManager,代碼行數:18,代碼來源:ExpensePresenterTest.java

示例11: setReceivedAtWithSystemTimeInUTC

import org.joda.time.DateTimeUtils; //導入方法依賴的package包/類
@Test
public void setReceivedAtWithSystemTimeInUTC() throws Exception {
    final EventType eventType = buildDefaultEventType();
    final JSONObject event = buildBusinessEvent();
    final BatchItem batch = TestUtils.createBatchItem(event);

    assertThat(event.getJSONObject("metadata").optString("received_at"), isEmptyString());

    try {
        DateTimeUtils.setCurrentMillisFixed(0);
        strategy.enrich(batch, eventType);
    } finally {
        DateTimeUtils.setCurrentMillisSystem();
    }

    assertThat(batch.getEvent().getJSONObject("metadata").getString("received_at"),
            equalTo("1970-01-01T00:00:00.000Z"));
}
 
開發者ID:zalando,項目名稱:nakadi,代碼行數:19,代碼來源:MetadataEnrichmentStrategyTest.java

示例12: setUp

import org.joda.time.DateTimeUtils; //導入方法依賴的package包/類
@Before
public void setUp() throws Exception {
    DateTimeUtils.setCurrentMillisFixed(NOW.getMillis());
    ResponseFromHubFactory responseFromHubFactory = new ResponseFromHubFactory(idGenerator);
    state = anEidasAwaitingCycle3DataState().build();
    controller = new EidasAwaitingCycle3DataStateController(
        state,
        eventSinkHubEventLogger,
        stateTransitionAction,
        transactionsConfigProxy,
        responseFromHubFactory,
        policyConfiguration,
        assertionRestrictionsFactory,
        matchingServiceConfigProxy);
}
 
開發者ID:alphagov,項目名稱:verify-hub,代碼行數:16,代碼來源:EidasAwaitingCycle3DataStateControllerTest.java

示例13: setUp

import org.joda.time.DateTimeUtils; //導入方法依賴的package包/類
@Before
public void setUp() throws InterruptedException {
    DateTime now = DateTime.now();
    // prepare mock
    mockDataInputProvider = Mockito.mock(ExcelDataProvider.class);
    PowerMockito.mockStatic(Context.class);
    when(Context.getDataInputProvider()).thenReturn(mockDataInputProvider);
    when(Context.getStartCurrentScenario()).thenReturn(now);
    DateTimeUtils.setCurrentMillisFixed(now.plusSeconds(5).getMillis());
}
 
開發者ID:NoraUi,項目名稱:NoraUi,代碼行數:11,代碼來源:CucumberHooksUT.java

示例14: init

import org.joda.time.DateTimeUtils; //導入方法依賴的package包/類
@Before
public void init() {
    tokenHelper = new TokenHelper();
    DateTimeUtils.setCurrentMillisFixed(20L);
    ReflectionTestUtils.setField(tokenHelper, "EXPIRES_IN", 1);
    ReflectionTestUtils.setField(tokenHelper, "SECRET", "mySecret");
}
 
開發者ID:bfwg,項目名稱:angular-spring-starter,代碼行數:8,代碼來源:TokenHelperTest.java

示例15: shouldGenerateMetadataValidFor1Hour

import org.joda.time.DateTimeUtils; //導入方法依賴的package包/類
@Test
public void shouldGenerateMetadataValidFor1Hour() throws Exception {
    DateTimeUtils.setCurrentMillisFixed(DateTime.now().getMillis());
    when(certificateStore.getSigningCertificates()).thenReturn(asList(getCertificate()));

    Document matchingServiceAdapterMetadata = matchingServiceAdapterMetadataRepository.getMatchingServiceAdapterMetadata();
    EntitiesDescriptor entitiesDescriptor = getEntitiesDescriptor(matchingServiceAdapterMetadata);

    assertThat(entitiesDescriptor.getValidUntil()).isEqualTo(DateTime.now(DateTimeZone.UTC).plusHours(1));
}
 
開發者ID:alphagov,項目名稱:verify-matching-service-adapter,代碼行數:11,代碼來源:MatchingServiceAdapterMetadataRepositoryTest.java


注:本文中的org.joda.time.DateTimeUtils.setCurrentMillisFixed方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。