Skip to content

Commit 2f2d8f6

Browse files
author
Sebastian Hoß
committed
add more tests
1 parent 53a8807 commit 2f2d8f6

18 files changed

+342
-5
lines changed

storage-units-dozer/src/test/java/wtf/metio/storageunits/dozer/BigIntegerBinaryStorageUnitConverterTest.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77

88
import org.junit.jupiter.api.Assertions;
99
import org.junit.jupiter.api.Test;
10+
import wtf.metio.storageunits.model.StorageUnits;
1011

1112
import java.math.BigInteger;
1213

@@ -17,7 +18,7 @@ void shouldConvertLongToStorageUnit() {
1718
final var converter = new BigIntegerBinaryStorageUnitConverter();
1819
final var unit = converter.convertTo(BigInteger.valueOf(1024L));
1920

20-
Assertions.assertNotNull(unit);
21+
Assertions.assertEquals(StorageUnits.kibibyte(1), unit);
2122
}
2223

2324
}
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
/*
2+
* SPDX-FileCopyrightText: The Storage-Units Authors
3+
* SPDX-License-Identifier: 0BSD
4+
*/
5+
6+
package wtf.metio.storageunits.dozer;
7+
8+
import org.junit.jupiter.api.Assertions;
9+
import org.junit.jupiter.api.Test;
10+
import wtf.metio.storageunits.model.StorageUnits;
11+
12+
import java.math.BigInteger;
13+
14+
class BigIntegerDecimalStorageUnitConverterTest {
15+
16+
@Test
17+
void shouldConvertLongToStorageUnit() {
18+
final var converter = new BigIntegerDecimalStorageUnitConverter();
19+
final var unit = converter.convertTo(BigInteger.valueOf(1000L));
20+
21+
Assertions.assertEquals(StorageUnits.kilobyte(1), unit);
22+
}
23+
24+
}
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
/*
2+
* SPDX-FileCopyrightText: The Storage-Units Authors
3+
* SPDX-License-Identifier: 0BSD
4+
*/
5+
6+
package wtf.metio.storageunits.dozer;
7+
8+
import org.junit.jupiter.api.Assertions;
9+
import org.junit.jupiter.api.Test;
10+
import wtf.metio.storageunits.model.StorageUnits;
11+
12+
class LongBinaryStorageUnitConverterTest {
13+
14+
@Test
15+
void shouldConvertLongToStorageUnit() {
16+
final var converter = new LongBinaryStorageUnitConverter();
17+
final var unit = converter.convertTo(1024L);
18+
19+
Assertions.assertEquals(StorageUnits.kibibyte(1), unit);
20+
}
21+
22+
}
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
/*
2+
* SPDX-FileCopyrightText: The Storage-Units Authors
3+
* SPDX-License-Identifier: 0BSD
4+
*/
5+
6+
package wtf.metio.storageunits.dozer;
7+
8+
import org.junit.jupiter.api.Assertions;
9+
import org.junit.jupiter.api.Test;
10+
import wtf.metio.storageunits.model.StorageUnits;
11+
12+
class LongDecimalStorageUnitConverterTest {
13+
14+
@Test
15+
void shouldConvertLongToStorageUnit() {
16+
final var converter = new LongDecimalStorageUnitConverter();
17+
final var unit = converter.convertTo(1000L);
18+
19+
Assertions.assertEquals(StorageUnits.kilobyte(1), unit);
20+
}
21+
22+
}

storage-units-jakarta/src/test/java/wtf/metio/storageunits/jakarta/BinaryStorageUnitConverterTest.java

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77

88
import org.junit.jupiter.api.Assertions;
99
import org.junit.jupiter.api.Test;
10+
import wtf.metio.storageunits.model.StorageUnits;
1011

1112
import java.math.BigInteger;
1213

@@ -17,7 +18,15 @@ void shouldConvertBigIntegerToStorageUnit() {
1718
final var converter = new BinaryStorageUnitConverter();
1819
final var unit = converter.convertToEntityAttribute(BigInteger.valueOf(1024L));
1920

20-
Assertions.assertNotNull(unit);
21+
Assertions.assertEquals(StorageUnits.kibibyte(1), unit);
22+
}
23+
24+
@Test
25+
void shouldConvertStorageUnitToBigInteger() {
26+
final var converter = new BinaryStorageUnitConverter();
27+
final var value = converter.convertToDatabaseColumn(StorageUnits.kibibyte(1));
28+
29+
Assertions.assertEquals(BigInteger.valueOf(1024L), value);
2130
}
2231

