DATAREDIS-316 - Polishing.
Extend JavaDoc documentation. Spelling fixes. Add Expiration.from factory method to create Expiration from all available time units. Original pull request: #170.
This commit is contained in:
@@ -0,0 +1,66 @@
|
||||
/*
|
||||
* Copyright 2016 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.springframework.data.redis.core.types;
|
||||
|
||||
import static org.hamcrest.core.Is.is;
|
||||
import static org.junit.Assert.assertThat;
|
||||
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
import org.junit.Test;
|
||||
|
||||
/**
|
||||
* @author Mark Paluch
|
||||
*/
|
||||
public class ExpirationUnitTests {
|
||||
|
||||
/**
|
||||
* @see DATAREDIS-316
|
||||
*/
|
||||
@Test
|
||||
public void fromDefault() throws Exception {
|
||||
|
||||
Expiration expiration = Expiration.from(5, null);
|
||||
|
||||
assertThat(expiration.getExpirationTime(), is(5L));
|
||||
assertThat(expiration.getTimeUnit(), is(TimeUnit.SECONDS));
|
||||
}
|
||||
|
||||
/**
|
||||
* @see DATAREDIS-316
|
||||
*/
|
||||
@Test
|
||||
public void fromNanos() throws Exception {
|
||||
|
||||
Expiration expiration = Expiration.from(5L * 1000 * 1000, TimeUnit.NANOSECONDS);
|
||||
|
||||
assertThat(expiration.getExpirationTime(), is(5L));
|
||||
assertThat(expiration.getTimeUnit(), is(TimeUnit.MILLISECONDS));
|
||||
}
|
||||
|
||||
/**
|
||||
* @see DATAREDIS-316
|
||||
*/
|
||||
@Test
|
||||
public void fromMinutes() throws Exception {
|
||||
|
||||
Expiration expiration = Expiration.from(5, TimeUnit.MINUTES);
|
||||
|
||||
assertThat(expiration.getExpirationTime(), is(5L * 60));
|
||||
assertThat(expiration.getTimeUnit(), is(TimeUnit.SECONDS));
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user