DATAREDIS-971 - Polishing.
Add test. Use primitive types instead of wrappers for signed flag. Add author tag. Original pull request: #447.
This commit is contained in:
@@ -28,6 +28,7 @@ import org.springframework.util.Assert;
|
||||
* The actual {@code BITFIELD} command representation holding several {@link BitFieldSubCommand}s to execute.
|
||||
*
|
||||
* @author Christoph Strobl
|
||||
* @author Qiang Lee
|
||||
* @since 2.1
|
||||
*/
|
||||
public class BitFieldSubCommands implements Iterable<BitFieldSubCommand> {
|
||||
@@ -88,7 +89,7 @@ public class BitFieldSubCommands implements Iterable<BitFieldSubCommand> {
|
||||
/**
|
||||
* Create new {@link BitFieldSubCommands} adding given {@link BitFieldSet} to the sub commands.
|
||||
*
|
||||
* @param get must not be {@literal null}.
|
||||
* @param set must not be {@literal null}.
|
||||
* @return
|
||||
*/
|
||||
protected BitFieldSubCommands set(BitFieldSet set) {
|
||||
@@ -434,7 +435,7 @@ public class BitFieldSubCommands implements Iterable<BitFieldSubCommand> {
|
||||
private final boolean signed;
|
||||
private final int bits;
|
||||
|
||||
private BitFieldType(Boolean signed, Integer bits) {
|
||||
private BitFieldType(boolean signed, Integer bits) {
|
||||
|
||||
this.signed = signed;
|
||||
this.bits = bits;
|
||||
|
||||
@@ -0,0 +1,48 @@
|
||||
/*
|
||||
* Copyright 2019 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
|
||||
*
|
||||
* https://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.connection;
|
||||
|
||||
import static org.assertj.core.api.Assertions.*;
|
||||
|
||||
import org.junit.Test;
|
||||
|
||||
import org.springframework.data.redis.connection.BitFieldSubCommands.BitFieldType;
|
||||
|
||||
/**
|
||||
* Unit tests for {@link BitFieldSubCommands}.
|
||||
*
|
||||
* @author Mark Paluch
|
||||
*/
|
||||
public class BitFieldSubCommandsUnitTests {
|
||||
|
||||
@Test // DATAREDIS-971
|
||||
public void shouldCreateSignedBitFieldType() {
|
||||
|
||||
BitFieldType type = BitFieldType.signed(10);
|
||||
|
||||
assertThat(type.isSigned()).isTrue();
|
||||
assertThat(type.getBits()).isEqualTo(10);
|
||||
}
|
||||
|
||||
@Test // DATAREDIS-971
|
||||
public void shouldCreateUnsignedBitFieldType() {
|
||||
|
||||
BitFieldType type = BitFieldType.unsigned(10);
|
||||
|
||||
assertThat(type.isSigned()).isFalse();
|
||||
assertThat(type.getBits()).isEqualTo(10);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user