2332
}
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
/*
2+
* SPDX-FileCopyrightText: The Storage-Units Authors
3+
* SPDX-License-Identifier: 0BSD
4+
*/
5+
6+
package wtf.metio.storageunits.jakarta;
7+
8+
import org.junit.jupiter.api.Assertions;
9+
import org.junit.jupiter.api.Test;
10+
import wtf.metio.storageunits.model.StorageUnits;
11+
12+
import java.math.BigInteger;
13+
14+
class DecimalStorageUnitConverterTest {
15+
16+
@Test
17+
void shouldConvertBigIntegerToStorageUnit() {
18+
final var converter = new DecimalStorageUnitConverter();
19+
final var unit = converter.convertToEntityAttribute(BigInteger.valueOf(1000L));
20+
21+
Assertions.assertEquals(StorageUnits.kilobyte(1), unit);
22+
}
23+
24+
@Test
25+
void shouldConvertStorageUnitToBigInteger() {
26+
final var converter = new DecimalStorageUnitConverter();
27+
final var value = converter.convertToDatabaseColumn(StorageUnits.kilobyte(1));
28+
29+
Assertions.assertEquals(BigInteger.valueOf(1000L), value);
30+
}
31+
32+
}

storage-units-mapstruct/src/test/java/wtf/metio/storageunits/mapstruct/BigIntegerToBinaryUnitMapperTest.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77

88
import org.junit.jupiter.api.Assertions;
99
import org.junit.jupiter.api.Test;
10+
import wtf.metio.storageunits.model.StorageUnits;
1011

1112
import java.math.BigInteger;
1213

@@ -17,7 +18,7 @@ void shouldConvertBigIntegerToStorageUnit() {
1718
final var mapper = new BigIntegerToBinaryUnitMapper();
1819
final var unit = mapper.convert(BigInteger.valueOf(1024L));
1920

20-
Assertions.assertNotNull(unit);
21+
Assertions.assertEquals(StorageUnits.kibibyte(1), unit);
2122
}
2223

2324
}
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
/*
2+
* SPDX-FileCopyrightText: The Storage-Units Authors
3+
* SPDX-License-Identifier: 0BSD
4+
*/
5+
6+
package wtf.metio.storageunits.mapstruct;
7+
8+
import org.junit.jupiter.api.Assertions;
9+
import org.junit.jupiter.api.Test;
10+
import wtf.metio.storageunits.model.StorageUnits;
11+
12+
import java.math.BigInteger;
13+
14+
class BigIntegerToDecimalUnitMapperTest {
15+
16+
@Test
17+
void shouldConvertBigIntegerToStorageUnit() {
18+
final var mapper = new BigIntegerToDecimalUnitMapper();
19+
final var unit = mapper.convert(BigInteger.valueOf(1000L));
20+
21+
Assertions.assertEquals(StorageUnits.kilobyte(1), unit);
22+
}
23+
24+
}
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
/*
2+
* SPDX-FileCopyrightText: The Storage-Units Authors
3+
* SPDX-License-Identifier: 0BSD
4+
*/
5+
6+
package wtf.metio.storageunits.mapstruct;
7+
8+
import org.junit.jupiter.api.Assertions;
9+
import org.junit.jupiter.api.Test;
10+
import wtf.metio.storageunits.model.StorageUnits;
11+
12+
class LongToBinaryUnitMapperTest {
13+
14+
@Test
15+
void shouldConvertLongToStorageUnit() {
16+
final var mapper = new LongToBinaryUnitMapper();
17+
final var unit = mapper.convert(1024L);
18+
19+
Assertions.assertEquals(StorageUnits.kibibyte(1), unit);
20+
}
21+
22+
}
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
/*
2+
* SPDX-FileCopyrightText: The Storage-Units Authors
3+
* SPDX-License-Identifier: 0BSD
4+
*/
5+
6+
package wtf.metio.storageunits.mapstruct;
7+
8+
import org.junit.jupiter.api.Assertions;
9+
import org.junit.jupiter.api.Test;
10+
import wtf.metio.storageunits.model.StorageUnits;
11+
12+
class LongToDecimalUnitMapperTest {
13+
14+
@Test
15+
void shouldConvertLongToStorageUnit() {
16+
final var mapper = new LongToBinaryUnitMapper();
17+
final var unit = mapper.convert(1000L);
18+
19+
Assertions.assertEquals(StorageUnits.kilobyte(1), unit);
20+
}
21+
22+
}

0 commit comments

Comments
 (0)