timemachine

Sonatype helps open source projects to set up Maven repositories on https://oss.sonatype.org/

Группа

Группа

br.com.caelum
Идентификатор

Идентификатор

timemachine
Последняя версия

Последняя версия

1.0
Дата

Дата

Тип

Тип

jar
Описание

Описание

timemachine
Sonatype helps open source projects to set up Maven repositories on https://oss.sonatype.org/
Ссылка на сайт

Ссылка на сайт

http://github.com/caelum/timemachine
Система контроля версий

Система контроля версий

http://github.com/caelum/timemachine

Скачать timemachine

Как подключить последнюю версию

<!-- https://jarcasting.com/artifacts/br.com.caelum/timemachine/ -->
<dependency>
    <groupId>br.com.caelum</groupId>
    <artifactId>timemachine</artifactId>
    <version>1.0</version>
</dependency>
// https://jarcasting.com/artifacts/br.com.caelum/timemachine/
implementation 'br.com.caelum:timemachine:1.0'
// https://jarcasting.com/artifacts/br.com.caelum/timemachine/
implementation ("br.com.caelum:timemachine:1.0")
'br.com.caelum:timemachine:jar:1.0'
<dependency org="br.com.caelum" name="timemachine" rev="1.0">
  <artifact name="timemachine" type="jar" />
</dependency>
@Grapes(
@Grab(group='br.com.caelum', module='timemachine', version='1.0')
)
libraryDependencies += "br.com.caelum" % "timemachine" % "1.0"
[br.com.caelum/timemachine "1.0"]

Зависимости

compile (1)

Идентификатор библиотеки Тип Версия
joda-time : joda-time jar 2.2

test (1)

Идентификатор библиотеки Тип Версия
junit : junit jar 4.8.2

Модули Проекта

Данный проект не имеет модулей.

TimeMachine

TimeMachine is a small library created to enable easy testing of code using JodaTime for date and time representation and has some logic depending upon getting the current date.

Usage

Suppose you have a ticket that should not be valid three days after its creation. You could write two tests for that:

@Test
public void should_be_valid_after_creation() {
    assertTrue(new Ticket().isValid());
}

@Test
public void should_not_be_valid_three_days_after_creation() {
    Ticket t = TimeMachine
                .goTo(new DateTime().minusDays(3))
                .andExecute(new Block<Ticket>() {
                    public Ticket run() {
                        return new Ticket();
                    }
                });
    assertFalse(t.isValid());
}

Inside the Block, a new instance of DateTime will be created pointing to three days ago, instead of pointing to the current date.

br.com.caelum

Caelum

Версии библиотеки

Версия
1.0