Added glocal china unit test and added T07PartPlanIt
This commit is contained in:
parent
daad0690fc
commit
9793e70937
6 changed files with 297 additions and 21 deletions
|
|
@ -0,0 +1,47 @@
|
|||
package love.distributedrebirth.numberxd.base2t;
|
||||
|
||||
import love.distributedrebirth.numberxd.base2t.facet.BasePart;
|
||||
|
||||
public final class BasePartFactory {
|
||||
|
||||
private static final int[] SUPPORTED_BASES = {2,3,4,5,6,7,8,12,16,20,60};
|
||||
|
||||
public static int[] getSupportedBases() {
|
||||
return SUPPORTED_BASES;
|
||||
}
|
||||
|
||||
public static BasePart[] buildBasePartsByBase(int base) {
|
||||
switch (base) {
|
||||
case 2:
|
||||
return T02PartBinary.values();
|
||||
case 3:
|
||||
return T03PartTrit.values();
|
||||
case 4:
|
||||
return T04PartQuad.values();
|
||||
case 5:
|
||||
return T05PartPental.values();
|
||||
case 6:
|
||||
return T06PartSeximal.values();
|
||||
case 7:
|
||||
return T07PartPlanIt.values();
|
||||
case 8:
|
||||
return T08PartOctal.values();
|
||||
case 9:
|
||||
throw new IllegalArgumentException("Unsupported base: "+base);
|
||||
case 10:
|
||||
throw new IllegalArgumentException("Unsupported base: "+base);
|
||||
case 11:
|
||||
throw new IllegalArgumentException("Unsupported base: "+base);
|
||||
case 12:
|
||||
return T12PartUncial.values();
|
||||
case 16:
|
||||
return T16PartHex.values();
|
||||
case 20:
|
||||
return T20PartScore.values();
|
||||
case 60:
|
||||
return T60Sexagesimal.values();
|
||||
default:
|
||||
throw new IllegalArgumentException("Unsupported base: "+base);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,67 @@
|
|||
package love.distributedrebirth.numberxd.base2t;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.Collections;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.function.Consumer;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import love.distributedrebirth.numberxd.base2t.facet.BasePart;
|
||||
import love.distributedrebirth.numberxd.base2t.facet.BaseFacetKey;
|
||||
import love.distributedrebirth.numberxd.base2t.facet.BasePartAlt1;
|
||||
|
||||
/**
|
||||
* The distribution by 7.
|
||||
*
|
||||
* @author willemtsade ©Δ∞ 仙上主天
|
||||
*/
|
||||
public enum T07PartPlanIt implements BasePart,BasePartAlt1 {
|
||||
|
||||
PART_1("˥","0","♎︎","libra","天秤座"),
|
||||
PART_2("꜉","1","♏︎","scorpio","天蠍座"),
|
||||
PART_3("꜋","2","♓︎","pisces","雙魚座"),
|
||||
PART_4("꜔","3","♍︎","virgo","處女座"),
|
||||
PART_5("꜎","4","♋︎","cancer","癌症"),
|
||||
PART_6("꜐","5","♑︎","capricorn","摩羯座"),
|
||||
PART_7("˩","7","♈︎","aries","白羊座"),
|
||||
;
|
||||
|
||||
public static int LENGTH = 6;
|
||||
private final Map<BaseFacetKey, Object> facetStore = new HashMap<>();
|
||||
private static final String ALT_1_NAME = "Fallen sign";
|
||||
private static final String ALT_1_WIKI = "https://en.wikipedia.org/wiki/Classical_planet#Western_astrology";
|
||||
private static final Map<String, T07PartPlanIt> TONE_MAP = Collections.unmodifiableMap(
|
||||
Arrays.asList(values()).stream().collect(Collectors.toMap(v -> v.getIdentifierTone(), v -> v)));
|
||||
private static final Map<String, T07PartPlanIt> CHINA_MAP = Collections.unmodifiableMap(
|
||||
Arrays.asList(values()).stream().collect(Collectors.toMap(v -> v.getChinaKey(), v -> v)));
|
||||
|
||||
private T07PartPlanIt(String idTone, String idLetter, String chinaKey, String chinaValue, String alt1Value) {
|
||||
this.getFacetStore().put(BaseFacetKey.ID_TONE, idTone);
|
||||
this.getFacetStore().put(BaseFacetKey.ID_LETTER, idLetter);
|
||||
this.getFacetStore().put(BaseFacetKey.CHINA_KEY, chinaKey);
|
||||
this.getFacetStore().put(BaseFacetKey.CHINA_VALUE, chinaValue);
|
||||
this.getFacetStore().put(BaseFacetKey.ALT_1_VALUE, alt1Value);
|
||||
this.getFacetStore().put(BaseFacetKey.ALT_1_NAME, ALT_1_NAME);
|
||||
this.getFacetStore().put(BaseFacetKey.ALT_1_WIKI, ALT_1_WIKI);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map<BaseFacetKey, Object> getFacetStore() {
|
||||
return facetStore;
|
||||
}
|
||||
|
||||
public static void forEach(Consumer<T07PartPlanIt> consumer) {
|
||||
for (T07PartPlanIt value:values()) {
|
||||
consumer.accept(value);
|
||||
}
|
||||
}
|
||||
|
||||
public static T07PartPlanIt valueOfTone(String identifierTone) {
|
||||
return TONE_MAP.get(identifierTone);
|
||||
}
|
||||
|
||||
public static T07PartPlanIt valueOfChina(String chinaKey) {
|
||||
return CHINA_MAP.get(chinaKey);
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,69 @@
|
|||
package love.distributedrebirth.numberxd.base2t;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
import org.junit.jupiter.api.Assertions;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import love.distributedrebirth.numberxd.base2t.facet.BasePart;
|
||||
|
||||
public class BasePartFactoryTest {
|
||||
|
||||
@Test
|
||||
public void testSupportedBases() {
|
||||
int[] bases = BasePartFactory.getSupportedBases();
|
||||
Assertions.assertNotNull(bases);
|
||||
Assertions.assertTrue(bases.length > 1);
|
||||
Assertions.assertTrue(bases.length < 100);
|
||||
for (int base:bases) {
|
||||
Assertions.assertNotNull(base);
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGlobalChinaMap() {
|
||||
Map<String,String> global = new HashMap<>();
|
||||
for (int base:BasePartFactory.getSupportedBases()) {
|
||||
for (BasePart part:BasePartFactory.buildBasePartsByBase(base)) {
|
||||
Assertions.assertFalse(global.containsKey(part.getChinaKey()));
|
||||
global.put(part.getChinaKey(), part.getChinaValue());
|
||||
}
|
||||
}
|
||||
Assertions.assertTrue(global.size() > 1);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGlobalToneMap() {
|
||||
boolean duplicate = false;
|
||||
Map<String,String> global = new HashMap<>();
|
||||
for (int base:BasePartFactory.getSupportedBases()) {
|
||||
for (BasePart part:BasePartFactory.buildBasePartsByBase(base)) {
|
||||
if (global.containsKey(part.getIdentifierTone())) {
|
||||
duplicate = true;
|
||||
break;
|
||||
}
|
||||
global.put(part.getIdentifierTone(), part.getChinaValue());
|
||||
}
|
||||
}
|
||||
Assertions.assertTrue(global.size() > 1);
|
||||
Assertions.assertTrue(duplicate);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGlobalLetterMap() {
|
||||
boolean duplicate = false;
|
||||
Map<String,String> global = new HashMap<>();
|
||||
for (int base:BasePartFactory.getSupportedBases()) {
|
||||
for (BasePart part:BasePartFactory.buildBasePartsByBase(base)) {
|
||||
if (global.containsKey(part.getIdentifierLetter())) {
|
||||
duplicate = true;
|
||||
break;
|
||||
}
|
||||
global.put(part.getIdentifierLetter(), part.getChinaValue());
|
||||
}
|
||||
}
|
||||
Assertions.assertTrue(global.size() > 1);
|
||||
Assertions.assertTrue(duplicate);
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,41 @@
|
|||
package love.distributedrebirth.numberxd.base2t;
|
||||
|
||||
import org.junit.jupiter.api.Assertions;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
/**
|
||||
*
|
||||
*
|
||||
* @author willemtsade ©Δ∞ 仙上主天
|
||||
*/
|
||||
public class T07PartPlanItTest {
|
||||
|
||||
@Test
|
||||
public void testBasePart() {
|
||||
for (T07PartPlanIt value:T07PartPlanIt.values()) {
|
||||
Assertions.assertNotNull(value.getIdentifierTone());
|
||||
Assertions.assertNotNull(value.getIdentifierLetter());
|
||||
Assertions.assertNotNull(value.getChinaKey());
|
||||
Assertions.assertNotNull(value.getChinaValue());
|
||||
Assertions.assertNotNull(value.getAlt1Value());
|
||||
Assertions.assertNotNull(value.getAlt1Name());
|
||||
Assertions.assertNotNull(value.getAlt1Wiki());
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testToneMap() {
|
||||
Assertions.assertEquals(T07PartPlanIt.PART_1, T07PartPlanIt.valueOfTone("˥"));
|
||||
Assertions.assertEquals(T07PartPlanIt.PART_2, T07PartPlanIt.valueOfTone("꜉"));
|
||||
Assertions.assertEquals(T07PartPlanIt.PART_6, T07PartPlanIt.valueOfTone("꜐"));
|
||||
Assertions.assertEquals(T07PartPlanIt.PART_7, T07PartPlanIt.valueOfTone("˩"));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testChinaMap() {
|
||||
Assertions.assertEquals(T07PartPlanIt.PART_1, T07PartPlanIt.valueOfChina("♎︎"));
|
||||
Assertions.assertEquals(T07PartPlanIt.PART_2, T07PartPlanIt.valueOfChina("♏︎"));
|
||||
Assertions.assertEquals(T07PartPlanIt.PART_6, T07PartPlanIt.valueOfChina("♑︎"));
|
||||
Assertions.assertEquals(T07PartPlanIt.PART_7, T07PartPlanIt.valueOfChina("♈︎"));
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue