forked from ModProg/BlockMeter
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
7 changed files
with
130 additions
and
70 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
15 changes: 15 additions & 0 deletions
15
src/test/java/de/modprog/blockmeter/measurebox/util/CsvToMBD.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
package de.modprog.blockmeter.measurebox.util; | ||
|
||
import java.lang.annotation.ElementType; | ||
import java.lang.annotation.Retention; | ||
import java.lang.annotation.RetentionPolicy; | ||
import java.lang.annotation.Target; | ||
|
||
import org.junit.jupiter.params.aggregator.AggregateWith; | ||
|
||
@Retention(RetentionPolicy.RUNTIME) | ||
@Target(ElementType.PARAMETER) | ||
@AggregateWith(MBDAggregator.class) | ||
public @interface CsvToMBD { | ||
|
||
} |
35 changes: 35 additions & 0 deletions
35
src/test/java/de/modprog/blockmeter/measurebox/util/MBDAggregator.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
package de.modprog.blockmeter.measurebox.util; | ||
|
||
import java.util.Arrays; | ||
|
||
import org.junit.jupiter.api.extension.ParameterContext; | ||
import org.junit.jupiter.params.aggregator.ArgumentsAccessor; | ||
import org.junit.jupiter.params.aggregator.ArgumentsAggregationException; | ||
import org.junit.jupiter.params.aggregator.ArgumentsAggregator; | ||
|
||
import net.minecraft.util.DyeColor; | ||
import net.minecraft.util.Identifier; | ||
import net.minecraft.util.math.BlockPos; | ||
|
||
public class MBDAggregator implements ArgumentsAggregator { | ||
|
||
@Override | ||
public Object aggregateArguments(ArgumentsAccessor arguments, ParameterContext context) | ||
throws ArgumentsAggregationException { | ||
return new MeasureBoxData(bp(arguments.getString(0)), bp(arguments.getString(1)), | ||
arguments.get(2, Identifier.class), dc(arguments.getString(3)), | ||
arguments.getString(4).equals("finished"), 0, 0); | ||
} | ||
|
||
private BlockPos bp(String s) { | ||
final int[] array = Arrays.stream(s.split("[/|-]")).mapToInt(Integer::parseInt).toArray(); | ||
if (array.length > 0) | ||
return new BlockPos(array[0], array[1], array[2]); | ||
throw new ArgumentsAggregationException("not enough numbers in BlockPos"); | ||
} | ||
|
||
private DyeColor dc(String s) { | ||
return DyeColor.valueOf(s.toUpperCase()); | ||
} | ||
|
||
} |
50 changes: 50 additions & 0 deletions
50
src/test/java/de/modprog/blockmeter/measurebox/util/MeasureBoxData.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
package de.modprog.blockmeter.measurebox.util; | ||
|
||
import java.util.stream.Stream; | ||
|
||
import org.junit.jupiter.api.extension.ExtensionContext; | ||
import org.junit.jupiter.params.provider.Arguments; | ||
import org.junit.jupiter.params.provider.ArgumentsProvider; | ||
|
||
import net.minecraft.util.DyeColor; | ||
import net.minecraft.util.Identifier; | ||
import net.minecraft.util.math.BlockPos; | ||
|
||
public class MeasureBoxData implements ArgumentsProvider { | ||
public final BlockPos bp1; | ||
public final BlockPos bp2; | ||
public final Identifier dimension; | ||
public final DyeColor color; | ||
public final boolean finished; | ||
public final int mode; | ||
public final int orientation; | ||
|
||
MeasureBoxData(BlockPos bp1, BlockPos bp2, Identifier identifier, DyeColor color, boolean finished, | ||
int mode, int orientation) { | ||
this.bp1 = bp1; | ||
this.bp2 = bp2; | ||
this.dimension = identifier; | ||
this.color = color; | ||
this.finished = finished; | ||
this.mode = mode; | ||
this.orientation = orientation; | ||
} | ||
|
||
@Override | ||
public String toString() { | ||
return bp1.toShortString(); | ||
} | ||
|
||
@Override | ||
public Stream<? extends Arguments> provideArguments(ExtensionContext context) throws Exception { | ||
return Stream.of(new Object[] { | ||
new MeasureBoxData(new BlockPos(0, 1, 2), new BlockPos(10, 5, 2), new Identifier("minecraft:overworld"), | ||
DyeColor.BLACK, true, 0, 0), | ||
new MeasureBoxData(new BlockPos(-30, 200, -1012), new BlockPos(10, 3, -100), | ||
new Identifier("minecraft:overworld"), DyeColor.ORANGE, false, 5, 3), | ||
new MeasureBoxData(new BlockPos(10300, 1, 2), new BlockPos(10000, 5, 2), | ||
new Identifier("minecraft:overworld"), DyeColor.WHITE, true, 20, 4) }) | ||
.map(Arguments::of); | ||
} | ||
|
||
} |
1 change: 1 addition & 0 deletions
1
src/test/resources/org/powermock/extensions/configuration.properties
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
powermock.global-ignore=javax.xml.parsers.*,org.apache.xerces.jaxp.*,com.sun.org.apache.xerces.*,org.xml.* |