method2testcases
stringlengths 118
6.63k
|
---|
### Question:
LargestDegreeFirstColoring extends GreedyColoring<V, E> { public LargestDegreeFirstColoring(Graph<V, E> graph) { super(graph); } LargestDegreeFirstColoring(Graph<V, E> graph); }### Answer:
@Test public void testLargestDegreeFirstColoring() { Graph<Integer, DefaultEdge> g = new SimpleGraph<>(DefaultEdge.class); Graphs.addAllVertices(g, Arrays.asList(1, 2, 3, 4, 5)); g.addEdge(1, 2); g.addEdge(1, 3); g.addEdge(1, 3); g.addEdge(1, 4); g.addEdge(1, 5); g.addEdge(2, 3); g.addEdge(3, 4); g.addEdge(3, 5); Coloring<Integer> coloring = new LargestDegreeFirstColoring<>(g).getColoring(); assertEquals(3, coloring.getNumberColors()); Map<Integer, Integer> colors = coloring.getColors(); assertEquals(0, colors.get(1).intValue()); assertEquals(2, colors.get(2).intValue()); assertEquals(1, colors.get(3).intValue()); assertEquals(2, colors.get(4).intValue()); assertEquals(2, colors.get(5).intValue()); } |
### Question:
SmallestDegreeLastColoring extends GreedyColoring<V, E> { public SmallestDegreeLastColoring(Graph<V, E> graph) { super(graph); } SmallestDegreeLastColoring(Graph<V, E> graph); }### Answer:
@Test public void testSmallestDegreeLastColoring() { Graph<Integer, DefaultEdge> g = createGraph1(); Coloring<Integer> coloring = new SmallestDegreeLastColoring<>(g).getColoring(); assertEquals(3, coloring.getNumberColors()); Map<Integer, Integer> colors = coloring.getColors(); assertEquals(2, colors.get(1).intValue()); assertEquals(0, colors.get(2).intValue()); assertEquals(1, colors.get(3).intValue()); assertEquals(0, colors.get(4).intValue()); assertEquals(0, colors.get(5).intValue()); } |
### Question:
GreedyColoring implements VertexColoringAlgorithm<V> { @Override public Coloring<V> getColoring() { int maxColor = -1; Map<V, Integer> colors = new HashMap<>(); Set<Integer> used = new HashSet<>(); for (V v : getVertexOrdering()) { for (E e : graph.edgesOf(v)) { V u = Graphs.getOppositeVertex(graph, e, v); if (v.equals(u)) { throw new IllegalArgumentException(SELF_LOOPS_NOT_ALLOWED); } if (colors.containsKey(u)) { used.add(colors.get(u)); } } int candidate = 0; while (used.contains(candidate)) { candidate++; } used.clear(); colors.put(v, candidate); maxColor = Math.max(maxColor, candidate); } return new ColoringImpl<>(colors, maxColor + 1); } GreedyColoring(Graph<V, E> graph); @Override Coloring<V> getColoring(); }### Answer:
@Test public void testGreedy() { Graph<Integer, DefaultEdge> g = createGraph1(); Coloring<Integer> coloring = new GreedyColoring<>(g).getColoring(); assertEquals(3, coloring.getNumberColors()); Map<Integer, Integer> colors = coloring.getColors(); assertEquals(0, colors.get(1).intValue()); assertEquals(1, colors.get(2).intValue()); assertEquals(2, colors.get(3).intValue()); assertEquals(1, colors.get(4).intValue()); assertEquals(1, colors.get(5).intValue()); } |
### Question:
HierholzerEulerianCycle implements EulerianCycleAlgorithm<V, E> { public GraphPath<V, E> getEulerianCycle(Graph<V, E> g) { if (!isEulerian(g)) { throw new IllegalArgumentException("Graph is not Eulerian"); } else if (g.vertexSet().size() == 0) { throw new IllegalArgumentException("Null graph not permitted"); } else if (GraphTests.isEmpty(g)) { return GraphWalk.emptyWalk(g); } initialize(g); while (verticesHead != null) { EdgeNode whereToInsert = verticesHead.insertLocation; Pair<EdgeNode, EdgeNode> partialCycle = computePartialCycle(); updateGraphAndInsertLocations(partialCycle, verticesHead); if (whereToInsert == null) { eulerianHead = partialCycle.getFirst(); } else { partialCycle.getSecond().next = whereToInsert.next; whereToInsert.next = partialCycle.getFirst(); } } GraphWalk<V, E> walk = buildWalk(); cleanup(); return walk; } boolean isEulerian(Graph<V, E> graph); GraphPath<V, E> getEulerianCycle(Graph<V, E> g); }### Answer:
@Test public void testEmptyWithSingleVertexUndirected() { Graph<Integer, DefaultEdge> g = new Pseudograph<>(DefaultEdge.class); g.addVertex(1); GraphPath<Integer, DefaultEdge> cycle = new HierholzerEulerianCycle<Integer, DefaultEdge>().getEulerianCycle(g); assertEulerian(cycle); }
@Test public void testEmptyMultipleVerticesUndirected() { Graph<Integer, DefaultEdge> g = new Pseudograph<>(DefaultEdge.class); g.addVertex(1); g.addVertex(2); g.addVertex(3); g.addVertex(4); g.addVertex(5); GraphPath<Integer, DefaultEdge> cycle = new HierholzerEulerianCycle<Integer, DefaultEdge>().getEulerianCycle(g); assertEulerian(cycle); }
@Test public void testEmptyWithSingleVertexDirected() { Graph<Integer, DefaultEdge> g = new DirectedPseudograph<>(DefaultEdge.class); g.addVertex(1); GraphPath<Integer, DefaultEdge> cycle = new HierholzerEulerianCycle<Integer, DefaultEdge>().getEulerianCycle(g); assertEulerian(cycle); }
@Test public void testEmptyMultipleVerticesDirected() { Graph<Integer, DefaultEdge> g = new DirectedPseudograph<>(DefaultEdge.class); g.addVertex(1); g.addVertex(2); g.addVertex(3); g.addVertex(4); g.addVertex(5); GraphPath<Integer, DefaultEdge> cycle = new HierholzerEulerianCycle<Integer, DefaultEdge>().getEulerianCycle(g); assertEulerian(cycle); } |
### Question:
Coreness implements VertexScoringAlgorithm<V, Integer> { @Override public Map<V, Integer> getScores() { lazyRun(); return Collections.unmodifiableMap(scores); } Coreness(Graph<V, E> g); @Override Map<V, Integer> getScores(); @Override Integer getVertexScore(V v); int getDegeneracy(); }### Answer:
@Test public void testEmptyGraph() { SimpleGraph<String, DefaultEdge> g = new SimpleGraph<>(DefaultEdge.class); VertexScoringAlgorithm<String, Integer> pr = new Coreness<>(g); assertTrue(pr.getScores().isEmpty()); } |
### Question:
ConceptMaps extends AbstractConceptMaps<ConceptMap, ConceptMaps> { public static ConceptMaps getEmpty(SparkSession spark) { Dataset<ConceptMap> emptyConceptMaps = spark.emptyDataset(CONCEPT_MAP_ENCODER) .withColumn("timestamp", lit(null).cast("timestamp")) .as(CONCEPT_MAP_ENCODER); return new ConceptMaps(spark, spark.emptyDataset(URL_AND_VERSION_ENCODER), emptyConceptMaps, spark.emptyDataset(MAPPING_ENCODER)); } protected ConceptMaps(SparkSession spark,
Dataset<UrlAndVersion> members,
Dataset<ConceptMap> conceptMaps,
Dataset<Mapping> mappings); static Encoder<Mapping> getMappingEncoder(); static Encoder<ConceptMap> getConceptMapEncoder(); static ConceptMaps getDefault(SparkSession spark); static ConceptMaps getFromDatabase(SparkSession spark, String databaseName); static ConceptMaps getEmpty(SparkSession spark); static List<Mapping> expandMappings(ConceptMap map); @Override ConceptMaps withConceptMaps(Dataset<ConceptMap> conceptMaps); @Override Broadcast<BroadcastableMappings> broadcast(Map<String,String> conceptMapUriToVersion); }### Answer:
@Test public void testWithMapsFromDirectoryXml() { ConceptMaps maps = ConceptMaps.getEmpty(spark) .withMapsFromDirectory("src/test/resources/xml/conceptmaps"); ConceptMap genderMap = maps.getConceptMap( "urn:cerner:poprec:fhir:conceptmap:demographics:gender", "0.0.1"); Assert.assertNotNull(genderMap); Assert.assertEquals("urn:cerner:poprec:fhir:conceptmap:demographics:gender", genderMap.getUrl()); Assert.assertEquals("0.0.1", genderMap.getVersion()); }
@Test public void testWithMapsFromDirectoryJson() { ConceptMaps maps = ConceptMaps.getEmpty(spark) .withMapsFromDirectory("src/test/resources/json/conceptmaps"); ConceptMap genderMap = maps.getConceptMap( "urn:cerner:poprec:fhir:conceptmap:demographics:gender", "0.0.1"); Assert.assertNotNull(genderMap); Assert.assertEquals("urn:cerner:poprec:fhir:conceptmap:demographics:gender", genderMap.getUrl()); Assert.assertEquals("0.0.1", genderMap.getVersion()); } |
### Question:
ConceptMaps extends AbstractConceptMaps<ConceptMap, ConceptMaps> { public static List<Mapping> expandMappings(ConceptMap map) { List<Mapping> mappings = new ArrayList<>(); expandMappingsIterator(map).forEachRemaining(mappings::add); return mappings; } protected ConceptMaps(SparkSession spark,
Dataset<UrlAndVersion> members,
Dataset<Row> conceptMaps,
Dataset<Mapping> mappings); static Encoder<Mapping> getMappingEncoder(); static SparkRowConverter getConceptMapConverter(); static ConceptMaps getDefault(SparkSession spark); static ConceptMaps getFromDatabase(SparkSession spark, String databaseName); static ConceptMaps getEmpty(SparkSession spark); static List<Mapping> expandMappings(ConceptMap map); @Override ConceptMaps withConceptMaps(Dataset<Row> conceptMaps); @Override Broadcast<BroadcastableMappings> broadcast(Map<String,String> conceptMapUriToVersion); }### Answer:
@Test public void testExpandMappings() { ConceptMap conceptMap = ConceptMaps.getEmpty(spark) .withConceptMaps(conceptMap("urn:cerner:conceptmap:map", "1")) .getConceptMap("urn:cerner:conceptmap:map", "1"); List<Mapping> mappings = ConceptMaps.expandMappings(conceptMap); Mapping expectedValue = new Mapping("urn:cerner:conceptmap:map", "1", "urn:source:valueset", "urn:target:valueset", "urn:source:system", "urn:source:code:a", "urn:target:system", "urn:target:code:1", Mapping.EQUIVALENT); Assert.assertEquals(1, mappings.size()); Assert.assertEquals(expectedValue, mappings.get(0)); } |
### Question:
ValueSets extends AbstractValueSets<ValueSet, ValueSets> { public static ValueSets getEmpty(SparkSession spark) { Dataset<Row> emptyValueSets = valuesetRowConverter.emptyDataFrame(spark) .withColumn("timestamp", lit(null).cast("timestamp")); return new ValueSets(spark, spark.emptyDataset(URL_AND_VERSION_ENCODER), emptyValueSets, spark.emptyDataset(getValueEncoder())); } private ValueSets(SparkSession spark,
Dataset<UrlAndVersion> members,
Dataset<Row> valueSets,
Dataset<Value> values); static ValueSets getDefault(SparkSession spark); static ValueSets getFromDatabase(SparkSession spark, String databaseName); static ValueSets getEmpty(SparkSession spark); @Override ValueSets withValueSets(Dataset<Row> valueSets); static List<Value> expandValues(ValueSet valueSet); }### Answer:
@Test public void testWithValueSetsFromDirectoryXml() { ValueSets valueSets = ValueSets.getEmpty(spark) .withValueSetsFromDirectory("src/test/resources/xml/valuesets"); ValueSet marriedValueSet = valueSets.getValueSet( "urn:cerner:bunsen:valueset:married_maritalstatus", "0.0.1"); Assert.assertNotNull(marriedValueSet); Assert.assertEquals("urn:cerner:bunsen:valueset:married_maritalstatus", marriedValueSet.getUrl()); Assert.assertEquals("0.0.1", marriedValueSet.getVersion()); }
@Test public void testWithValueSetsFromDirectoryJson() { ValueSets valueSets = ValueSets.getEmpty(spark) .withValueSetsFromDirectory("src/test/resources/json/valuesets"); ValueSet marriedValueSet = valueSets.getValueSet( "urn:cerner:bunsen:valueset:married_maritalstatus", "0.0.1"); Assert.assertNotNull(marriedValueSet); Assert.assertEquals("urn:cerner:bunsen:valueset:married_maritalstatus", marriedValueSet.getUrl()); Assert.assertEquals("0.0.1", marriedValueSet.getVersion()); } |
### Question:
ValueSets extends AbstractValueSets<ValueSet, ValueSets> { public static List<Value> expandValues(ValueSet valueSet) { List<Value> values = new ArrayList<>(); expandValuesIterator(valueSet).forEachRemaining(values::add); return values; } private ValueSets(SparkSession spark,
Dataset<UrlAndVersion> members,
Dataset<Row> valueSets,
Dataset<Value> values); static ValueSets getDefault(SparkSession spark); static ValueSets getFromDatabase(SparkSession spark, String databaseName); static ValueSets getEmpty(SparkSession spark); @Override ValueSets withValueSets(Dataset<Row> valueSets); static List<Value> expandValues(ValueSet valueSet); }### Answer:
@Test public void testExpandValues() { ValueSet valueSet = ValueSets.getEmpty(spark) .withValueSets(valueSet("urn:cerner:valueset:valueset", "1")) .getValueSet("urn:cerner:valueset:valueset", "1"); List<Value> values = ValueSets.expandValues(valueSet); Value expectedValue = new Value("urn:cerner:valueset:valueset", "1", "urn:cerner:system", "1", "a"); Assert.assertEquals(1, values.size()); Assert.assertEquals(expectedValue, values.get(0)); } |
### Question:
Functions { public static String resourceToJson(Resource resource) { IParser parser = CONTEXT.newJsonParser(); return parser.encodeResourceToString(resource); } static Dataset<String> toJson(Dataset<Row> dataset, String resourceTypeUrl); static Bundle toBundle(Dataset<Row> dataset,
String resourceTypeUrl); static String toJsonBundle(Dataset<Row> dataset, String resourceTypeUrl); static String resourceToXml(Resource resource); static String resourceToJson(Resource resource); }### Answer:
@Test public void resourceToJson() { Dataset<String> jsonDs = Functions.toJson(conditions, "Condition"); String conditionJson = jsonDs.first(); Condition parsedCondition = (Condition) CONTEXT.newJsonParser() .parseResource(conditionJson); Assert.assertEquals(condition.getId(), parsedCondition.getId()); } |
### Question:
Functions { public static String toJsonBundle(Dataset<Row> dataset, String resourceTypeUrl) { Bundle bundle = toBundle(dataset, resourceTypeUrl); return CONTEXT.newJsonParser().encodeResourceToString(bundle); } static Dataset<String> toJson(Dataset<Row> dataset, String resourceTypeUrl); static Bundle toBundle(Dataset<Row> dataset,
String resourceTypeUrl); static String toJsonBundle(Dataset<Row> dataset, String resourceTypeUrl); static String resourceToXml(Resource resource); static String resourceToJson(Resource resource); }### Answer:
@Test public void bundleToJson() { String jsonBundle = Functions.toJsonBundle(conditions, "Condition"); Bundle bundle = (Bundle) CONTEXT.newJsonParser().parseResource(jsonBundle); Condition parsedCondition = (Condition) bundle.getEntryFirstRep().getResource(); Assert.assertEquals(condition.getId(), parsedCondition.getId()); } |
### Question:
GenerateSchemas { public static int main(String[] args) { if (args.length < 2) { System.out.println("Usage: GenerateSchemas <output file> resourceTypeUrls..."); System.out.println("Example:"); System.out.println(" GenerateSchemas my_schemas.avsc " + "http: + "http: System.out.println(); System.out.println("The resulting avsc file then can be used to generate Java classes " + "using avro-tools, for example:"); System.out.println(" avro-tools compile protocol my_schemas.avsc <target_directory>"); return 1; } File outputFile = new File(args[0]); if (outputFile.exists()) { System.out.println("File " + outputFile.getName() + " already exists."); return 1; } Map<String, List<String>> resourceTypeUrls = Arrays.stream(args) .skip(1) .collect(Collectors.toMap(Function.identity(), item -> Collections.emptyList())); List<Schema> schemas = AvroConverter.generateSchemas(FhirContexts.forStu3(), resourceTypeUrls); Protocol protocol = new Protocol("FhirGeneratedSchemas", "Avro schemas generated from FHIR StructureDefinitions", "com.cerner.bunsen.avro"); protocol.setTypes(schemas); try { Files.write(outputFile.toPath(), protocol.toString(true).getBytes()); } catch (IOException exception) { System.out.println("Unable to write file " + outputFile.getPath()); exception.printStackTrace(); return 1; } return 0; } static int main(String[] args); }### Answer:
@Test public void testWriteSchema() throws IOException { Path generatedCodePath = Files.createTempDirectory("schema_directory"); generatedCodePath.toFile().deleteOnExit(); Path outputFile = generatedCodePath.resolve("out.asvc"); int result = GenerateSchemas.main(new String[] {outputFile.toString(), TestData.US_CORE_PATIENT, TestData.US_CORE_CONDITION, TestData.US_CORE_MEDICATION, TestData.US_CORE_MEDICATION_REQUEST}); Assert.assertEquals(0, result); Assert.assertTrue(outputFile.toFile().exists()); } |
### Question:
AvroConverter { public static List<Schema> generateSchemas(FhirContext context, Map<String, List<String>> resourceTypeUrls) { StructureDefinitions structureDefinitions = StructureDefinitions.create(context); Map<String, HapiConverter<Schema>> converters = new HashMap<>(); for (Entry<String, List<String>> resourceTypeUrlEntry: resourceTypeUrls.entrySet()) { visitResource(context, structureDefinitions, resourceTypeUrlEntry.getKey(), resourceTypeUrlEntry.getValue(), converters); } return converters.values() .stream() .map(HapiConverter::getDataType) .collect(Collectors.toList()); } private AvroConverter(HapiConverter<Schema> hapiToAvroConverter,
RuntimeResourceDefinition... resources); static List<Schema> generateSchemas(FhirContext context,
Map<String, List<String>> resourceTypeUrls); static AvroConverter forResource(FhirContext context,
String resourceTypeUrl); static AvroConverter forResource(FhirContext context,
String resourceTypeUrl,
List<String> containedResourceTypeUrls); IndexedRecord resourceToAvro(IBaseResource resource); IBaseResource avroToResource(IndexedRecord record); Schema getSchema(); String getResourceType(); }### Answer:
@Test public void testCompile() throws IOException { List<Schema> schemas = AvroConverter.generateSchemas(FhirContexts.forStu3(), ImmutableMap.of(TestData.US_CORE_PATIENT, Collections.emptyList(), TestData.VALUE_SET, Collections.emptyList(), TestData.US_CORE_MEDICATION_REQUEST, ImmutableList.of(TestData.US_CORE_MEDICATION))); Protocol protocol = new Protocol("fhir-test", "FHIR Resources for Testing", null); protocol.setTypes(schemas); SpecificCompiler compiler = new SpecificCompiler(protocol); Path generatedCodePath = Files.createTempDirectory("generated_code"); generatedCodePath.toFile().deleteOnExit(); compiler.compileToDestination(null, generatedCodePath.toFile()); Set<String> javaFiles = Files.find(generatedCodePath, 10, (path, basicFileAttributes) -> true) .map(path -> generatedCodePath.relativize(path)) .map(Object::toString) .collect(Collectors.toSet()); Assert.assertTrue(javaFiles.contains("com/cerner/bunsen/stu3/avro/Period.java")); Assert.assertTrue(javaFiles.contains("com/cerner/bunsen/stu3/avro/Coding.java")); Assert.assertTrue(javaFiles.contains("com/cerner/bunsen/stu3/avro/ValueSet.java")); Assert.assertTrue(javaFiles.contains("com/cerner/bunsen/stu3/avro/us/core/Patient.java")); Assert.assertTrue(javaFiles.contains("com/cerner/bunsen/stu3/avro/us/core/UsCoreRace.java")); Assert.assertTrue(javaFiles.contains("com/cerner/bunsen/stu3/avro/ChoiceBooleanInteger.java")); Assert.assertTrue(javaFiles.contains( "com/cerner/bunsen/stu3/avro/us/core/MedicationRequestContained.java")); } |
### Question:
ConceptMaps extends AbstractConceptMaps<ConceptMap, ConceptMaps> { public static List<Mapping> expandMappings(ConceptMap map) { List<Mapping> mappings = new ArrayList<>(); expandMappingsIterator(map).forEachRemaining(mappings::add); return mappings; } protected ConceptMaps(SparkSession spark,
Dataset<UrlAndVersion> members,
Dataset<ConceptMap> conceptMaps,
Dataset<Mapping> mappings); static Encoder<Mapping> getMappingEncoder(); static Encoder<ConceptMap> getConceptMapEncoder(); static ConceptMaps getDefault(SparkSession spark); static ConceptMaps getFromDatabase(SparkSession spark, String databaseName); static ConceptMaps getEmpty(SparkSession spark); static List<Mapping> expandMappings(ConceptMap map); @Override ConceptMaps withConceptMaps(Dataset<ConceptMap> conceptMaps); @Override Broadcast<BroadcastableMappings> broadcast(Map<String,String> conceptMapUriToVersion); }### Answer:
@Test public void testExpandMappings() { ConceptMap conceptMap = ConceptMaps.getEmpty(spark) .withConceptMaps(conceptMap("urn:cerner:conceptmap:map", "1")) .getConceptMap("urn:cerner:conceptmap:map", "1"); List<Mapping> mappings = ConceptMaps.expandMappings(conceptMap); Mapping expectedValue = new Mapping("urn:cerner:conceptmap:map", "1", "urn:source:valueset", "urn:target:valueset", "urn:source:system", "urn:source:code:a", "urn:target:system", "urn:target:code:1", Mapping.EQUIVALENT); Assert.assertEquals(1, mappings.size()); Assert.assertEquals(expectedValue, mappings.get(0)); } |
### Question:
ValueSets extends AbstractValueSets<ValueSet, ValueSets> { public static ValueSets getEmpty(SparkSession spark) { Dataset<ValueSet> emptyValueSets = spark.emptyDataset(VALUE_SET_ENCODER) .withColumn("timestamp", lit(null).cast("timestamp")) .as(VALUE_SET_ENCODER); return new ValueSets(spark, spark.emptyDataset(URL_AND_VERSION_ENCODER), emptyValueSets, spark.emptyDataset(getValueEncoder())); } private ValueSets(SparkSession spark,
Dataset<UrlAndVersion> members,
Dataset<ValueSet> valueSets,
Dataset<Value> values); static Encoder<ValueSet> getValueSetEncoder(); static ValueSets getDefault(SparkSession spark); static ValueSets getFromDatabase(SparkSession spark, String databaseName); static ValueSets getEmpty(SparkSession spark); @Override ValueSets withValueSets(Dataset<ValueSet> valueSets); static List<Value> expandValues(ValueSet valueSet); }### Answer:
@Test public void testWithValueSetsFromDirectoryXml() { ValueSets valueSets = ValueSets.getEmpty(spark) .withValueSetsFromDirectory("src/test/resources/xml/valuesets"); ValueSet marriedValueSet = valueSets.getValueSet( "urn:cerner:bunsen:valueset:married_maritalstatus", "0.0.1"); Assert.assertNotNull(marriedValueSet); Assert.assertEquals("urn:cerner:bunsen:valueset:married_maritalstatus", marriedValueSet.getUrl()); Assert.assertEquals("0.0.1", marriedValueSet.getVersion()); }
@Test public void testWithValueSetsFromDirectoryJson() { ValueSets valueSets = ValueSets.getEmpty(spark) .withValueSetsFromDirectory("src/test/resources/json/valuesets"); ValueSet marriedValueSet = valueSets.getValueSet( "urn:cerner:bunsen:valueset:married_maritalstatus", "0.0.1"); Assert.assertNotNull(marriedValueSet); Assert.assertEquals("urn:cerner:bunsen:valueset:married_maritalstatus", marriedValueSet.getUrl()); Assert.assertEquals("0.0.1", marriedValueSet.getVersion()); } |
### Question:
ValueSets extends AbstractValueSets<ValueSet, ValueSets> { public static List<Value> expandValues(ValueSet valueSet) { List<Value> values = new ArrayList<>(); expandValuesIterator(valueSet).forEachRemaining(values::add); return values; } private ValueSets(SparkSession spark,
Dataset<UrlAndVersion> members,
Dataset<ValueSet> valueSets,
Dataset<Value> values); static Encoder<ValueSet> getValueSetEncoder(); static ValueSets getDefault(SparkSession spark); static ValueSets getFromDatabase(SparkSession spark, String databaseName); static ValueSets getEmpty(SparkSession spark); @Override ValueSets withValueSets(Dataset<ValueSet> valueSets); static List<Value> expandValues(ValueSet valueSet); }### Answer:
@Test public void testExpandValues() { ValueSet valueSet = ValueSets.getEmpty(spark) .withValueSets(valueSet("urn:cerner:valueset:valueset", "1")) .getValueSet("urn:cerner:valueset:valueset", "1"); List<Value> values = ValueSets.expandValues(valueSet); Value expectedValue = new Value("urn:cerner:valueset:valueset", "1", "urn:cerner:system", "1", "a"); Assert.assertEquals(1, values.size()); Assert.assertEquals(expectedValue, values.get(0)); } |
### Question:
Functions { public static String resourceToJson(Resource resource) { IParser parser = CONTEXT.newJsonParser(); return parser.encodeResourceToString(resource); } static Dataset<String> toJson(Dataset<?> dataset, String resourceType); static Bundle toBundle(Dataset<? extends Resource> dataset); static String toJsonBundle(Dataset<? extends Resource> dataset); static String resourceToXml(Resource resource); static String resourceToJson(Resource resource); }### Answer:
@Test public void resourceToJson() { Dataset<String> jsonDs = Functions.toJson(conditions, "condition"); String conditionJson = jsonDs.first(); Condition parsedCondition = (Condition) CONTEXT.newJsonParser() .parseResource(conditionJson); Assert.assertEquals(condition.getId(), parsedCondition.getId()); } |
### Question:
Functions { public static String toJsonBundle(Dataset<? extends Resource> dataset) { Bundle bundle = toBundle(dataset); return CONTEXT.newJsonParser().encodeResourceToString(bundle); } static Dataset<String> toJson(Dataset<?> dataset, String resourceType); static Bundle toBundle(Dataset<? extends Resource> dataset); static String toJsonBundle(Dataset<? extends Resource> dataset); static String resourceToXml(Resource resource); static String resourceToJson(Resource resource); }### Answer:
@Test public void bundleToJson() { String jsonBundle = Functions.toJsonBundle(conditions); Bundle bundle = (Bundle) CONTEXT.newJsonParser().parseResource(jsonBundle); Condition parsedCondition = (Condition) bundle.getEntryFirstRep().getResource(); Assert.assertEquals(condition.getId(), parsedCondition.getId()); } |
### Question:
ConceptMaps extends AbstractConceptMaps<ConceptMap, ConceptMaps> { public static ConceptMaps getEmpty(SparkSession spark) { Dataset<Row> emptyConceptMaps = conceptMapConverter.emptyDataFrame(spark) .withColumn("timestamp", lit(null).cast("timestamp")); return new ConceptMaps(spark, spark.emptyDataset(URL_AND_VERSION_ENCODER), emptyConceptMaps, spark.emptyDataset(MAPPING_ENCODER)); } protected ConceptMaps(SparkSession spark,
Dataset<UrlAndVersion> members,
Dataset<Row> conceptMaps,
Dataset<Mapping> mappings); static Encoder<Mapping> getMappingEncoder(); static SparkRowConverter getConceptMapConverter(); static ConceptMaps getDefault(SparkSession spark); static ConceptMaps getFromDatabase(SparkSession spark, String databaseName); static ConceptMaps getEmpty(SparkSession spark); static List<Mapping> expandMappings(ConceptMap map); @Override ConceptMaps withConceptMaps(Dataset<Row> conceptMaps); @Override Broadcast<BroadcastableMappings> broadcast(Map<String,String> conceptMapUriToVersion); }### Answer:
@Test public void testWithMapsFromDirectoryXml() { ConceptMaps maps = ConceptMaps.getEmpty(spark) .withMapsFromDirectory("src/test/resources/xml/conceptmaps"); ConceptMap genderMap = maps.getConceptMap( "urn:cerner:poprec:fhir:conceptmap:demographics:gender", "0.0.1"); Assert.assertNotNull(genderMap); Assert.assertEquals("urn:cerner:poprec:fhir:conceptmap:demographics:gender", genderMap.getUrl()); Assert.assertEquals("0.0.1", genderMap.getVersion()); }
@Test public void testWithMapsFromDirectoryJson() { ConceptMaps maps = ConceptMaps.getEmpty(spark) .withMapsFromDirectory("src/test/resources/json/conceptmaps"); ConceptMap genderMap = maps.getConceptMap( "urn:cerner:poprec:fhir:conceptmap:demographics:gender", "0.0.1"); Assert.assertNotNull(genderMap); Assert.assertEquals("urn:cerner:poprec:fhir:conceptmap:demographics:gender", genderMap.getUrl()); Assert.assertEquals("0.0.1", genderMap.getVersion()); } |
### Question:
S2Controller extends DefaultSubscriber<Response> { public static Builder starcraft2Game() { return new Builder(); } private S2Controller(Config config); static Builder starcraft2Game(); S2Controller untilReady(); void stop(); boolean stopAndWait(); boolean stopAndWait(long timeoutInMillis); void isInState(GameStatus expectedStatus); boolean inState(GameStatus expectedStatus); Config getConfig(); @Override void onNext(Response response); @Override void onComplete(); @Override void onError(Throwable e); S2Controller relaunchIfNeeded(int baseBuild, String dataVersion); void restart(); Process getS2Process(); }### Answer:
@Test void throwsExceptionWhenExecuteInfoIsNotFound() { assertThatExceptionOfType(StarCraft2ControllerException.class) .isThrownBy(() -> starcraft2Game().getGameConfiguration()) .withMessage("Invalid argument was provided") .withCause(new IllegalArgumentException("ExecuteInfo.txt is required")); }
@Test void throwsExceptionWhenExecutablePathDoesNotExist() { asWindows(); userHome.newFile(WIN_USER_DIR.resolve("Starcraft II"), EXECUTE_INFO_TXT); assertThatExceptionOfType(StarCraft2ControllerException.class) .isThrownBy(() -> starcraft2Game().getGameConfiguration()) .withMessage("Invalid argument was provided") .withCause(new IllegalArgumentException("executable path is required")); }
@Test void throwsExceptionWhenExecutablePathIsTooShort() { asWindows(); userHome.newFile(WIN_USER_DIR.resolve("Starcraft II"), EXECUTE_INFO_TXT); assertThatExceptionOfType(StarCraft2ControllerException.class) .isThrownBy(() -> starcraft2Game().withExecutablePath(Paths.get("sc2")).getGameConfiguration()) .withMessage("Invalid path to the executable file: sc2"); }
@Test void managesConfigurationOfManyGameInstances() throws IOException { asWindows(); initStarcraft2Executable(WIN_USER_DIR); Config instance01 = starcraft2Game().getGameConfiguration(); Config instance02 = starcraft2Game().getGameConfiguration(); Config instance03 = starcraft2Game().getGameConfiguration(); Config instance04 = starcraft2Game().getGameConfiguration(); Config instance05 = starcraft2Game().getGameConfiguration(); assertThat(instance01.getInt(GAME_WINDOW_X)).as("game instance 01 window.x").isEqualTo(CFG_WINDOW_X); assertThat(instance01.getInt(GAME_WINDOW_Y)).as("game instance 01 window.y").isEqualTo(CFG_WINDOW_Y); assertThat(instance02.getInt(GAME_WINDOW_X)).as("game instance 02 window.x") .isEqualTo(CFG_WINDOW_X + CFG_WINDOW_W); assertThat(instance02.getInt(GAME_WINDOW_Y)).as("game instance 02 window.y").isEqualTo(CFG_WINDOW_Y); assertThat(instance03.getInt(GAME_WINDOW_X)).as("game instance 03 window.x").isEqualTo(CFG_WINDOW_X); assertThat(instance03.getInt(GAME_WINDOW_Y)).as("game instance 03 window.y") .isEqualTo(CFG_WINDOW_Y + CFG_WINDOW_H); assertThat(instance04.getInt(GAME_WINDOW_X)).as("game instance 04 window.x") .isEqualTo(CFG_WINDOW_X + CFG_WINDOW_W); assertThat(instance04.getInt(GAME_WINDOW_Y)).as("game instance 04 window.y") .isEqualTo(CFG_WINDOW_Y + CFG_WINDOW_H); assertThat(instance05.getInt(GAME_WINDOW_X)).as("game instance 05 window.x").isEqualTo(CFG_WINDOW_X); assertThat(instance05.getInt(GAME_WINDOW_Y)).as("game instance 05 window.y").isEqualTo(CFG_WINDOW_Y); } |
### Question:
FeatureLayersMinimap implements Serializable { public static FeatureLayersMinimap from(Spatial.FeatureLayersMinimap sc2ApiFeatureLayersMinimap) { require("sc2api feature layers minimap", sc2ApiFeatureLayersMinimap); return new FeatureLayersMinimap(sc2ApiFeatureLayersMinimap); } private FeatureLayersMinimap(Spatial.FeatureLayersMinimap sc2ApiFeatureLayersMinimap); static FeatureLayersMinimap from(Spatial.FeatureLayersMinimap sc2ApiFeatureLayersMinimap); ImageData getHeightMap(); ImageData getVisibilityMap(); ImageData getCreep(); ImageData getCamera(); ImageData getPlayerId(); ImageData getPlayerRelative(); ImageData getSelected(); Optional<ImageData> getAlerts(); Optional<ImageData> getBuildable(); Optional<ImageData> getPathable(); Optional<ImageData> getUnitType(); @Override boolean equals(Object o); @Override int hashCode(); @Override String toString(); }### Answer:
@Test void throwsExceptionWhenPlayerRelativeIsNotProvided() { assertThatExceptionOfType(IllegalArgumentException.class) .isThrownBy(() -> FeatureLayersMinimap.from(without( () -> sc2ApiFeatureLayersMinimap().toBuilder(), Spatial.FeatureLayersMinimap.Builder::clearPlayerRelative).build())) .withMessage("player relative is required"); }
@Test void throwsExceptionWhenSc2ApiFeatureLayersMinimapIsNull() { assertThatExceptionOfType(IllegalArgumentException.class) .isThrownBy(() -> FeatureLayersMinimap.from(nothing())) .withMessage("sc2api feature layers minimap is required"); }
@Test void convertsAllFieldsFromSc2ApiFeatureLayersMinimap() { assertThatAllFieldsAreConverted(FeatureLayersMinimap.from(sc2ApiFeatureLayersMinimap())); }
@Test void throwsExceptionWhenHeightMapIsNotProvided() { assertThatExceptionOfType(IllegalArgumentException.class) .isThrownBy(() -> FeatureLayersMinimap.from(without( () -> sc2ApiFeatureLayersMinimap().toBuilder(), Spatial.FeatureLayersMinimap.Builder::clearHeightMap).build())) .withMessage("height map is required"); }
@Test void throwsExceptionWhenVisibilityMapIsNotProvided() { assertThatExceptionOfType(IllegalArgumentException.class) .isThrownBy(() -> FeatureLayersMinimap.from(without( () -> sc2ApiFeatureLayersMinimap().toBuilder(), Spatial.FeatureLayersMinimap.Builder::clearVisibilityMap).build())) .withMessage("visibility map is required"); }
@Test void throwsExceptionWhenCreepIsNotProvided() { assertThatExceptionOfType(IllegalArgumentException.class) .isThrownBy(() -> FeatureLayersMinimap.from(without( () -> sc2ApiFeatureLayersMinimap().toBuilder(), Spatial.FeatureLayersMinimap.Builder::clearCreep).build())) .withMessage("creep is required"); }
@Test void throwsExceptionWhenCameraIsNotProvided() { assertThatExceptionOfType(IllegalArgumentException.class) .isThrownBy(() -> FeatureLayersMinimap.from(without( () -> sc2ApiFeatureLayersMinimap().toBuilder(), Spatial.FeatureLayersMinimap.Builder::clearCamera).build())) .withMessage("camera is required"); }
@Test void throwsExceptionWhenPlayerIdIsNotProvided() { assertThatExceptionOfType(IllegalArgumentException.class) .isThrownBy(() -> FeatureLayersMinimap.from(without( () -> sc2ApiFeatureLayersMinimap().toBuilder(), Spatial.FeatureLayersMinimap.Builder::clearPlayerId).build())) .withMessage("player id is required"); }
@Test void throwsExceptionWhenSelectedIsNotProvided() { assertThatExceptionOfType(IllegalArgumentException.class) .isThrownBy(() -> FeatureLayersMinimap.from(without( () -> sc2ApiFeatureLayersMinimap().toBuilder(), Spatial.FeatureLayersMinimap.Builder::clearSelected).build())) .withMessage("selected is required"); } |
### Question:
ImageData implements Serializable { public static ImageData from(Common.ImageData sc2ApiImageData) { require("sc2api image data", sc2ApiImageData); return new ImageData(sc2ApiImageData); } private ImageData(Common.ImageData sc2ApiImageData); static ImageData from(Common.ImageData sc2ApiImageData); int getBitsPerPixel(); Size2dI getSize(); @JsonIgnore byte[] getData(); @JsonIgnore BufferedImage getImage(); int sample(Point2d point, Origin origin); int sample(Point2d point); @Override boolean equals(Object o); @Override int hashCode(); @Override String toString(); }### Answer:
@Test void throwsExceptionWhenSc2ApiImageDataIsNull() { assertThatExceptionOfType(IllegalArgumentException.class) .isThrownBy(() -> ImageData.from(nothing())) .withMessage("sc2api image data is required"); }
@Test void convertsAllFieldsFromSc2ApiImageData() { assertThatAllFieldsAreConverted(ImageData.from(sc2ApiImageData())); }
@Test void throwsExceptionWhenBitsPerPixelIsNotProvided() { assertThatExceptionOfType(IllegalArgumentException.class) .isThrownBy(() -> ImageData.from(without( () -> sc2ApiImageData().toBuilder(), Common.ImageData.Builder::clearBitsPerPixel).build())) .withMessage("bits per pixel is required"); }
@Test void throwsExceptionWhenSizeIsNotProvided() { assertThatExceptionOfType(IllegalArgumentException.class) .isThrownBy(() -> ImageData.from(without( () -> sc2ApiImageData().toBuilder(), Common.ImageData.Builder::clearSize).build())) .withMessage("size is required"); }
@Test void throwsExceptionWhenImageIsNotProvided() { assertThatExceptionOfType(IllegalArgumentException.class) .isThrownBy(() -> ImageData.from(without( () -> sc2ApiImageData().toBuilder(), Common.ImageData.Builder::clearData).build())) .withMessage("data is required"); }
@Test void throwsExceptionWhenImageSizeIsInvalid() { assertThatExceptionOfType(IllegalArgumentException.class) .isThrownBy(() -> ImageData.from(corruptedSc2ApiImageData())) .withMessage("expected image size [4096] is not equal actual size [1]"); }
@Test void throwsExceptionWhenImageTypeIsUnsupported() { assertThatExceptionOfType(IllegalArgumentException.class) .isThrownBy(() -> ImageData.from(sc2ApiImageDataWithTwoBitPerPixel())) .withMessage("Unsupported image type with bits per pixel [2]. Expected {1, 8, 24, 32}."); } |
### Question:
ObservationFeatureLayer implements Serializable { public static ObservationFeatureLayer from(Spatial.ObservationFeatureLayer sc2ApiObservationFeatureLayer) { require("sc2api observation feature layer", sc2ApiObservationFeatureLayer); return new ObservationFeatureLayer(sc2ApiObservationFeatureLayer); } private ObservationFeatureLayer(Spatial.ObservationFeatureLayer sc2ApiObservationFeatureLayer); static ObservationFeatureLayer from(Spatial.ObservationFeatureLayer sc2ApiObservationFeatureLayer); FeatureLayers getRenders(); FeatureLayersMinimap getMinimapRenders(); @Override boolean equals(Object o); @Override int hashCode(); @Override String toString(); }### Answer:
@Test void throwsExceptionWhenSc2ApiObservationFeatureLayerIsNull() { assertThatExceptionOfType(IllegalArgumentException.class) .isThrownBy(() -> ObservationFeatureLayer.from(nothing())) .withMessage("sc2api observation feature layer is required"); }
@Test void convertsAllFieldsFromSc2ApiObservationFeatureLayer() { assertThatAllFieldsAreConverted(ObservationFeatureLayer.from(sc2ApiObservationFeatureLayer())); }
@Test void throwsExceptionWhenRendersIsNotProvided() { assertThatExceptionOfType(IllegalArgumentException.class) .isThrownBy(() -> ObservationFeatureLayer.from(without( () -> sc2ApiObservationFeatureLayer().toBuilder(), Spatial.ObservationFeatureLayer.Builder::clearRenders).build())) .withMessage("renders is required"); }
@Test void throwsExceptionWhenMinimapRendersIsNotProvided() { assertThatExceptionOfType(IllegalArgumentException.class) .isThrownBy(() -> ObservationFeatureLayer.from(without( () -> sc2ApiObservationFeatureLayer().toBuilder(), Spatial.ObservationFeatureLayer.Builder::clearMinimapRenders).build())) .withMessage("minimap renders is required"); } |
### Question:
EffectData implements Serializable { public static EffectData from(Data.EffectData sc2ApiEffectData) { require("sc2api effect data", sc2ApiEffectData); return new EffectData(sc2ApiEffectData); } private EffectData(Data.EffectData sc2ApiEffectData); static EffectData from(Data.EffectData sc2ApiEffectData); Effect getEffect(); String getName(); String getFriendlyName(); float getRadius(); @Override boolean equals(Object o); @Override int hashCode(); @Override String toString(); }### Answer:
@Test void throwsExceptionWhenFriendlyNameIsNotProvided() { assertThatExceptionOfType(IllegalArgumentException.class) .isThrownBy(() -> EffectData.from(without( () -> sc2ApiEffectData().toBuilder(), Data.EffectData.Builder::clearFriendlyName).build())) .withMessage("friendly name is required"); }
@Test void throwsExceptionWhenRadiusIsNotProvided() { assertThatExceptionOfType(IllegalArgumentException.class) .isThrownBy(() -> EffectData.from(without( () -> sc2ApiEffectData().toBuilder(), Data.EffectData.Builder::clearRadius).build())) .withMessage("radius is required"); }
@Test void throwsExceptionWhenSc2ApiEffectDataIsNull() { assertThatExceptionOfType(IllegalArgumentException.class) .isThrownBy(() -> EffectData.from(nothing())) .withMessage("sc2api effect data is required"); }
@Test void convertsAllFieldsFromSc2ApiUnit() { assertThatAllFieldsAreConverted(EffectData.from(sc2ApiEffectData())); }
@Test void throwsExceptionWhenEffectIsNotProvided() { assertThatExceptionOfType(IllegalArgumentException.class) .isThrownBy(() -> EffectData.from(without( () -> sc2ApiEffectData().toBuilder(), Data.EffectData.Builder::clearEffectId).build())) .withMessage("effect is required"); }
@Test void throwsExceptionWhenNameIsNotProvided() { assertThatExceptionOfType(IllegalArgumentException.class) .isThrownBy(() -> EffectData.from(without( () -> sc2ApiEffectData().toBuilder(), Data.EffectData.Builder::clearName).build())) .withMessage("name is required"); } |
### Question:
ObservationRender implements Serializable { public static ObservationRender from(Spatial.ObservationRender sc2ApiObservationRender) { require("sc2api observation render", sc2ApiObservationRender); return new ObservationRender(sc2ApiObservationRender); } private ObservationRender(Spatial.ObservationRender sc2ApiObservationRender); static ObservationRender from(Spatial.ObservationRender sc2ApiObservationRender); ImageData getMap(); ImageData getMinimap(); @Override boolean equals(Object o); @Override int hashCode(); @Override String toString(); }### Answer:
@Test void throwsExceptionWhenSc2ApiObservationRenderIsNull() { assertThatExceptionOfType(IllegalArgumentException.class) .isThrownBy(() -> ObservationRender.from(nothing())) .withMessage("sc2api observation render is required"); }
@Test void convertsAllFieldsFromSc2ApiObservationRender() { assertThatAllFieldsAreConverted(ObservationRender.from(sc2ApiObservationRender())); }
@Test void throwsExceptionWhenMapIsNotProvided() { assertThatExceptionOfType(IllegalArgumentException.class) .isThrownBy(() -> ObservationRender.from(without( () -> sc2ApiObservationRender().toBuilder(), Spatial.ObservationRender.Builder::clearMap).build())) .withMessage("map is required"); }
@Test void throwsExceptionWhenMinimapIsNotProvided() { assertThatExceptionOfType(IllegalArgumentException.class) .isThrownBy(() -> ObservationRender.from(without( () -> sc2ApiObservationRender().toBuilder(), Spatial.ObservationRender.Builder::clearMinimap).build())) .withMessage("minimap is required"); } |
### Question:
DamageBonus implements Serializable { public static DamageBonus from(Data.DamageBonus sc2ApiDamageBonus) { require("sc2api damage bonus", sc2ApiDamageBonus); return new DamageBonus(sc2ApiDamageBonus); } private DamageBonus(Data.DamageBonus sc2ApiDamageBonus); static DamageBonus from(Data.DamageBonus sc2ApiDamageBonus); UnitAttribute getAttribute(); float getBonus(); @Override boolean equals(Object o); @Override int hashCode(); @Override String toString(); }### Answer:
@Test void throwsExceptionWhenSc2ApiDamageBonusIsNull() { assertThatExceptionOfType(IllegalArgumentException.class) .isThrownBy(() -> DamageBonus.from(nothing())) .withMessage("sc2api damage bonus is required"); }
@Test void convertsAllFieldsFromSc2ApiDamageBonus() { assertThatAllFieldsAreConverted(DamageBonus.from(sc2ApiDamageBonus())); }
@Test void throwsExceptionWhenAttributeIsNotProvided() { assertThatExceptionOfType(IllegalArgumentException.class) .isThrownBy(() -> DamageBonus.from(without( () -> sc2ApiDamageBonus().toBuilder(), Data.DamageBonus.Builder::clearAttribute).build())) .withMessage("attribute is required"); }
@Test void throwsExceptionWhenBonusIsNotProvided() { assertThatExceptionOfType(IllegalArgumentException.class) .isThrownBy(() -> DamageBonus.from(without( () -> sc2ApiDamageBonus().toBuilder(), Data.DamageBonus.Builder::clearBonus).build())) .withMessage("bonus is required"); } |
### Question:
MultiPanel implements Serializable { public static MultiPanel from(Ui.MultiPanel sc2ApiMultiPanel) { require("sc2api multi panel", sc2ApiMultiPanel); return new MultiPanel(sc2ApiMultiPanel); } private MultiPanel(Ui.MultiPanel sc2ApiMultiPanel); static MultiPanel from(Ui.MultiPanel sc2ApiMultiPanel); List<UnitInfo> getUnits(); @Override boolean equals(Object o); @Override int hashCode(); @Override String toString(); }### Answer:
@Test void throwsExceptionWhenSc2ApiMultiPanelIsNull() { assertThatExceptionOfType(IllegalArgumentException.class) .isThrownBy(() -> MultiPanel.from(nothing())) .withMessage("sc2api multi panel is required"); }
@Test void convertsAllFieldsFromSc2ApiMultiPanel() { assertThatAllFieldsAreConverted(MultiPanel.from(sc2ApiMultiPanel())); }
@Test void fulfillsEqualsContract() { EqualsVerifier .forClass(MultiPanel.class) .withNonnullFields("units") .withPrefabValues(UnitInfo.class, UnitInfo.from(sc2ApiUnitInfoAddOn()), UnitInfo.from(sc2ApiUnitInfo())) .verify(); } |
### Question:
SinglePanel implements Serializable { public static SinglePanel from(Ui.SinglePanel sc2ApiSinglePanel) { require("sc2api single panel", sc2ApiSinglePanel); return new SinglePanel(sc2ApiSinglePanel); } private SinglePanel(Ui.SinglePanel sc2ApiSinglePanel); static SinglePanel from(Ui.SinglePanel sc2ApiSinglePanel); UnitInfo getUnit(); Optional<Integer> getAttackUpgradeLevel(); Optional<Integer> getArmorUpgradeLevel(); Optional<Integer> getShieldUpgradeLevel(); Set<Buff> getBuffs(); @Override boolean equals(Object o); @Override int hashCode(); @Override String toString(); }### Answer:
@Test void throwsExceptionWhenSc2ApiSinglePanelIsNull() { assertThatExceptionOfType(IllegalArgumentException.class) .isThrownBy(() -> SinglePanel.from(nothing())) .withMessage("sc2api single panel is required"); }
@Test void convertsAllFieldsFromSc2ApiSinglePanel() { assertThatAllFieldsAreConverted(SinglePanel.from(sc2ApiSinglePanel())); }
@Test void throwsExceptionWhenTagIsNotProvided() { assertThatExceptionOfType(IllegalArgumentException.class) .isThrownBy(() -> SinglePanel.from( without(() -> sc2ApiSinglePanel().toBuilder(), Ui.SinglePanel.Builder::clearUnit).build())) .withMessage("unit is required"); }
@Test void fulfillsEqualsContract() { EqualsVerifier .forClass(SinglePanel.class) .withNonnullFields("unit", "buffs") .withPrefabValues(UnitInfo.class, UnitInfo.from(sc2ApiUnitInfoAddOn()), UnitInfo.from(sc2ApiUnitInfo())) .verify(); } |
### Question:
ProductionPanel implements Serializable { public static ProductionPanel from(Ui.ProductionPanel sc2ApiProductionPanel) { require("sc2api production panel", sc2ApiProductionPanel); return new ProductionPanel(sc2ApiProductionPanel); } private ProductionPanel(Ui.ProductionPanel sc2ApiProductionPanel); static ProductionPanel from(Ui.ProductionPanel sc2ApiProductionPanel); UnitInfo getUnit(); List<UnitInfo> getBuildQueue(); List<BuildItem> getProductionQueue(); @Override boolean equals(Object o); @Override int hashCode(); @Override String toString(); }### Answer:
@Test void throwsExceptionWhenSc2ApiProductionPanelIsNull() { assertThatExceptionOfType(IllegalArgumentException.class) .isThrownBy(() -> ProductionPanel.from(nothing())) .withMessage("sc2api production panel is required"); }
@Test void convertsAllFieldsFromSc2ApiProductionPanel() { assertThatAllFieldsAreConverted(ProductionPanel.from(sc2ApiProductionPanel())); }
@Test void throwsExceptionWhenUnitIsNotProvided() { assertThatExceptionOfType(IllegalArgumentException.class) .isThrownBy(() -> ProductionPanel.from(without( () -> sc2ApiProductionPanel().toBuilder(), Ui.ProductionPanel.Builder::clearUnit).build())) .withMessage("unit is required"); }
@Test void fulfillsEqualsContract() { EqualsVerifier .forClass(ProductionPanel.class) .withNonnullFields("unit", "buildQueue", "productionQueue") .withPrefabValues(UnitInfo.class, UnitInfo.from(sc2ApiUnitInfoAddOn()), UnitInfo.from(sc2ApiUnitInfo())) .verify(); } |
### Question:
ControlGroup implements Serializable { public static ControlGroup from(Ui.ControlGroup sc2ApiControlGroup) { require("sc2api control group", sc2ApiControlGroup); return new ControlGroup(sc2ApiControlGroup); } private ControlGroup(Ui.ControlGroup sc2ApiControlGroup); static ControlGroup from(Ui.ControlGroup sc2ApiControlGroup); int getIndex(); UnitType getLeaderUnitType(); int getCount(); @Override boolean equals(Object o); @Override int hashCode(); @Override String toString(); }### Answer:
@Test void throwsExceptionWhenSc2ApiControlGroupIsNull() { assertThatExceptionOfType(IllegalArgumentException.class) .isThrownBy(() -> ControlGroup.from(nothing())) .withMessage("sc2api control group is required"); }
@Test void convertsSc2ApiControlGroupToControlGroup() { assertThatAllFieldsAreConverted(ControlGroup.from(sc2ApiControlGroup())); }
@Test void throwsExceptionWhenIndexIsNotProvided() { assertThatExceptionOfType(IllegalArgumentException.class) .isThrownBy(() -> ControlGroup.from(without( () -> sc2ApiControlGroup().toBuilder(), Ui.ControlGroup.Builder::clearControlGroupIndex).build())) .withMessage("index is required"); }
@Test void throwsExceptionWhenLeaderUnitTypeIsNotProvided() { assertThatExceptionOfType(IllegalArgumentException.class) .isThrownBy(() -> ControlGroup.from(without( () -> sc2ApiControlGroup().toBuilder(), Ui.ControlGroup.Builder::clearLeaderUnitType).build())) .withMessage("leader unit type is required"); }
@Test void throwsExceptionWhenCountIsNotProvided() { assertThatExceptionOfType(IllegalArgumentException.class) .isThrownBy(() -> ControlGroup.from(without( () -> sc2ApiControlGroup().toBuilder(), Ui.ControlGroup.Builder::clearCount).build())) .withMessage("count is required"); } |
### Question:
CargoPanel implements Serializable { public static CargoPanel from(Ui.CargoPanel sc2ApiCargoPanel) { require("sc2api cargo panel", sc2ApiCargoPanel); return new CargoPanel(sc2ApiCargoPanel); } private CargoPanel(Ui.CargoPanel sc2ApiCargoPanel); static CargoPanel from(Ui.CargoPanel sc2ApiCargoPanel); UnitInfo getUnit(); List<UnitInfo> getPassengers(); int getCargoSize(); @Override boolean equals(Object o); @Override int hashCode(); @Override String toString(); }### Answer:
@Test void throwsExceptionWhenSc2ApiCargoPanelIsNull() { assertThatExceptionOfType(IllegalArgumentException.class) .isThrownBy(() -> CargoPanel.from(nothing())) .withMessage("sc2api cargo panel is required"); }
@Test void convertsAllFieldsFromSc2ApiCargoPanel() { assertThatAllFieldsAreConverted(CargoPanel.from(sc2ApiCargoPanel())); }
@Test void throwsExceptionWhenUnitIsNotProvided() { assertThatExceptionOfType(IllegalArgumentException.class) .isThrownBy(() -> CargoPanel.from( without(() -> sc2ApiCargoPanel().toBuilder(), Ui.CargoPanel.Builder::clearUnit).build())) .withMessage("unit is required"); }
@Test void throwsExceptionWhenCargoSizeIsNotProvided() { assertThatExceptionOfType(IllegalArgumentException.class) .isThrownBy(() -> CargoPanel.from(without( () -> sc2ApiCargoPanel().toBuilder(), Ui.CargoPanel.Builder::clearSlotsAvailable).build())) .withMessage("cargo size is required"); }
@Test void fulfillsEqualsContract() { EqualsVerifier .forClass(CargoPanel.class) .withNonnullFields("unit", "passengers") .withPrefabValues(UnitInfo.class, UnitInfo.from(sc2ApiUnitInfoAddOn()), UnitInfo.from(sc2ApiUnitInfo())) .verify(); } |
### Question:
ObservationUi implements Serializable { public static ObservationUi from(Ui.ObservationUI sc2ApiObservationUi) { require("sc2api observation ui", sc2ApiObservationUi); return new ObservationUi(sc2ApiObservationUi); } private ObservationUi(Ui.ObservationUI sc2ApiObservationUi); static ObservationUi from(Ui.ObservationUI sc2ApiObservationUi); Set<ControlGroup> getControlGroups(); Optional<SinglePanel> getSinglePanel(); Optional<MultiPanel> getMultiPanel(); Optional<CargoPanel> getCargoPanel(); Optional<ProductionPanel> getProductionPanel(); @Override boolean equals(Object o); @Override int hashCode(); @Override String toString(); }### Answer:
@Test void throwsExceptionWhenSc2ApiObservationUiIsNull() { assertThatExceptionOfType(IllegalArgumentException.class) .isThrownBy(() -> ObservationUi.from(nothing())) .withMessage("sc2api observation ui is required"); }
@Test void convertsAllFieldsFromSc2ApiObservationUi() { assertThatAllFieldsAreConvertedForSinglePanel(ObservationUi.from(sc2ApiObservationUiSingle())); assertThatAllFieldsAreConvertedForMultiPanel(ObservationUi.from(sc2ApiObservationUiMulti())); assertThatAllFieldsAreConvertedForCargoPanel(ObservationUi.from(sc2ApiObservationUiCargo())); assertThatAllFieldsAreConvertedForProductionPanel(ObservationUi.from(sc2ApiObservationUiProduction())); }
@Test void fulfillsEqualsContract() { EqualsVerifier .forClass(ObservationUi.class) .withNonnullFields("controlGroups") .withPrefabValues(UnitInfo.class, UnitInfo.from(sc2ApiUnitInfoAddOn()), UnitInfo.from(sc2ApiUnitInfo())) .verify(); } |
### Question:
BuildItem implements Serializable { public static BuildItem from(Ui.BuildItem sc2ApiBuildItem) { require("sc2api build item", sc2ApiBuildItem); return new BuildItem(sc2ApiBuildItem); } private BuildItem(Ui.BuildItem sc2ApiBuildItem); static BuildItem from(Ui.BuildItem sc2ApiBuildItem); Ability getAbility(); float getBuildProgress(); @Override boolean equals(Object o); @Override int hashCode(); @Override String toString(); }### Answer:
@Test void throwsExceptionWhenSc2ApiBuildItemIsNull() { assertThatExceptionOfType(IllegalArgumentException.class) .isThrownBy(() -> BuildItem.from(nothing())) .withMessage("sc2api build item is required"); }
@Test void convertsAllFieldsFromSc2ApiBuildItem() { assertThatAllFieldsAreConverted(BuildItem.from(sc2ApiBuildItem())); }
@Test void throwsExceptionWhenAbilityIsNotProvided() { assertThatExceptionOfType(IllegalArgumentException.class) .isThrownBy(() -> BuildItem.from( without(() -> sc2ApiBuildItem().toBuilder(), Ui.BuildItem.Builder::clearAbilityId).build())) .withMessage("ability is required"); }
@Test void throwsExceptionWhenBuildProgressIsNotProvided() { assertThatExceptionOfType(IllegalArgumentException.class) .isThrownBy(() -> BuildItem.from( without(() -> sc2ApiBuildItem().toBuilder(), Ui.BuildItem.Builder::clearBuildProgress).build())) .withMessage("build progress is required"); } |
### Question:
PlayerCommon implements Serializable { public static PlayerCommon from(Sc2Api.PlayerCommon sc2ApiPlayerCommon) { require("sc2api player common", sc2ApiPlayerCommon); return new PlayerCommon(sc2ApiPlayerCommon); } private PlayerCommon(Sc2Api.PlayerCommon sc2ApiPlayerCommon); static PlayerCommon from(Sc2Api.PlayerCommon sc2ApiPlayerCommon); int getPlayerId(); int getMinerals(); int getVespene(); int getFoodCap(); int getFoodUsed(); int getFoodArmy(); int getFoodWorkers(); int getIdleWorkerCount(); int getArmyCount(); Optional<Integer> getWarpGateCount(); Optional<Integer> getLarvaCount(); @Override boolean equals(Object o); @Override int hashCode(); @Override String toString(); }### Answer:
@Test void throwsExceptionWhenSc2ApiPlayerCommonIsNull() { assertThatExceptionOfType(IllegalArgumentException.class) .isThrownBy(() -> PlayerCommon.from(nothing())) .withMessage("sc2api player common is required"); }
@Test void convertsAllFieldsFromSc2ApiPlayerCommon() { assertThatAllFieldsAreConverted(PlayerCommon.from(sc2ApiPlayerCommon())); }
@Test void throwsExceptionWhenPlayerIdIsNotProvided() { assertThatExceptionOfType(IllegalArgumentException.class) .isThrownBy(() -> PlayerCommon.from(without( () -> sc2ApiPlayerCommon().toBuilder(), Sc2Api.PlayerCommon.Builder::clearPlayerId).build())) .withMessage("player id is required"); }
@Test void throwsExceptionWhenMineralsIsNotProvided() { assertThatExceptionOfType(IllegalArgumentException.class) .isThrownBy(() -> PlayerCommon.from(without( () -> sc2ApiPlayerCommon().toBuilder(), Sc2Api.PlayerCommon.Builder::clearMinerals).build())) .withMessage("minerals is required"); }
@Test void throwsExceptionWhenVespeneIsNotProvided() { assertThatExceptionOfType(IllegalArgumentException.class) .isThrownBy(() -> PlayerCommon.from(without( () -> sc2ApiPlayerCommon().toBuilder(), Sc2Api.PlayerCommon.Builder::clearVespene).build())) .withMessage("vespene is required"); }
@Test void throwsExceptionWhenFoodCapIsNotProvided() { assertThatExceptionOfType(IllegalArgumentException.class) .isThrownBy(() -> PlayerCommon.from(without( () -> sc2ApiPlayerCommon().toBuilder(), Sc2Api.PlayerCommon.Builder::clearFoodCap).build())) .withMessage("food cap is required"); }
@Test void throwsExceptionWhenFoodUsedIsNotProvided() { assertThatExceptionOfType(IllegalArgumentException.class) .isThrownBy(() -> PlayerCommon.from(without( () -> sc2ApiPlayerCommon().toBuilder(), Sc2Api.PlayerCommon.Builder::clearFoodUsed).build())) .withMessage("food used is required"); }
@Test void throwsExceptionWhenFoodArmyIsNotProvided() { assertThatExceptionOfType(IllegalArgumentException.class) .isThrownBy(() -> PlayerCommon.from(without( () -> sc2ApiPlayerCommon().toBuilder(), Sc2Api.PlayerCommon.Builder::clearFoodArmy).build())) .withMessage("food army is required"); }
@Test void throwsExceptionWhenFoodWorkersIsNotProvided() { assertThatExceptionOfType(IllegalArgumentException.class) .isThrownBy(() -> PlayerCommon.from(without( () -> sc2ApiPlayerCommon().toBuilder(), Sc2Api.PlayerCommon.Builder::clearFoodWorkers).build())) .withMessage("food workers is required"); }
@Test void throwsExceptionWhenIdleWorkerCountIsNotProvided() { assertThatExceptionOfType(IllegalArgumentException.class) .isThrownBy(() -> PlayerCommon.from(without( () -> sc2ApiPlayerCommon().toBuilder(), Sc2Api.PlayerCommon.Builder::clearIdleWorkerCount).build())) .withMessage("idle worker count is required"); }
@Test void throwsExceptionWhenArmyCountIsNotProvided() { assertThatExceptionOfType(IllegalArgumentException.class) .isThrownBy(() -> PlayerCommon.from(without( () -> sc2ApiPlayerCommon().toBuilder(), Sc2Api.PlayerCommon.Builder::clearArmyCount).build())) .withMessage("army count is required"); } |
### Question:
UnitTypeData implements Serializable { public static UnitTypeData from(Data.UnitTypeData sc2ApiUnitTypeData) { require("sc2api unit type data", sc2ApiUnitTypeData); return new UnitTypeData(sc2ApiUnitTypeData); } private UnitTypeData(Data.UnitTypeData sc2ApiUnitTypeData); static UnitTypeData from(Data.UnitTypeData sc2ApiUnitTypeData); UnitType getUnitType(); String getName(); boolean isAvailable(); Optional<Integer> getCargoSize(); Optional<Integer> getMineralCost(); Optional<Integer> getVespeneCost(); Optional<Float> getFoodRequired(); Optional<Float> getFoodProvided(); Optional<Ability> getAbility(); Optional<Race> getRace(); Optional<Float> getBuildTime(); boolean isHasVespene(); boolean isHasMinerals(); Optional<Float> getSightRange(); Set<UnitType> getTechAliases(); Optional<UnitType> getUnitAlias(); Optional<UnitType> getTechRequirement(); boolean isRequireAttached(); Set<UnitAttribute> getAttributes(); Optional<Float> getMovementSpeed(); Optional<Float> getArmor(); Set<Weapon> getWeapons(); @Override boolean equals(Object o); @Override int hashCode(); @Override String toString(); }### Answer:
@Test void throwsExceptionWhenSc2ApiUnitTypeDataIsNull() { assertThatExceptionOfType(IllegalArgumentException.class) .isThrownBy(() -> UnitTypeData.from(nothing())) .withMessage("sc2api unit type data is required"); }
@Test void convertsAllFieldsFromSc2ApiUnit() { assertThatAllFieldsAreConverted(UnitTypeData.from(sc2ApiUnitTypeData())); }
@Test void throwsExceptionWhenUnitTypeIsNotProvided() { assertThatExceptionOfType(IllegalArgumentException.class) .isThrownBy(() -> UnitTypeData.from(without( () -> sc2ApiUnitTypeData().toBuilder(), Data.UnitTypeData.Builder::clearUnitId).build())) .withMessage("unit type is required"); }
@Test void throwsExceptionWhenNameIsNotProvided() { assertThatExceptionOfType(IllegalArgumentException.class) .isThrownBy(() -> UnitTypeData.from(without( () -> sc2ApiUnitTypeData().toBuilder(), Data.UnitTypeData.Builder::clearName).build())) .withMessage("name is required"); } |
### Question:
ChatReceived implements Serializable { public static ChatReceived from(Sc2Api.ChatReceived sc2ApiChatReceived) { require("sc2api chat received", sc2ApiChatReceived); return new ChatReceived(sc2ApiChatReceived); } private ChatReceived(Sc2Api.ChatReceived sc2ApiChatReceived); static ChatReceived from(Sc2Api.ChatReceived sc2ApiChatReceived); int getPlayerId(); String getMessage(); @Override boolean equals(Object o); @Override int hashCode(); @Override String toString(); }### Answer:
@Test void throwsExceptionWhenSc2ApiChatReceivedIsNull() { assertThatExceptionOfType(IllegalArgumentException.class) .isThrownBy(() -> ChatReceived.from(nothing())) .withMessage("sc2api chat received is required"); }
@Test void convertsSc2ApiChatReceivedToChatReceived() { assertThatAllFieldsAreConverted(ChatReceived.from(sc2ApiChatReceived())); }
@Test void throwsExceptionWhenPlayerIdInNotProvided() { assertThatExceptionOfType(IllegalArgumentException.class) .isThrownBy(() -> ChatReceived.from(sc2ApiChatReceivedWithoutPlayerId())) .withMessage("player id is required"); }
@Test void throwsExceptionWhenMessageInNotProvided() { assertThatExceptionOfType(IllegalArgumentException.class) .isThrownBy(() -> ChatReceived.from(sc2ApiChatReceivedWithoutMessage())) .withMessage("message is required"); } |
### Question:
PlayerResult implements Serializable { public static PlayerResult from(Sc2Api.PlayerResult sc2ApiPlayerResult) { require("sc2api player result", sc2ApiPlayerResult); return new PlayerResult(sc2ApiPlayerResult); } private PlayerResult(Sc2Api.PlayerResult sc2ApiPlayerResult); static PlayerResult from(Sc2Api.PlayerResult sc2ApiPlayerResult); int getPlayerId(); Result getResult(); @Override boolean equals(Object o); @Override int hashCode(); @Override String toString(); }### Answer:
@Test void throwsExceptionWhenSc2ApiPlayerResultIsNull() { assertThatExceptionOfType(IllegalArgumentException.class) .isThrownBy(() -> PlayerResult.from(nothing())) .withMessage("sc2api player result is required"); }
@Test void convertsAllFieldsFromSc2ApiPlayerResult() { assertThatAllFieldsAreConverted(PlayerResult.from(sc2ApiPlayerResult())); }
@Test void throwsExceptionWhenSc2ApiPlayerInfoDoesNotExist() { assertThatExceptionOfType(IllegalArgumentException.class) .isThrownBy(() -> PlayerResult.from(sc2ApiPlayerResultWithoutPlayerId())) .withMessage("player id is required"); }
@Test void throwsExceptionWhenSc2ApiResultDoesNotExist() { assertThatExceptionOfType(IllegalArgumentException.class) .isThrownBy(() -> PlayerResult.from(sc2PlayerResultWithoutResult())) .withMessage("result is required"); } |
### Question:
MapState implements Serializable { public static MapState from(Raw.MapState sc2ApiMapState) { require("sc2api map state", sc2ApiMapState); return new MapState(sc2ApiMapState); } private MapState(Raw.MapState sc2ApiMapState); static MapState from(Raw.MapState sc2ApiMapState); ImageData getVisibility(); ImageData getCreep(); @Override boolean equals(Object o); @Override int hashCode(); @Override String toString(); }### Answer:
@Test void throwsExceptionWhenSc2ApiMapStateIsNull() { assertThatExceptionOfType(IllegalArgumentException.class) .isThrownBy(() -> MapState.from(nothing())) .withMessage("sc2api map state is required"); }
@Test void convertsAllFieldsFromSc2ApiMapState() { assertThatAllFieldsAreConverted(MapState.from(sc2ApiMapState())); }
@Test void throwsExceptionWhenVisibilityIsNotProvided() { assertThatExceptionOfType(IllegalArgumentException.class) .isThrownBy(() -> MapState.from(without( () -> sc2ApiMapState().toBuilder(), Raw.MapState.Builder::clearVisibility).build())) .withMessage("visibility is required"); }
@Test void throwsExceptionWhenCreepIsNotProvided() { assertThatExceptionOfType(IllegalArgumentException.class) .isThrownBy(() -> MapState.from(without( () -> sc2ApiMapState().toBuilder(), Raw.MapState.Builder::clearCreep).build())) .withMessage("creep is required"); } |
### Question:
ObservationRaw implements Serializable { public static ObservationRaw from(Raw.ObservationRaw sc2ApiObservationRaw) { require("sc2api observation raw", sc2ApiObservationRaw); return new ObservationRaw(sc2ApiObservationRaw); } private ObservationRaw(Raw.ObservationRaw sc2ApiObservationRaw); static ObservationRaw from(Raw.ObservationRaw sc2ApiObservationRaw); PlayerRaw getPlayer(); Set<Unit> getUnits(); Set<UnitSnapshot> getUnitSnapshots(); MapState getMapState(); Optional<Event> getEvent(); Set<EffectLocations> getEffects(); @Override boolean equals(Object o); @Override int hashCode(); @Override String toString(); }### Answer:
@Test void throwsExceptionWhenSc2ApiObservationRawIsNull() { assertThatExceptionOfType(IllegalArgumentException.class) .isThrownBy(() -> ObservationRaw.from(nothing())) .withMessage("sc2api observation raw is required"); }
@Test void convertsAllFieldsFromSc2ApiObservationRaw() { assertThatAllFieldsAreConverted(ObservationRaw.from(sc2ApiObservationRaw())); }
@Test void throwsExceptionWhenPlayerIsNotProvided() { assertThatExceptionOfType(IllegalArgumentException.class) .isThrownBy(() -> ObservationRaw.from(without( () -> sc2ApiObservationRaw().toBuilder(), Raw.ObservationRaw.Builder::clearPlayer).build())) .withMessage("player is required"); }
@Test void throwsExceptionWhenMapStateIsNotProvided() { assertThatExceptionOfType(IllegalArgumentException.class) .isThrownBy(() -> ObservationRaw.from(without( () -> sc2ApiObservationRaw().toBuilder(), Raw.ObservationRaw.Builder::clearMapState).build())) .withMessage("map state is required"); } |
### Question:
PlayerRaw implements Serializable { public static PlayerRaw from(Raw.PlayerRaw sc2ApiPlayerRaw) { require("sc2api player raw", sc2ApiPlayerRaw); return new PlayerRaw(sc2ApiPlayerRaw); } private PlayerRaw(Raw.PlayerRaw sc2ApiPlayerRaw); static PlayerRaw from(Raw.PlayerRaw sc2ApiPlayerRaw); Set<PowerSource> getPowerSources(); Point getCamera(); Set<Upgrade> getUpgrades(); @Override boolean equals(Object o); @Override int hashCode(); @Override String toString(); }### Answer:
@Test void throwsExceptionWhenSc2ApiPlayerRawIsNull() { assertThatExceptionOfType(IllegalArgumentException.class) .isThrownBy(() -> PlayerRaw.from(nothing())) .withMessage("sc2api player raw is required"); }
@Test void convertsAllFieldsFromSc2ApiPlayerRaw() { assertThatAllFieldsAreConverted(PlayerRaw.from(sc2ApiPlayerRaw())); }
@Test void throwsExceptionWhenCameraIsNotProvided() { assertThatExceptionOfType(IllegalArgumentException.class) .isThrownBy(() -> PlayerRaw.from(without( () -> sc2ApiPlayerRaw().toBuilder(), Raw.PlayerRaw.Builder::clearCamera).build())) .withMessage("camera is required"); } |
### Question:
PowerSource implements Serializable { public static PowerSource from(Raw.PowerSource sc2ApiPowerSource) { require("sc2api power source", sc2ApiPowerSource); return new PowerSource(sc2ApiPowerSource); } private PowerSource(Raw.PowerSource sc2ApiPowerSource); static PowerSource from(Raw.PowerSource sc2ApiPowerSource); Point getPosition(); float getRadius(); Tag getTag(); @Override boolean equals(Object o); @Override int hashCode(); @Override String toString(); }### Answer:
@Test void throwsExceptionWhenSc2ApiPowerSourceIsNull() { assertThatExceptionOfType(IllegalArgumentException.class) .isThrownBy(() -> PowerSource.from(nothing())) .withMessage("sc2api power source is required"); }
@Test void convertsAllFieldsFromSc2ApiPowerSource() { assertThatAllFieldsAreConverted(PowerSource.from(sc2ApiPowerSource())); }
@Test void throwsExceptionWhenPositionIsNotProvided() { assertThatExceptionOfType(IllegalArgumentException.class) .isThrownBy(() -> PowerSource.from(without( () -> sc2ApiPowerSource().toBuilder(), Raw.PowerSource.Builder::clearPos).build())) .withMessage("position is required"); }
@Test void throwsExceptionWhenRadiusIsNotProvided() { assertThatExceptionOfType(IllegalArgumentException.class) .isThrownBy(() -> PowerSource.from(without( () -> sc2ApiPowerSource().toBuilder(), Raw.PowerSource.Builder::clearRadius).build())) .withMessage("radius is required"); }
@Test void throwsExceptionWhenTagIsNotProvided() { assertThatExceptionOfType(IllegalArgumentException.class) .isThrownBy(() -> PowerSource.from(without( () -> sc2ApiPowerSource().toBuilder(), Raw.PowerSource.Builder::clearTag).build())) .withMessage("tag is required"); } |
### Question:
EffectLocations implements Serializable { public static EffectLocations from(Raw.Effect sc2ApiEffect) { require("sc2api effect", sc2ApiEffect); return new EffectLocations(sc2ApiEffect); } private EffectLocations(Raw.Effect sc2ApiEffect); static EffectLocations from(Raw.Effect sc2ApiEffect); Effect getEffect(); Set<Point2d> getPositions(); Optional<Alliance> getAlliance(); Optional<Integer> getOwner(); Optional<Float> getRadius(); @Override boolean equals(Object o); @Override int hashCode(); @Override String toString(); }### Answer:
@Test void throwsExceptionWhenSc2ApiEffectIsNull() { assertThatExceptionOfType(IllegalArgumentException.class) .isThrownBy(() -> EffectLocations.from(nothing())) .withMessage("sc2api effect is required"); }
@Test void convertsAllFieldsFromSc2ApiEffect() { assertThatAllFieldsAreConverted(EffectLocations.from(sc2ApiEffect())); }
@Test void throwsExceptionWhenEffectIdIsNotProvided() { assertThatExceptionOfType(IllegalArgumentException.class) .isThrownBy(() -> EffectLocations.from(without( () -> sc2ApiEffect().toBuilder(), Raw.Effect.Builder::clearEffectId).build())) .withMessage("effect is required"); } |
### Question:
Event implements Serializable { public static Event from(Raw.Event sc2ApiEvent) { require("sc2api event", sc2ApiEvent); return new Event(sc2ApiEvent); } private Event(Raw.Event sc2ApiEvent); static Event from(Raw.Event sc2ApiEvent); Set<Tag> getDeadUnits(); @Override boolean equals(Object o); @Override int hashCode(); @Override String toString(); }### Answer:
@Test void throwsExceptionWhenSc2ApiEventIsNull() { assertThatExceptionOfType(IllegalArgumentException.class) .isThrownBy(() -> Event.from(nothing())) .withMessage("sc2api event is required"); }
@Test void convertsAllFieldsFromSc2ApiEvent() { assertThatAllFieldsAreConverted(Event.from(sc2ApiEvent())); } |
### Question:
RequestSerializer implements Function<Request, byte[]> { @Override public byte[] apply(Request request) { if (!isSet(request)) return new byte[0]; Sc2Api.Request sc2ApiRequest = request.toSc2Api(); sc2ApiRequest = sc2ApiRequest.toBuilder().setId(request.getId()).build(); ByteArrayOutputStream output = new ByteArrayOutputStream(sc2ApiRequest.getSerializedSize()); try { sc2ApiRequest.writeTo(output); } catch (IOException e) { throw new ProtocolException(e); } return output.toByteArray(); } @Override byte[] apply(Request request); }### Answer:
@Test void returnsEmptyArrayForNullInput() { assertThat(new RequestSerializer().apply(nothing())).as("serialized request").isEqualTo(EMPTY_ARRAY); }
@Test void serializesSc2ApiRequestToBytes() throws Exception { RequestPing ping = ping(); Sc2Api.Request initialRequest = Sc2Api.Request.newBuilder() .setPing(Sc2Api.RequestPing.newBuilder().build()) .setId(ping.getId()) .build(); byte[] serializedRequest = new RequestSerializer().apply(ping); assertThat(serializedRequest).as("serialized request").isNotEmpty(); assertThat(Sc2Api.Request.parseFrom(serializedRequest)).isEqualTo(initialRequest); } |
### Question:
LocalMap implements Sc2ApiSerializable<Sc2Api.LocalMap> { public static LocalMap of(Path localMapPath, byte[] localMapDataInBytes) { validatePath(localMapPath); validateDataInBytes(localMapDataInBytes); return new LocalMap(localMapPath, localMapDataInBytes); } private LocalMap(Path path); private LocalMap(byte[] dataInBytes); private LocalMap(Path path, byte[] dataInBytes); static LocalMap of(Path localMapPath, byte[] localMapDataInBytes); static LocalMap of(Path localMapPath); static LocalMap of(byte[] localMapDataInBytes); @Override Sc2Api.LocalMap toSc2Api(); Optional<Path> getPath(); Optional<byte[]> getDataInBytes(); @Override boolean equals(Object o); @Override int hashCode(); @Override String toString(); }### Answer:
@Test void throwsExceptionWhenAnyOfArgumentInFactoryMethodIsNull() { assertThatExceptionOfType(IllegalArgumentException.class) .isThrownBy(() -> LocalMap.of((Path) nothing())) .withMessage("path is required"); assertThatExceptionOfType(IllegalArgumentException.class) .isThrownBy(() -> LocalMap.of((byte[]) nothing())) .withMessage("data in bytes is required"); assertThatExceptionOfType(IllegalArgumentException.class) .isThrownBy(() -> LocalMap.of(nothing(), DATA_IN_BYTES)) .withMessage("path is required"); assertThatExceptionOfType(IllegalArgumentException.class) .isThrownBy(() -> LocalMap.of(Paths.get(LOCAL_MAP_PATH), nothing())) .withMessage("data in bytes is required"); }
@Test void throwsExceptionWhenPathLengthIsExceeded() { Path tooLongPath = Paths.get(String.join("", nCopies(261, String.valueOf('a')))); assertThatExceptionOfType(IllegalArgumentException.class) .isThrownBy(() -> LocalMap.of(tooLongPath)) .withMessage("Maximum length of path (260) exceeded. Actual was 261."); assertThatExceptionOfType(IllegalArgumentException.class) .isThrownBy(() -> LocalMap.of(tooLongPath, DATA_IN_BYTES)) .withMessage("Maximum length of path (260) exceeded. Actual was 261."); } |
### Question:
BattlenetMap implements Sc2ApiSerializable<String> { public static BattlenetMap of(String battlenetMapName) { if (battlenetMapName == null) throw new IllegalArgumentException("battlenet map name is required"); return new BattlenetMap(battlenetMapName); } private BattlenetMap(String name); @Override String toSc2Api(); static BattlenetMap of(String battlenetMapName); @JsonValue String getName(); @Override boolean equals(Object o); @Override int hashCode(); @Override String toString(); }### Answer:
@Test void throwsExceptionWhenMapNameIsNull() { assertThatExceptionOfType(IllegalArgumentException.class) .isThrownBy(() -> BattlenetMap.of(nothing())) .withMessage("battlenet map name is required"); } |
### Question:
PortSet implements Sc2ApiSerializable<Sc2Api.PortSet> { public static PortSet of(int gamePort, int basePort) { if (!portIsValid(gamePort) || !portIsValid(basePort)) throw new IllegalArgumentException("port must be greater than 0"); return new PortSet(gamePort, basePort); } private PortSet(int gamePort, int basePort); static PortSet of(int gamePort, int basePort); @Override Sc2Api.PortSet toSc2Api(); int getGamePort(); int getBasePort(); @Override boolean equals(Object o); @Override int hashCode(); @Override String toString(); }### Answer:
@Test void throwsExceptionWhenPortIsLowerThanOne() { assertThatExceptionOfType(IllegalArgumentException.class) .isThrownBy(() -> PortSet.of(0, 1)) .withMessage("port must be greater than 0"); assertThatExceptionOfType(IllegalArgumentException.class) .isThrownBy(() -> PortSet.of(1, 0)) .withMessage("port must be greater than 0"); } |
### Question:
InterfaceOptions implements Sc2ApiSerializable<Sc2Api.InterfaceOptions> { public static InterfaceOptionsSyntax interfaces() { return new Builder(); } private InterfaceOptions(Builder builder); private InterfaceOptions(Sc2Api.InterfaceOptions sc2ApiInterfaceOptions); static InterfaceOptionsSyntax interfaces(); static InterfaceOptions from(Sc2Api.InterfaceOptions sc2ApiInterfaceOptions); @Override Sc2Api.InterfaceOptions toSc2Api(); boolean isRaw(); boolean isScore(); Optional<SpatialCameraSetup> getFeatureLayer(); Optional<SpatialCameraSetup> getRender(); Optional<Boolean> getShowCloaked(); Optional<Boolean> getShowBurrowed(); Optional<Boolean> getRawAffectsSelection(); Optional<Boolean> getRawCropToPlayableArea(); @Override boolean equals(Object o); @Override int hashCode(); @Override String toString(); }### Answer:
@Test void throwsExceptionWhenAnyOptionIsNotSet() { assertThatExceptionOfType(IllegalArgumentException.class) .isThrownBy(() -> fullAccessTo(interfaces()).build()) .withMessage("one of interface options is required"); } |
### Question:
PlayerInfo implements Serializable { public static PlayerInfo from(Sc2Api.PlayerInfo sc2ApiPlayerInfo) { require("sc2api player info", sc2ApiPlayerInfo); return new PlayerInfo(sc2ApiPlayerInfo); } private PlayerInfo(Sc2Api.PlayerInfo sc2ApiPlayerInfo); static PlayerInfo from(Sc2Api.PlayerInfo sc2ApiPlayerInfo); int getPlayerId(); Optional<PlayerType> getPlayerType(); Race getRequestedRace(); Optional<Race> getActualRace(); Optional<Difficulty> getDifficulty(); Optional<String> getPlayerName(); @Override boolean equals(Object o); @Override int hashCode(); @Override String toString(); }### Answer:
@Test void throwsExceptionWhenSc2ApiPlayerInfoIsNull() { assertThatExceptionOfType(IllegalArgumentException.class) .isThrownBy(() -> PlayerInfo.from(nothing())) .withMessage("sc2api player info is required"); }
@Test void convertsAllFieldsFromSc2ApiPlayerInfo() { assertThatAllFieldsAreConverted(PlayerInfo.from(sc2ApiPlayerInfo())); }
@Test void throwsExceptionWhenSc2ApiPlayerIdDoesNotExist() { assertThatExceptionOfType(IllegalArgumentException.class) .isThrownBy(() -> PlayerInfo.from(sc2ApiPlayerInfoWithoutPlayerId())) .withMessage("player id is required"); }
@Test void throwsExceptionWhenSc2ApiRequestedRaceDoesNotExist() { assertThatExceptionOfType(IllegalArgumentException.class) .isThrownBy(() -> PlayerInfo.from(sc2ApiPlayerInfoWithoutRaceRequested())) .withMessage("requested race is required"); } |
### Question:
Weapon implements Serializable { public static Weapon from(Data.Weapon sc2ApiWeapon) { require("sc2api weapon", sc2ApiWeapon); return new Weapon(sc2ApiWeapon); } private Weapon(Data.Weapon sc2ApiWeapon); static Weapon from(Data.Weapon sc2ApiWeapon); TargetType getTargetType(); float getDamage(); Set<DamageBonus> getDamageBonuses(); int getAttacks(); float getRange(); float getSpeed(); @Override boolean equals(Object o); @Override int hashCode(); @Override String toString(); }### Answer:
@Test void throwsExceptionWhenSc2ApiWeaponIsNull() { assertThatExceptionOfType(IllegalArgumentException.class) .isThrownBy(() -> Weapon.from(nothing())) .withMessage("sc2api weapon is required"); }
@Test void convertsAllFieldsFromSc2ApiWeapon() { assertThatAllFieldsAreConverted(Weapon.from(sc2ApiWeapon())); }
@Test void throwsExceptionWhenWeaponTargetTypeIsNull() { assertThatExceptionOfType(IllegalArgumentException.class) .isThrownBy(() -> Weapon.TargetType.from(nothing())) .withMessage("sc2api target type is required"); }
@Test void throwsExceptionWhenTargetTypeIsNotProvided() { assertThatExceptionOfType(IllegalArgumentException.class) .isThrownBy(() -> Weapon.from( without(() -> sc2ApiWeapon().toBuilder(), Data.Weapon.Builder::clearType).build())) .withMessage("target type is required"); }
@Test void throwsExceptionWhenDamageIsNotProvided() { assertThatExceptionOfType(IllegalArgumentException.class) .isThrownBy(() -> Weapon.from( without(() -> sc2ApiWeapon().toBuilder(), Data.Weapon.Builder::clearDamage).build())) .withMessage("damage is required"); }
@Test void throwsExceptionWhenAttacksIsNotProvided() { assertThatExceptionOfType(IllegalArgumentException.class) .isThrownBy(() -> Weapon.from( without(() -> sc2ApiWeapon().toBuilder(), Data.Weapon.Builder::clearAttacks).build())) .withMessage("attacks is required"); }
@Test void throwsExceptionWhenRangeIsNotProvided() { assertThatExceptionOfType(IllegalArgumentException.class) .isThrownBy(() -> Weapon.from( without(() -> sc2ApiWeapon().toBuilder(), Data.Weapon.Builder::clearRange).build())) .withMessage("range is required"); }
@Test void throwsExceptionWhenSpeedIsNotProvided() { assertThatExceptionOfType(IllegalArgumentException.class) .isThrownBy(() -> Weapon.from( without(() -> sc2ApiWeapon().toBuilder(), Data.Weapon.Builder::clearSpeed).build())) .withMessage("speed is required"); } |
### Question:
ReplayInfo implements Serializable { public static ReplayInfo from(Sc2Api.ResponseReplayInfo sc2ApiResponseReplayInfo) { require("sc2api response replay info", sc2ApiResponseReplayInfo); return new ReplayInfo(sc2ApiResponseReplayInfo); } private ReplayInfo(Sc2Api.ResponseReplayInfo sc2ApiResponseReplayInfo); static ReplayInfo from(Sc2Api.ResponseReplayInfo sc2ApiResponseReplayInfo); Optional<BattlenetMap> getBattlenetMap(); Optional<LocalMap> getLocalMap(); Set<PlayerInfoExtra> getPlayerInfo(); int getGameDurationLoops(); float getGameDurationSeconds(); String getGameVersion(); String getDataVersion(); int getBaseBuild(); int getDataBuild(); @Override boolean equals(Object o); @Override int hashCode(); @Override String toString(); }### Answer:
@Test void throwsExceptionWhenSc2ApiResponseReplayInfoIsNull() { assertThatExceptionOfType(IllegalArgumentException.class) .isThrownBy(() -> ReplayInfo.from(nothing())) .withMessage("sc2api response replay info is required"); }
@Test void convertsSc2ApiReplayInfoToReplayInfo() { assertThatAllFieldsAreMapped(ReplayInfo.from(sc2ApiResponseReplayInfo())); }
@Test void throwsExceptionWhenMapInfoIsNotProvided() { assertThatExceptionOfType(IllegalArgumentException.class) .isThrownBy(() -> ReplayInfo.from(sc2ApiReplayInfoWithoutMap())) .withMessage("map info (local or battlenet) is required"); } |
### Question:
MultiplayerOptions implements Serializable { public static MultiplayerOptionsSyntax multiplayerSetup() { return new Builder(); } private MultiplayerOptions(Builder builder); static MultiplayerOptionsSyntax multiplayerSetup(); static MultiplayerOptions multiplayerSetupFor(int portStart, int playerCount); int getSharedPort(); PortSet getServerPort(); Set<PortSet> getClientPorts(); @Override boolean equals(Object o); @Override int hashCode(); @Override String toString(); }### Answer:
@Test void throwsExceptionWhenSharedPortIsNotSet() { assertThatExceptionOfType(IllegalArgumentException.class) .isThrownBy(() -> fullAccessTo(multiplayerSetup()).build()) .withMessage("shared port is required"); }
@Test void throwsExceptionWhenServerPortIsNotSet() { assertThatExceptionOfType(IllegalArgumentException.class) .isThrownBy(() -> fullAccessTo(multiplayerSetup().sharedPort(1)).build()) .withMessage("server port is required"); }
@Test void throwsExceptionWhenClientPortsAreEmpty() { assertThatExceptionOfType(IllegalArgumentException.class) .isThrownBy(() -> fullAccessTo(multiplayerSetup().sharedPort(1).serverPort(PortSet.of(1, 2))).build()) .withMessage("client port list is required"); }
@Test void throwsExceptionWhenSharedPortLowerThanOne() { assertThatExceptionOfType(IllegalArgumentException.class) .isThrownBy(() -> multiplayerSetup().sharedPort(0)) .withMessage("shared port must be greater than 0"); } |
### Question:
PlayerInfoExtra implements Serializable { public static PlayerInfoExtra from(Sc2Api.PlayerInfoExtra sc2ApiPlayerInfoExtra) { require("sc2api player info extra", sc2ApiPlayerInfoExtra); return new PlayerInfoExtra(sc2ApiPlayerInfoExtra); } private PlayerInfoExtra(Sc2Api.PlayerInfoExtra sc2ApiPlayerInfoExtra); static PlayerInfoExtra from(Sc2Api.PlayerInfoExtra sc2ApiPlayerInfoExtra); PlayerInfo getPlayerInfo(); PlayerResult getPlayerResult(); Optional<Integer> getPlayerMatchMakingRating(); int getPlayerActionPerMinute(); @Override boolean equals(Object o); @Override int hashCode(); @Override String toString(); }### Answer:
@Test void throwsExceptionWhenSc2ApiPlayerInfoExtraIsNull() { assertThatExceptionOfType(IllegalArgumentException.class) .isThrownBy(() -> PlayerInfoExtra.from(nothing())) .withMessage("sc2api player info extra is required"); }
@Test void convertsAllFieldsFromSc2ApiPlayerInfoExtra() { assertThatAllFieldsAreConverted(PlayerInfoExtra.from(sc2ApiPlayerInfoExtra())); }
@Test void throwsExceptionWhenSc2ApiPlayerInfoDoesNotExist() { assertThatExceptionOfType(IllegalArgumentException.class) .isThrownBy(() -> PlayerInfoExtra.from(sc2ApiPlayerInfoExtraWithoutPlayerInfo())) .withMessage("player info is required"); }
@Test void throwsExceptionWhenSc2ApiPlayerApmDoesNotExist() { assertThatExceptionOfType(IllegalArgumentException.class) .isThrownBy(() -> PlayerInfoExtra.from(without( () -> sc2ApiPlayerInfoExtra().toBuilder(), Sc2Api.PlayerInfoExtra.Builder::clearPlayerApm).build())) .withMessage("player apm is required"); } |
### Question:
ComputerPlayerSetup extends PlayerSetup { public static ComputerPlayerSetup computer(Race race, Difficulty difficulty) { if (race == null) throw new IllegalArgumentException("race is required"); if (difficulty == null) throw new IllegalArgumentException("difficulty level is required"); return new ComputerPlayerSetup(race, difficulty, null, null); } private ComputerPlayerSetup(Race race, Difficulty difficulty, String playerName, AiBuild aiBuild); static ComputerPlayerSetup computer(Race race, Difficulty difficulty); static ComputerPlayerSetup computer(Race race, Difficulty difficulty, String playerName); static ComputerPlayerSetup computer(Race race, Difficulty difficulty, String playerName, AiBuild aiBuild); static ComputerPlayerSetup computer(Race race, Difficulty difficulty, AiBuild aiBuild); @Override Sc2Api.PlayerSetup toSc2Api(); Race getRace(); Difficulty getDifficulty(); Optional<String> getPlayerName(); Optional<AiBuild> getAiBuild(); @Override boolean equals(Object o); @Override boolean canEqual(Object other); @Override int hashCode(); @Override String toString(); }### Answer:
@Test void throwsExceptionWhenRaceIsNull() { assertThatExceptionOfType(IllegalArgumentException.class) .isThrownBy(() -> computer(nothing(), Difficulty.MEDIUM)) .withMessage("race is required"); }
@Test void throwsExceptionWhenDifficultyIsNull() { assertThatExceptionOfType(IllegalArgumentException.class) .isThrownBy(() -> computer(Race.PROTOSS, nothing())) .withMessage("difficulty level is required"); } |
### Question:
StartRaw implements Serializable { public static StartRaw from(Raw.StartRaw sc2ApiStartRaw) { require("sc2api start raw", sc2ApiStartRaw); return new StartRaw(sc2ApiStartRaw); } private StartRaw(Raw.StartRaw sc2ApiStartRaw); static StartRaw from(Raw.StartRaw sc2ApiStartRaw); Size2dI getMapSize(); ImageData getPathingGrid(); ImageData getTerrainHeight(); ImageData getPlacementGrid(); RectangleI getPlayableArea(); Set<Point2d> getStartLocations(); @Override boolean equals(Object o); @Override int hashCode(); @Override String toString(); }### Answer:
@Test void throwsExceptionWhenSc2ApiStartRawIsNull() { assertThatExceptionOfType(IllegalArgumentException.class) .isThrownBy(() -> StartRaw.from(nothing())) .withMessage("sc2api start raw is required"); }
@Test void convertsAllFieldsFromSc2ApiStartRaw() { assertThatAllFieldsAreConverted(StartRaw.from(sc2ApiStartRaw())); }
@Test void throwsExceptionWhenMapSizeIsNotProvided() { assertThatExceptionOfType(IllegalArgumentException.class) .isThrownBy(() -> StartRaw.from( without(() -> sc2ApiStartRaw().toBuilder(), Raw.StartRaw.Builder::clearMapSize).build())) .withMessage("map size is required"); }
@Test void throwsExceptionWhenPathingGridIsNotProvided() { assertThatExceptionOfType(IllegalArgumentException.class) .isThrownBy(() -> StartRaw.from( without(() -> sc2ApiStartRaw().toBuilder(), Raw.StartRaw.Builder::clearPathingGrid).build())) .withMessage("pathing grid is required"); }
@Test void throwsExceptionWhenTerrainHeightIsNotProvided() { assertThatExceptionOfType(IllegalArgumentException.class) .isThrownBy(() -> StartRaw.from( without(() -> sc2ApiStartRaw().toBuilder(), Raw.StartRaw.Builder::clearTerrainHeight).build())) .withMessage("terrain height is required"); }
@Test void throwsExceptionWhenPlacementGridIsNotProvided() { assertThatExceptionOfType(IllegalArgumentException.class) .isThrownBy(() -> StartRaw.from( without(() -> sc2ApiStartRaw().toBuilder(), Raw.StartRaw.Builder::clearPlacementGrid).build())) .withMessage("placement grid is required"); }
@Test void throwsExceptionWhenPlayableAreaIsNotProvided() { assertThatExceptionOfType(IllegalArgumentException.class) .isThrownBy(() -> StartRaw.from( without(() -> sc2ApiStartRaw().toBuilder(), Raw.StartRaw.Builder::clearPlayableArea).build())) .withMessage("playable area is required"); } |
### Question:
PointI implements Sc2ApiSerializable<Common.PointI> { public static PointI from(Common.PointI sc2ApiPointI) { require("sc2api pointi", sc2ApiPointI); return new PointI(sc2ApiPointI); } private PointI(Common.PointI sc2ApiPointI); private PointI(int x, int y); static PointI from(Common.PointI sc2ApiPointI); static PointI of(int x, int y); @Override Common.PointI toSc2Api(); int getX(); int getY(); PointI add(PointI pointToAdd); PointI sub(PointI pointToSubtract); PointI div(int divBy); PointI mul(int mulBy); int dot(PointI b); double distance(PointI b); Point2d toPoint2d(); @Override boolean equals(Object o); @Override int hashCode(); @Override String toString(); }### Answer:
@Test void throwsExceptionWhenSc2ApiPointIIsNull() { assertThatExceptionOfType(IllegalArgumentException.class) .isThrownBy(() -> PointI.from(nothing())) .withMessage("sc2api pointi is required"); }
@Test void throwsExceptionWhenSc2ApiPointIDoesNotHaveX() { assertThatExceptionOfType(IllegalArgumentException.class) .isThrownBy(() -> PointI.from(Common.PointI.newBuilder().setY(POINT_Y).build())) .withMessage("x is required"); }
@Test void throwsExceptionWhenSc2ApiPointIDoesNotHaveY() { assertThatExceptionOfType(IllegalArgumentException.class) .isThrownBy(() -> PointI.from(Common.PointI.newBuilder().setX(POINT_X).build())) .withMessage("y is required"); } |
### Question:
RectangleI implements Sc2ApiSerializable<Common.RectangleI> { public static RectangleI from(Common.RectangleI sc2ApiRectangleI) { require("sc2api rectanglei", sc2ApiRectangleI); return new RectangleI(sc2ApiRectangleI); } private RectangleI(Common.RectangleI sc2ApiRectangleI); private RectangleI(PointI p0, PointI p1); static RectangleI from(Common.RectangleI sc2ApiRectangleI); static RectangleI of(PointI p0, PointI p1); @Override Common.RectangleI toSc2Api(); PointI getP0(); PointI getP1(); @Override boolean equals(Object o); @Override int hashCode(); @Override String toString(); }### Answer:
@Test void throwsExceptionWhenSc2ApiRectangleIIsNull() { assertThatExceptionOfType(IllegalArgumentException.class) .isThrownBy(() -> RectangleI.from(nothing())) .withMessage("sc2api rectanglei is required"); } |
### Question:
SpatialCameraSetup implements Sc2ApiSerializable<Sc2Api.SpatialCameraSetup> { public static SpatialCameraSetupSyntax spatialSetup() { return new Builder(); } private SpatialCameraSetup(Builder builder); private SpatialCameraSetup(Sc2Api.SpatialCameraSetup sc2ApiSpatialCameraSetup); static SpatialCameraSetupSyntax spatialSetup(); static SpatialCameraSetup from(Sc2Api.SpatialCameraSetup sc2ApiSpatialCameraSetup); @Override Sc2Api.SpatialCameraSetup toSc2Api(); Optional<Float> getWidth(); Size2dI getMap(); Size2dI getMinimap(); Optional<Boolean> getCropToPlayableArea(); Optional<Boolean> getAllowCheatingLayers(); @Override boolean equals(Object o); @Override int hashCode(); @Override String toString(); }### Answer:
@Test void throwsExceptionWhenResolutionIsNotSet() { assertThatExceptionOfType(IllegalArgumentException.class) .isThrownBy(() -> fullAccessTo(spatialSetup()) .resolution(nothing()).minimap(MINIMAP_X, MINIMAP_Y).build()) .withMessage("resolution is required"); }
@Test void throwsExceptionWhenMinimapResolutionIsNotSet() { assertThatExceptionOfType(IllegalArgumentException.class) .isThrownBy(() -> fullAccessTo(spatialSetup()).resolution(MAP_X, MAP_Y).minimap(nothing()).build()) .withMessage("minimap is required"); }
@Test void throwsExceptionWhenWidthIsNotGreaterThanZero() { assertThatExceptionOfType(IllegalArgumentException.class) .isThrownBy(() -> spatialSetup() .width(0).resolution(MAP_X, MAP_Y).minimap(MINIMAP_X, MINIMAP_Y).build()) .withMessage("camera width has value 0.0 and is not greater than 0.0"); } |
### Question:
Point implements Sc2ApiSerializable<Common.Point> { public static Point from(Common.Point sc2ApiPoint) { require("sc2api point", sc2ApiPoint); return new Point(sc2ApiPoint); } private Point(Common.Point sc2ApiPoint); private Point(float x, float y, float z); static Point of(float x, float y); static Point of(float x, float y, float z); static Point from(Common.Point sc2ApiPoint); @Override Common.Point toSc2Api(); float getX(); float getY(); float getZ(); Point add(Point pointToAdd); Point sub(Point pointToSubtract); Point sub(float subX, float subY, float subZ); Point div(float divBy); Point mul(float mulBy); double distance(Point b); float dot(Point b); Point2d toPoint2d(); @Override boolean equals(Object o); @Override int hashCode(); @Override String toString(); }### Answer:
@Test void throwsExceptionWhenSc2ApiPointIsNull() { assertThatExceptionOfType(IllegalArgumentException.class) .isThrownBy(() -> Point.from(nothing())) .withMessage("sc2api point is required"); }
@Test void throwsExceptionWhenSc2ApiPointDoesNotHaveX() { assertThatExceptionOfType(IllegalArgumentException.class) .isThrownBy(() -> Point.from(Common.Point.newBuilder().setY(POINT_Y).setZ(POINT_Z).build())) .withMessage("x is required"); }
@Test void throwsExceptionWhenSc2ApiPointDoesNotHaveY() { assertThatExceptionOfType(IllegalArgumentException.class) .isThrownBy(() -> Point.from(Common.Point.newBuilder().setX(POINT_X).setZ(POINT_Z).build())) .withMessage("y is required"); } |
### Question:
Point2d implements Sc2ApiSerializable<Common.Point2D> { public static Point2d from(Common.Point2D sc2ApiPoint2d) { require("sc2api point2d", sc2ApiPoint2d); return new Point2d(sc2ApiPoint2d); } private Point2d(Common.Point2D sc2ApiPoint2d); private Point2d(float x, float y); static Point2d of(float x, float y); static Point2d from(Common.Point2D sc2ApiPoint2d); @Override Common.Point2D toSc2Api(); float getX(); float getY(); Point2d add(Point2d pointToAdd); Point2d add(float addX, float addY); Point2d sub(Point2d pointToSubtract); Point2d sub(float subX, float subY); Point2d div(float divBy); Point2d mul(float mulBy); double distance(Point2d b); float dot(Point2d b); @Override boolean equals(Object o); @Override int hashCode(); @Override String toString(); }### Answer:
@Test void throwsExceptionWhenSc2ApiPoint2DIsNull() { assertThatExceptionOfType(IllegalArgumentException.class) .isThrownBy(() -> Point2d.from(nothing())) .withMessage("sc2api point2d is required"); }
@Test void throwsExceptionWhenSc2ApiPoint2DDoesNotHaveX() { assertThatExceptionOfType(IllegalArgumentException.class) .isThrownBy(() -> Point2d.from(Common.Point2D.newBuilder().setY(POINT_Y).build())) .withMessage("x is required"); }
@Test void throwsExceptionWhenSc2ApiPoint2DDoesNotHaveY() { assertThatExceptionOfType(IllegalArgumentException.class) .isThrownBy(() -> Point2d.from(Common.Point2D.newBuilder().setX(POINT_X).build())) .withMessage("y is required"); } |
### Question:
Size2dI implements Sc2ApiSerializable<Common.Size2DI> { public static Size2dI from(Common.Size2DI sc2ApiSize2dI) { require("sc2api size2dI", sc2ApiSize2dI); return new Size2dI(sc2ApiSize2dI); } private Size2dI(Common.Size2DI sc2ApiSize2dI); private Size2dI(int x, int y); static Size2dI from(Common.Size2DI sc2ApiSize2dI); @Override Common.Size2DI toSc2Api(); int getX(); int getY(); @Override boolean equals(Object o); @Override int hashCode(); @Override String toString(); static Size2dI of(int x, int y); }### Answer:
@Test void throwsExceptionWhenSc2ApiSize2dIIsNull() { assertThatExceptionOfType(IllegalArgumentException.class) .isThrownBy(() -> Size2dI.from(nothing())) .withMessage("sc2api size2dI is required"); }
@Test void convertsAllFieldsFromSc2ApiSize2dI() { assertThatAllFieldsAreConverted(Size2dI.from(sc2ApiSize2dI())); }
@Test void throwsExceptionWhenXIsNotProvided() { assertThatExceptionOfType(IllegalArgumentException.class) .isThrownBy(() -> Size2dI.from(without( () -> sc2ApiSize2dI().toBuilder(), Common.Size2DI.Builder::clearX).build())) .withMessage("x is required"); }
@Test void throwsExceptionWhenYIsNotProvided() { assertThatExceptionOfType(IllegalArgumentException.class) .isThrownBy(() -> Size2dI.from(without( () -> sc2ApiSize2dI().toBuilder(), Common.Size2DI.Builder::clearY).build())) .withMessage("y is required"); } |
### Question:
Size2dI implements Sc2ApiSerializable<Common.Size2DI> { public static Size2dI of(int x, int y) { return new Size2dI(x, y); } private Size2dI(Common.Size2DI sc2ApiSize2dI); private Size2dI(int x, int y); static Size2dI from(Common.Size2DI sc2ApiSize2dI); @Override Common.Size2DI toSc2Api(); int getX(); int getY(); @Override boolean equals(Object o); @Override int hashCode(); @Override String toString(); static Size2dI of(int x, int y); }### Answer:
@Test void throwsExceptionWhenSize2dIIsNotInValidRange() { assertThatExceptionOfType(IllegalArgumentException.class) .isThrownBy(() -> Size2dI.of(-1, 1)) .withMessage("size2di [x] has value -1 and is lower than 0"); assertThatExceptionOfType(IllegalArgumentException.class) .isThrownBy(() -> Size2dI.of(1, -1)) .withMessage("size2di [y] has value -1 and is lower than 0"); } |
### Question:
ObserverAction implements Sc2ApiSerializable<Sc2Api.ObserverAction> { public static Builder observerAction() { return new Builder(); } private ObserverAction(ActionObserverPlayerPerspective playerPerspective); private ObserverAction(ActionObserverCameraMove cameraMove); private ObserverAction(ActionObserverCameraFollowPlayer cameraFollowPlayer); private ObserverAction(ActionObserverCameraFollowUnits cameraFollowUnits); static Builder observerAction(); @Override Sc2Api.ObserverAction toSc2Api(); Optional<ActionObserverPlayerPerspective> getPlayerPerspective(); Optional<ActionObserverCameraMove> getCameraMove(); Optional<ActionObserverCameraFollowPlayer> getCameraFollowPlayer(); Optional<ActionObserverCameraFollowUnits> getCameraFollowUnits(); @Override boolean equals(Object o); @Override int hashCode(); @Override String toString(); }### Answer:
@Test void throwsExceptionWhenThereIsNoActionCase() { assertThatExceptionOfType(IllegalArgumentException.class) .isThrownBy(() -> observerAction().of((ActionObserverPlayerPerspective) nothing())) .withMessage("player perspective is required"); assertThatExceptionOfType(IllegalArgumentException.class) .isThrownBy(() -> observerAction().of((ActionObserverCameraMove) nothing())) .withMessage("camera move is required"); assertThatExceptionOfType(IllegalArgumentException.class) .isThrownBy(() -> observerAction().of((ActionObserverCameraFollowPlayer) nothing())) .withMessage("camera follow player is required"); assertThatExceptionOfType(IllegalArgumentException.class) .isThrownBy(() -> observerAction().of((ActionObserverCameraFollowUnits) nothing())) .withMessage("camera follow units is required"); } |
### Question:
ActionObserverCameraFollowPlayer implements Sc2ApiSerializable<Sc2Api.ActionObserverCameraFollowPlayer> { public static ActionObserverCameraFollowPlayerSyntax cameraFollowPlayer() { return new ActionObserverCameraFollowPlayer.Builder(); } private ActionObserverCameraFollowPlayer(ActionObserverCameraFollowPlayer.Builder builder); static ActionObserverCameraFollowPlayerSyntax cameraFollowPlayer(); @Override Sc2Api.ActionObserverCameraFollowPlayer toSc2Api(); int getPlayerId(); @Override boolean equals(Object o); @Override int hashCode(); @Override String toString(); }### Answer:
@Test void throwsExceptionWhenPlayerIdIsNotSet() { assertThatExceptionOfType(IllegalArgumentException.class) .isThrownBy(() -> ((ActionObserverCameraFollowPlayer.Builder) cameraFollowPlayer()).build()) .withMessage("player id is required"); } |
### Question:
ActionObserverPlayerPerspective implements Sc2ApiSerializable<Sc2Api.ActionObserverPlayerPerspective> { public static ActionObserverPlayerPerspectiveSyntax playerPerspective() { return new Builder(); } private ActionObserverPlayerPerspective(Builder builder); static ActionObserverPlayerPerspectiveSyntax playerPerspective(); @Override Sc2Api.ActionObserverPlayerPerspective toSc2Api(); int getPlayerId(); @Override boolean equals(Object o); @Override int hashCode(); @Override String toString(); }### Answer:
@Test void throwsExceptionWhenPlayerIdIsNotSet() { assertThatExceptionOfType(IllegalArgumentException.class) .isThrownBy(() -> ((ActionObserverPlayerPerspective.Builder) playerPerspective()).build()) .withMessage("player id is required"); } |
### Question:
ActionObserverCameraFollowUnits implements Sc2ApiSerializable<Sc2Api.ActionObserverCameraFollowUnits> { public static ActionObserverCameraFollowUnitsSyntax cameraFollowUnits() { return new Builder(); } private ActionObserverCameraFollowUnits(Builder builder); static ActionObserverCameraFollowUnitsSyntax cameraFollowUnits(); @Override Sc2Api.ActionObserverCameraFollowUnits toSc2Api(); Set<Tag> getUnits(); @Override boolean equals(Object o); @Override int hashCode(); @Override String toString(); }### Answer:
@Test void throwsExceptionWhenUnitsAreNotSet() { assertThatExceptionOfType(IllegalArgumentException.class) .isThrownBy(() -> ((ActionObserverCameraFollowUnits.Builder) cameraFollowUnits()).build()) .withMessage("units is required"); } |
### Question:
ActionObserverCameraMove implements Sc2ApiSerializable<Sc2Api.ActionObserverCameraMove> { @Override public Sc2Api.ActionObserverCameraMove toSc2Api() { return Sc2Api.ActionObserverCameraMove.newBuilder() .setWorldPos(position.toSc2Api()) .setDistance(distance) .build(); } private ActionObserverCameraMove(Builder builder); static ActionObserverCameraMoveSyntax cameraMove(); @Override Sc2Api.ActionObserverCameraMove toSc2Api(); Point2d getPosition(); float getDistance(); @Override boolean equals(Object o); @Override int hashCode(); @Override String toString(); }### Answer:
@Test void serializesToSc2ApiActionObserverCameraMove() { assertThatAllFieldsInRequestAreSerialized(observerCameraMove().build().toSc2Api()); } |
### Question:
ActionObserverCameraMove implements Sc2ApiSerializable<Sc2Api.ActionObserverCameraMove> { public static ActionObserverCameraMoveSyntax cameraMove() { return new Builder(); } private ActionObserverCameraMove(Builder builder); static ActionObserverCameraMoveSyntax cameraMove(); @Override Sc2Api.ActionObserverCameraMove toSc2Api(); Point2d getPosition(); float getDistance(); @Override boolean equals(Object o); @Override int hashCode(); @Override String toString(); }### Answer:
@Test void throwsExceptionWhenPositionIsNotSet() { assertThatExceptionOfType(IllegalArgumentException.class) .isThrownBy(() -> ((ActionObserverCameraMove.Builder) cameraMove()).build()) .withMessage("position is required"); } |
### Question:
ActionChat implements Sc2ApiSerializable<Sc2Api.ActionChat> { public static ActionChat from(Sc2Api.ActionChat sc2ApiActionChat) { require("sc2api action chat", sc2ApiActionChat); return new ActionChat(sc2ApiActionChat); } private ActionChat(Builder builder); private ActionChat(Sc2Api.ActionChat sc2ApiActionChat); static ActionChatSyntax message(); static ActionChat from(Sc2Api.ActionChat sc2ApiActionChat); @Override Sc2Api.ActionChat toSc2Api(); Channel getChannel(); String getMessage(); @Override boolean equals(Object o); @Override int hashCode(); @Override String toString(); }### Answer:
@Test void throwsExceptionWhenSc2ApiActionChatIsNull() { assertThatExceptionOfType(IllegalArgumentException.class) .isThrownBy(() -> ActionChat.from(nothing())) .withMessage("sc2api action chat is required"); }
@Test void convertsSc2ApiActionChatToActionChat() { assertThatAllFieldsAreConverted(ActionChat.from(sc2ApiActionWithChat())); }
@Test void throwsExceptionWhenSc2ApiChatChannelIsNotProvided() { assertThatExceptionOfType(IllegalArgumentException.class) .isThrownBy(() -> ActionChat.Channel.from(nothing())) .withMessage("sc2api action chat channel is required"); } |
### Question:
ActionSpatial implements Sc2ApiSerializable<Spatial.ActionSpatial>, GeneralizableAbility<ActionSpatial> { public static ActionSpatial from(Spatial.ActionSpatial sc2ApiActionSpatial) { require("sc2api action spatial", sc2ApiActionSpatial); return new ActionSpatial(sc2ApiActionSpatial); } private ActionSpatial(Spatial.ActionSpatial sc2ApiActionSpatial); private ActionSpatial(ActionSpatialUnitCommand unitCommand); private ActionSpatial(ActionSpatialCameraMove cameraMove); private ActionSpatial(ActionSpatialUnitSelectionPoint unitSelectionPoint); private ActionSpatial(ActionSpatialUnitSelectionRect unitSelectionRect); static ActionSpatial of(ActionSpatialUnitCommand unitCommand); static ActionSpatial of(ActionSpatialCameraMove cameraMove); static ActionSpatial of(ActionSpatialUnitSelectionPoint unitSelectionPoint); static ActionSpatial of(ActionSpatialUnitSelectionRect unitSelectionRect); static ActionSpatial from(Spatial.ActionSpatial sc2ApiActionSpatial); @Override Spatial.ActionSpatial toSc2Api(); Optional<ActionSpatialUnitCommand> getUnitCommand(); Optional<ActionSpatialCameraMove> getCameraMove(); Optional<ActionSpatialUnitSelectionPoint> getUnitSelectionPoint(); Optional<ActionSpatialUnitSelectionRect> getUnitSelectionRect(); @Override ActionSpatial generalizeAbility(UnaryOperator<Ability> generalize); @Override boolean equals(Object o); @Override int hashCode(); @Override String toString(); }### Answer:
@Test void throwsExceptionWhenSc2ApiActionSpatialIsNull() { assertThatExceptionOfType(IllegalArgumentException.class) .isThrownBy(() -> ActionSpatial.from(nothing())) .withMessage("sc2api action spatial is required"); } |
### Question:
ActionSpatial implements Sc2ApiSerializable<Spatial.ActionSpatial>, GeneralizableAbility<ActionSpatial> { @Override public ActionSpatial generalizeAbility(UnaryOperator<Ability> generalize) { return getUnitCommand() .map(command -> ActionSpatial.of(command.generalizeAbility(generalize))) .orElse(this); } private ActionSpatial(Spatial.ActionSpatial sc2ApiActionSpatial); private ActionSpatial(ActionSpatialUnitCommand unitCommand); private ActionSpatial(ActionSpatialCameraMove cameraMove); private ActionSpatial(ActionSpatialUnitSelectionPoint unitSelectionPoint); private ActionSpatial(ActionSpatialUnitSelectionRect unitSelectionRect); static ActionSpatial of(ActionSpatialUnitCommand unitCommand); static ActionSpatial of(ActionSpatialCameraMove cameraMove); static ActionSpatial of(ActionSpatialUnitSelectionPoint unitSelectionPoint); static ActionSpatial of(ActionSpatialUnitSelectionRect unitSelectionRect); static ActionSpatial from(Spatial.ActionSpatial sc2ApiActionSpatial); @Override Spatial.ActionSpatial toSc2Api(); Optional<ActionSpatialUnitCommand> getUnitCommand(); Optional<ActionSpatialCameraMove> getCameraMove(); Optional<ActionSpatialUnitSelectionPoint> getUnitSelectionPoint(); Optional<ActionSpatialUnitSelectionRect> getUnitSelectionRect(); @Override ActionSpatial generalizeAbility(UnaryOperator<Ability> generalize); @Override boolean equals(Object o); @Override int hashCode(); @Override String toString(); }### Answer:
@Test void createsCopyWithGeneralizedAbility() { ActionSpatial actionSpatialWithUnitCommand = actionSpatialWithUnitCommand(); ActionSpatial actionSpatialWithCameraMove = actionSpatialWithCameraMove(); ActionSpatial actionSpatialWithSelectionPoint = actionSpatialWithSelectionPoint(); ActionSpatial actionSpatialWithSelectionRect = actionSpatialWithSelectionRect(); UnaryOperator<Ability> generalize = ability -> Abilities.ATTACK_REDIRECT; assertThat(actionSpatialWithUnitCommand.generalizeAbility(generalize)).isNotEqualTo(actionSpatialWithUnitCommand); assertThat(actionSpatialWithCameraMove.generalizeAbility(generalize)).isSameAs(actionSpatialWithCameraMove); assertThat(actionSpatialWithSelectionPoint.generalizeAbility(generalize)) .isSameAs(actionSpatialWithSelectionPoint); assertThat(actionSpatialWithSelectionRect.generalizeAbility(generalize)) .isSameAs(actionSpatialWithSelectionRect); } |
### Question:
ActionSpatialUnitSelectionRect implements Sc2ApiSerializable<Spatial.ActionSpatialUnitSelectionRect> { public static ActionSpatialUnitSelectionRect from( Spatial.ActionSpatialUnitSelectionRect sc2ApiActionSpatialUnitSelectionRect) { require("sc2api action spatial unit selection rect", sc2ApiActionSpatialUnitSelectionRect); return new ActionSpatialUnitSelectionRect(sc2ApiActionSpatialUnitSelectionRect); } private ActionSpatialUnitSelectionRect(Builder builder); private ActionSpatialUnitSelectionRect(
Spatial.ActionSpatialUnitSelectionRect sc2ApiActionSpatialUnitSelectionRect); static ActionSpatialUnitSelectionRectSyntax select(); static ActionSpatialUnitSelectionRect from(
Spatial.ActionSpatialUnitSelectionRect sc2ApiActionSpatialUnitSelectionRect); @Override Spatial.ActionSpatialUnitSelectionRect toSc2Api(); Set<RectangleI> getSelectionsInScreenCoord(); boolean isSelectionAdd(); @Override boolean equals(Object o); @Override int hashCode(); @Override String toString(); }### Answer:
@Test void throwsExceptionWhenSc2ApiActionSpatialUnitSelectionRectIsNull() { assertThatExceptionOfType(IllegalArgumentException.class) .isThrownBy(() -> ActionSpatialUnitSelectionRect.from(nothing())) .withMessage("sc2api action spatial unit selection rect is required"); }
@Test void convertsSc2ApiActionSpatialUnitSelectionRectToActionSpatialUnitSelectionRect() { assertThatAllFieldsAreConverted(ActionSpatialUnitSelectionRect.from(sc2ApiActionSpatialUnitSelectionRect())); } |
### Question:
ActionSpatialUnitSelectionPoint implements Sc2ApiSerializable<Spatial.ActionSpatialUnitSelectionPoint> { public static ActionSpatialUnitSelectionPoint from( Spatial.ActionSpatialUnitSelectionPoint sc2apiActionSpatialUnitSelectionPoint) { require("sc2api action spatial unit selection point", sc2apiActionSpatialUnitSelectionPoint); return new ActionSpatialUnitSelectionPoint(sc2apiActionSpatialUnitSelectionPoint); } private ActionSpatialUnitSelectionPoint(Builder builder); private ActionSpatialUnitSelectionPoint(
Spatial.ActionSpatialUnitSelectionPoint sc2apiActionSpatialUnitSelectionPoint); static ActionSpatialUnitSelectionPointSyntax click(); static ActionSpatialUnitSelectionPoint from(
Spatial.ActionSpatialUnitSelectionPoint sc2apiActionSpatialUnitSelectionPoint); @Override Spatial.ActionSpatialUnitSelectionPoint toSc2Api(); PointI getSelectionInScreenCoord(); Type getType(); @Override boolean equals(Object o); @Override int hashCode(); @Override String toString(); }### Answer:
@Test void throwsExceptionWhenSc2ApiActionSpatialUnitSelectionPointIsNull() { assertThatExceptionOfType(IllegalArgumentException.class) .isThrownBy(() -> ActionSpatialUnitSelectionPoint.from(nothing())) .withMessage("sc2api action spatial unit selection point is required"); }
@Test void convertsSc2ApiActionSpatialUnitSelectionPointToActionSpatialUnitSelectionPoint() { assertThatAllFieldsAreConverted(ActionSpatialUnitSelectionPoint.from(sc2ApiActionSpatialUnitSelectionPoint())); }
@Test void throwsExceptionWhenUnitSelectionPointTypeIsNull() { assertThatExceptionOfType(IllegalArgumentException.class) .isThrownBy(() -> ActionSpatialUnitSelectionPoint.Type.from(nothing())) .withMessage("sc2api unit selection point type is required"); } |
### Question:
ActionSpatialUnitCommand implements
Sc2ApiSerializable<Spatial.ActionSpatialUnitCommand>, GeneralizableAbility<ActionSpatialUnitCommand> { public static ActionSpatialUnitCommand from(Spatial.ActionSpatialUnitCommand sc2apiActionSpatialUnitCommand) { require("sc2api action spatial unit command", sc2apiActionSpatialUnitCommand); return new ActionSpatialUnitCommand(sc2apiActionSpatialUnitCommand); } private ActionSpatialUnitCommand(Builder builder); private ActionSpatialUnitCommand(Spatial.ActionSpatialUnitCommand sc2ApiActionSpatialUnitCommand); static ActionSpatialUnitCommandSyntax unitCommand(); static ActionSpatialUnitCommand from(Spatial.ActionSpatialUnitCommand sc2apiActionSpatialUnitCommand); @Override Spatial.ActionSpatialUnitCommand toSc2Api(); Ability getAbility(); Optional<PointI> getTargetInScreenCoord(); Optional<PointI> getTargetInMinimapCoord(); boolean isQueued(); @Override ActionSpatialUnitCommand generalizeAbility(UnaryOperator<Ability> generalize); @Override boolean equals(Object o); @Override int hashCode(); @Override String toString(); }### Answer:
@Test void throwsExceptionWhenSc2ApiActionSpatialUnitCommandIsNull() { assertThatExceptionOfType(IllegalArgumentException.class) .isThrownBy(() -> ActionSpatialUnitCommand.from(nothing())) .withMessage("sc2api action spatial unit command is required"); }
@Test void convertsSc2ApiActionSpatialUnitCommandToActionSpatialUnitCommand() { assertThatAllFieldsAreConverted(ActionSpatialUnitCommand.from(sc2ApiActionSpatialUnitCommand())); } |
### Question:
ActionSpatialUnitCommand implements
Sc2ApiSerializable<Spatial.ActionSpatialUnitCommand>, GeneralizableAbility<ActionSpatialUnitCommand> { @Override public Spatial.ActionSpatialUnitCommand toSc2Api() { Spatial.ActionSpatialUnitCommand.Builder aSc2ApiUnitCommand = Spatial.ActionSpatialUnitCommand.newBuilder() .setAbilityId(ability.toSc2Api()) .setQueueCommand(queued); getTargetInScreenCoord().map(PointI::toSc2Api).ifPresent(aSc2ApiUnitCommand::setTargetScreenCoord); getTargetInMinimapCoord().map(PointI::toSc2Api).ifPresent(aSc2ApiUnitCommand::setTargetMinimapCoord); return aSc2ApiUnitCommand.build(); } private ActionSpatialUnitCommand(Builder builder); private ActionSpatialUnitCommand(Spatial.ActionSpatialUnitCommand sc2ApiActionSpatialUnitCommand); static ActionSpatialUnitCommandSyntax unitCommand(); static ActionSpatialUnitCommand from(Spatial.ActionSpatialUnitCommand sc2apiActionSpatialUnitCommand); @Override Spatial.ActionSpatialUnitCommand toSc2Api(); Ability getAbility(); Optional<PointI> getTargetInScreenCoord(); Optional<PointI> getTargetInMinimapCoord(); boolean isQueued(); @Override ActionSpatialUnitCommand generalizeAbility(UnaryOperator<Ability> generalize); @Override boolean equals(Object o); @Override int hashCode(); @Override String toString(); }### Answer:
@Test void serializedDefaultValueForQueuedFieldIsNotProvided() { assertThat(defaultUnitCommand().build().toSc2Api().getQueueCommand()) .as("sc2api action spatial unit command: default queued value").isFalse(); } |
### Question:
ActionSpatialCameraMove implements Sc2ApiSerializable<Spatial.ActionSpatialCameraMove> { public static ActionSpatialCameraMove from(Spatial.ActionSpatialCameraMove sc2ApiActionSpatialCameraMove) { require("sc2api action spatial camera move", sc2ApiActionSpatialCameraMove); return new ActionSpatialCameraMove(sc2ApiActionSpatialCameraMove); } private ActionSpatialCameraMove(Builder builder); private ActionSpatialCameraMove(Spatial.ActionSpatialCameraMove sc2ApiActionSpatialCameraMove); static Builder cameraMove(); static ActionSpatialCameraMove from(Spatial.ActionSpatialCameraMove sc2ApiActionSpatialCameraMove); @Override Spatial.ActionSpatialCameraMove toSc2Api(); PointI getCenterInMinimap(); @Override boolean equals(Object o); @Override int hashCode(); @Override String toString(); }### Answer:
@Test void throwsExceptionWhenSc2ApiActionSpatialCameraMoveIsNull() { assertThatExceptionOfType(IllegalArgumentException.class) .isThrownBy(() -> ActionSpatialCameraMove.from(nothing())) .withMessage("sc2api action spatial camera move is required"); }
@Test void convertsSc2ApiActionSpatialCameraMoveToActionSpatialCameraMove() { assertThatAllFieldsAreConverted(ActionSpatialCameraMove.from(sc2ApiActionSpatialCameraMove())); } |
### Question:
ActionUiProductionPanelRemoveFromQueue implements Sc2ApiSerializable<Ui.ActionProductionPanelRemoveFromQueue> { public static ActionUiProductionPanelRemoveFromQueue from( Ui.ActionProductionPanelRemoveFromQueue sc2ApiActionProductionPanelRemoveFromQueue) { require("sc2api action ui production panel remove from queue", sc2ApiActionProductionPanelRemoveFromQueue); return new ActionUiProductionPanelRemoveFromQueue(sc2ApiActionProductionPanelRemoveFromQueue); } private ActionUiProductionPanelRemoveFromQueue(Builder builder); private ActionUiProductionPanelRemoveFromQueue(
Ui.ActionProductionPanelRemoveFromQueue sc2ApiActionProductionPanelRemoveFromQueue); static ActionUiProductionPanelRemoveFromQueue from(
Ui.ActionProductionPanelRemoveFromQueue sc2ApiActionProductionPanelRemoveFromQueue); static ActionUiProductionPanelRemoveFromQueueSyntax removeFromQueue(); int getUnitIndex(); @Override Ui.ActionProductionPanelRemoveFromQueue toSc2Api(); @Override boolean equals(Object o); @Override int hashCode(); @Override String toString(); }### Answer:
@Test void throwsExceptionWhenSc2ApiActionUiProductionPanelRemoveFromQueueIsNull() { assertThatExceptionOfType(IllegalArgumentException.class) .isThrownBy(() -> ActionUiProductionPanelRemoveFromQueue.from(nothing())) .withMessage("sc2api action ui production panel remove from queue is required"); }
@Test void convertsSc2ApiActionUiProductionPanelRemoveFromQueueToActionUiProductionPanelRemoveFromQueue() { assertThatAllFieldsAreConverted(ActionUiProductionPanelRemoveFromQueue.from( sc2ApiActionUiProductionPanelRemoveFromQueue())); } |
### Question:
ActionUiMultiPanel implements Sc2ApiSerializable<Ui.ActionMultiPanel> { public static ActionUiMultiPanel from(Ui.ActionMultiPanel sc2ApiActionMultiPanel) { require("sc2api action ui multi panel", sc2ApiActionMultiPanel); return new ActionUiMultiPanel(sc2ApiActionMultiPanel); } private ActionUiMultiPanel(Builder builder); private ActionUiMultiPanel(Ui.ActionMultiPanel sc2ApiActionMultiPanel); static ActionUiMultiPanelSyntax multiPanel(); static ActionUiMultiPanel from(Ui.ActionMultiPanel sc2ApiActionMultiPanel); @Override Ui.ActionMultiPanel toSc2Api(); Type getType(); int getUnitIndex(); @Override boolean equals(Object o); @Override int hashCode(); @Override String toString(); }### Answer:
@Test void throwsExceptionWhenSc2ApiActionUiMultiPanelIsNull() { assertThatExceptionOfType(IllegalArgumentException.class) .isThrownBy(() -> ActionUiMultiPanel.from(nothing())) .withMessage("sc2api action ui multi panel is required"); }
@Test void convertsSc2ApiActionUiMultiPanelToActionUiMultiPanel() { assertThatAllFieldsAreConverted(ActionUiMultiPanel.from(sc2ApiActionUiMultiPanel())); }
@Test void throwsExceptionWhenMultiPanelTypeIsNotProvided() { assertThatExceptionOfType(IllegalArgumentException.class) .isThrownBy(() -> ActionUiMultiPanel.Type.from(nothing())) .withMessage("sc2api multi panel type is required"); } |
### Question:
ActionUiSelectIdleWorker implements Sc2ApiSerializable<Ui.ActionSelectIdleWorker> { public static ActionUiSelectIdleWorker from(Ui.ActionSelectIdleWorker sc2ApiActionSelectIdleWorker) { require("sc2api action ui select idle worker", sc2ApiActionSelectIdleWorker); return new ActionUiSelectIdleWorker(sc2ApiActionSelectIdleWorker); } private ActionUiSelectIdleWorker(Builder builder); private ActionUiSelectIdleWorker(Ui.ActionSelectIdleWorker sc2ApiActionSelectIdleWorker); static ActionUiSelectIdleWorkerSyntax selectIdleWorker(); static ActionUiSelectIdleWorker from(Ui.ActionSelectIdleWorker sc2ApiActionSelectIdleWorker); @Override Ui.ActionSelectIdleWorker toSc2Api(); Type getType(); @Override boolean equals(Object o); @Override int hashCode(); @Override String toString(); }### Answer:
@Test void throwsExceptionWhenSc2ApiActionUiSelectIdleWorkerIsNull() { assertThatExceptionOfType(IllegalArgumentException.class) .isThrownBy(() -> ActionUiSelectIdleWorker.from(nothing())) .withMessage("sc2api action ui select idle worker is required"); }
@Test void convertsSc2ApiActionUiSelectIdleWorkerToActionUiSelectIdleWorker() { assertThatAllFieldsAreConverted(ActionUiSelectIdleWorker.from(sc2ApiActionUiSelectIdleWorker())); }
@Test void throwsExceptionWhenSelectIdleWorkerTypeIsNotProvided() { assertThatExceptionOfType(IllegalArgumentException.class) .isThrownBy(() -> ActionUiSelectIdleWorker.Type.from(nothing())) .withMessage("sc2api select idle worker type is required"); } |
### Question:
ActionUiCargoPanelUnload implements Sc2ApiSerializable<Ui.ActionCargoPanelUnload> { public static ActionUiCargoPanelUnload from(Ui.ActionCargoPanelUnload sc2ApiActionCargoPanelUnload) { require("sc2api action ui cargo panel unload", sc2ApiActionCargoPanelUnload); return new ActionUiCargoPanelUnload(sc2ApiActionCargoPanelUnload); } private ActionUiCargoPanelUnload(Builder builder); private ActionUiCargoPanelUnload(Ui.ActionCargoPanelUnload sc2ApiActionCargoPanelUnload); static ActionUiCargoPanelUnload from(Ui.ActionCargoPanelUnload sc2ApiActionCargoPanelUnload); static ActionUiCargoPanelUnloadSyntax cargoPanelUnload(); int getUnitIndex(); @Override Ui.ActionCargoPanelUnload toSc2Api(); @Override boolean equals(Object o); @Override int hashCode(); @Override String toString(); }### Answer:
@Test void throwsExceptionWhenSc2ApiActionUiCargoPanelUnloadIsNull() { assertThatExceptionOfType(IllegalArgumentException.class) .isThrownBy(() -> ActionUiCargoPanelUnload.from(nothing())) .withMessage("sc2api action ui cargo panel unload is required"); }
@Test void convertsSc2ApiActionUiCargoPanelUnloadToActionUiCargoPanelUnload() { assertThatAllFieldsAreConverted(ActionUiCargoPanelUnload.from(sc2ApiActionUiCargoPanelUnload())); } |
### Question:
ActionUiSelectLarva implements Sc2ApiSerializable<Ui.ActionSelectLarva> { public static ActionUiSelectLarva from(Ui.ActionSelectLarva sc2ApiActionSelectLarva) { require("sc2api action ui select larva", sc2ApiActionSelectLarva); return new ActionUiSelectLarva(); } private ActionUiSelectLarva(); static ActionUiSelectLarva from(Ui.ActionSelectLarva sc2ApiActionSelectLarva); static ActionUiSelectLarva selectLarva(); @Override Ui.ActionSelectLarva toSc2Api(); @Override boolean equals(Object o); @Override int hashCode(); @Override String toString(); }### Answer:
@Test void throwsExceptionWhenSc2ApiActionUiSelectLarvaIsNull() { assertThatExceptionOfType(IllegalArgumentException.class) .isThrownBy(() -> ActionUiSelectLarva.from(nothing())) .withMessage("sc2api action ui select larva is required"); }
@Test void convertsSc2ApiActionUiSelectLarvaToActionUiSelectLarva() { assertThat(ActionUiSelectLarva.from(sc2ApiActionUiSelectLarva())).as("action ui select larva").isNotNull(); } |
### Question:
ActionUiControlGroup implements Sc2ApiSerializable<Ui.ActionControlGroup> { public static ActionUiControlGroup from(Ui.ActionControlGroup sc2ApiActionControlGroup) { require("sc2api action ui control group", sc2ApiActionControlGroup); return new ActionUiControlGroup(sc2ApiActionControlGroup); } private ActionUiControlGroup(Builder builder); private ActionUiControlGroup(Ui.ActionControlGroup sc2ApiActionControlGroup); static ActionUiControlGroupSyntax controlGroup(); static ActionUiControlGroup from(Ui.ActionControlGroup sc2ApiActionControlGroup); @Override Ui.ActionControlGroup toSc2Api(); Action getAction(); int getIndex(); @Override boolean equals(Object o); @Override int hashCode(); @Override String toString(); }### Answer:
@Test void throwsExceptionWhenSc2ApiActionUiControlGroupIsNull() { assertThatExceptionOfType(IllegalArgumentException.class) .isThrownBy(() -> ActionUiControlGroup.from(nothing())) .withMessage("sc2api action ui control group is required"); }
@Test void convertsSc2ApiActionUiControlGroupToActionUiControlGroup() { assertThatAllFieldsAreConverted(ActionUiControlGroup.from(sc2ApiActionUiControlGroup())); }
@Test void throwsExceptionWhenControlGroupActionIsNotProvided() { assertThatExceptionOfType(IllegalArgumentException.class) .isThrownBy(() -> ActionUiControlGroup.Action.from(nothing())) .withMessage("sc2api control group action is required"); } |
### Question:
ActionUiControlGroup implements Sc2ApiSerializable<Ui.ActionControlGroup> { public static ActionUiControlGroupSyntax controlGroup() { return new Builder(); } private ActionUiControlGroup(Builder builder); private ActionUiControlGroup(Ui.ActionControlGroup sc2ApiActionControlGroup); static ActionUiControlGroupSyntax controlGroup(); static ActionUiControlGroup from(Ui.ActionControlGroup sc2ApiActionControlGroup); @Override Ui.ActionControlGroup toSc2Api(); Action getAction(); int getIndex(); @Override boolean equals(Object o); @Override int hashCode(); @Override String toString(); }### Answer:
@Test void throwsExceptionWhenIndexIsNotInValidRange() { assertThatExceptionOfType(IllegalArgumentException.class) .isThrownBy(() -> controlGroup().on(-1).withMode(APPEND).build()) .withMessage("control group index has value -1 and is lower than 0"); assertThatExceptionOfType(IllegalArgumentException.class) .isThrownBy(() -> controlGroup().on(10).withMode(APPEND).build()) .withMessage("control group index has value 10 and is greater than 9"); } |
### Question:
AbilityData implements Serializable { public static AbilityData from(Data.AbilityData sc2ApiAbilityData) { require("sc2api ability data", sc2ApiAbilityData); return new AbilityData(sc2ApiAbilityData); } private AbilityData(Data.AbilityData sc2ApiAbilityData); static AbilityData from(Data.AbilityData sc2ApiAbilityData); Ability getAbility(); String getLinkName(); int getLinkIndex(); Optional<String> getButtonName(); Optional<String> getFriendlyName(); Optional<String> getHotkey(); Optional<Ability> getRemapsToAbility(); boolean isAvailable(); Optional<Target> getTarget(); boolean isAllowMinimap(); boolean isAllowAutocast(); boolean isBuilding(); Optional<Float> getFootprintRadius(); boolean isInstantPlacement(); Optional<Float> getCastRange(); @Override boolean equals(Object o); @Override int hashCode(); @Override String toString(); }### Answer:
@Test void throwsExceptionWhenSc2ApiAbilityDataIsNull() { assertThatExceptionOfType(IllegalArgumentException.class) .isThrownBy(() -> AbilityData.from(nothing())) .withMessage("sc2api ability data is required"); }
@Test void convertsAllFieldsFromSc2ApiUnit() { assertThatAllFieldsAreConverted(AbilityData.from(sc2ApiAbilityData())); }
@Test void throwsExceptionWhenAbilityIsNotProvided() { assertThatExceptionOfType(IllegalArgumentException.class) .isThrownBy(() -> AbilityData.from(without( () -> sc2ApiAbilityData().toBuilder(), Data.AbilityData.Builder::clearAbilityId).build())) .withMessage("ability is required"); }
@Test void throwsExceptionWhenLinkNameIsNotProvided() { assertThatExceptionOfType(IllegalArgumentException.class) .isThrownBy(() -> AbilityData.from(without( () -> sc2ApiAbilityData().toBuilder(), Data.AbilityData.Builder::clearLinkName).build())) .withMessage("link name is required"); }
@Test void throwsExceptionWhenLinkIndexIsNotProvided() { assertThatExceptionOfType(IllegalArgumentException.class) .isThrownBy(() -> AbilityData.from(without( () -> sc2ApiAbilityData().toBuilder(), Data.AbilityData.Builder::clearLinkIndex).build())) .withMessage("link index is required"); } |
### Question:
ActionUiSelectArmy implements Sc2ApiSerializable<Ui.ActionSelectArmy> { public static ActionUiSelectArmy from(Ui.ActionSelectArmy sc2ApiActionSelectArmy) { require("sc2api action ui select army", sc2ApiActionSelectArmy); return new ActionUiSelectArmy(sc2ApiActionSelectArmy); } private ActionUiSelectArmy(Builder builder); private ActionUiSelectArmy(Ui.ActionSelectArmy sc2ApiActionSelectArmy); static ActionUiSelectArmySyntax selectArmy(); static ActionUiSelectArmy from(Ui.ActionSelectArmy sc2ApiActionSelectArmy); @Override Ui.ActionSelectArmy toSc2Api(); boolean isSelectionAdd(); @Override boolean equals(Object o); @Override int hashCode(); @Override String toString(); }### Answer:
@Test void throwsExceptionWhenSc2ApiActionUiSelectArmyIsNull() { assertThatExceptionOfType(IllegalArgumentException.class) .isThrownBy(() -> ActionUiSelectArmy.from(nothing())) .withMessage("sc2api action ui select army is required"); }
@Test void convertsSc2ApiActionUiSelectArmyToActionUiSelectArmy() { assertThatAllFieldsAreConverted(ActionUiSelectArmy.from(sc2ApiActionUiSelectArmy())); } |
### Question:
ActionUiToggleAutocast implements Sc2ApiSerializable<Ui.ActionToggleAutocast> { public static ActionUiToggleAutocast from(Ui.ActionToggleAutocast sc2ApiActionToggleAutocast) { require("sc2api action ui toggle autocast", sc2ApiActionToggleAutocast); return new ActionUiToggleAutocast(sc2ApiActionToggleAutocast); } private ActionUiToggleAutocast(Builder builder); private ActionUiToggleAutocast(Ui.ActionToggleAutocast sc2ApiActionToggleAutocast); static ActionUiToggleAutocast from(Ui.ActionToggleAutocast sc2ApiActionToggleAutocast); static ActionUiToggleAutocastSyntax toggleAutocast(); @Override Ui.ActionToggleAutocast toSc2Api(); Ability getAbility(); @Override boolean equals(Object o); @Override int hashCode(); @Override String toString(); }### Answer:
@Test void throwsExceptionWhenSc2ApiActionUiToggleAutocastIsNull() { assertThatExceptionOfType(IllegalArgumentException.class) .isThrownBy(() -> ActionUiToggleAutocast.from(nothing())) .withMessage("sc2api action ui toggle autocast is required"); }
@Test void convertsSc2ApiActionUiToggleAutocastToActionUiToggleAutocast() { assertThatAllFieldsAreConverted(ActionUiToggleAutocast.from(sc2ApiActionUiToggleAutocast())); } |
### Question:
ActionError implements Serializable { public static ActionError from(Sc2Api.ActionError sc2ApiActionError) { require("sc2api action error", sc2ApiActionError); return new ActionError(sc2ApiActionError); } private ActionError(Sc2Api.ActionError sc2ApiActionError); static ActionError from(Sc2Api.ActionError sc2ApiActionError); Optional<Tag> getUnitTag(); Optional<Ability> getAbility(); ActionResult getActionResult(); @Override boolean equals(Object o); @Override int hashCode(); @Override String toString(); }### Answer:
@Test void throwsExceptionWhenSc2ApiActionErrorIsNull() { assertThatExceptionOfType(IllegalArgumentException.class) .isThrownBy(() -> ActionError.from(nothing())) .withMessage("sc2api action error is required"); }
@Test void convertsSc2ApiActionErrorToActionError() { assertThatAllFieldsAreConverted(ActionError.from(sc2ApiActionError())); }
@Test void throwsExceptionWhenActionResultIsNotProvided() { assertThatExceptionOfType(IllegalArgumentException.class) .isThrownBy(() -> ActionError.from(without( () -> sc2ApiActionError().toBuilder(), Sc2Api.ActionError.Builder::clearResult).build())) .withMessage("action result is required"); } |
### Question:
ActionRawCameraMove implements Sc2ApiSerializable<Raw.ActionRawCameraMove> { public static ActionRawCameraMove from(Raw.ActionRawCameraMove sc2ApiActionRawCameraMove) { require("sc2api action raw camera move", sc2ApiActionRawCameraMove); return new ActionRawCameraMove(sc2ApiActionRawCameraMove); } private ActionRawCameraMove(Builder builder); private ActionRawCameraMove(Raw.ActionRawCameraMove sc2ApiActionRawCameraMove); static ActionRawCameraMoveSyntax cameraMove(); static ActionRawCameraMove from(Raw.ActionRawCameraMove sc2ApiActionRawCameraMove); @Override Raw.ActionRawCameraMove toSc2Api(); Point getCenterInWorldSpace(); @Override boolean equals(Object o); @Override int hashCode(); @Override String toString(); }### Answer:
@Test void throwsExceptionWhenSc2ApiActionRawCameraMoveIsNull() { assertThatExceptionOfType(IllegalArgumentException.class) .isThrownBy(() -> ActionRawCameraMove.from(nothing())) .withMessage("sc2api action raw camera move is required"); }
@Test void convertsSc2ApiActionRawCameraMoveToActionRawCameraMove() { assertThatAllFieldsAreConverted(ActionRawCameraMove.from(sc2ApiActionRawCameraMove())); } |
### Question:
ActionRaw implements Sc2ApiSerializable<Raw.ActionRaw>, GeneralizableAbility<ActionRaw> { public static ActionRaw from(Raw.ActionRaw sc2ApiActionRaw) { require("sc2api action raw", sc2ApiActionRaw); return new ActionRaw(sc2ApiActionRaw); } private ActionRaw(Raw.ActionRaw sc2ApiActionRaw); private ActionRaw(ActionRawUnitCommand unitCommand); private ActionRaw(ActionRawCameraMove cameraMove); private ActionRaw(ActionRawToggleAutocast toggleAutocast); static ActionRaw from(Raw.ActionRaw sc2ApiActionRaw); static ActionRaw of(ActionRawUnitCommand unitCommand); static ActionRaw of(ActionRawCameraMove cameraMove); static ActionRaw of(ActionRawToggleAutocast toggleAutocast); @Override Raw.ActionRaw toSc2Api(); Optional<ActionRawUnitCommand> getUnitCommand(); Optional<ActionRawCameraMove> getCameraMove(); Optional<ActionRawToggleAutocast> getToggleAutocast(); @Override ActionRaw generalizeAbility(UnaryOperator<Ability> generalize); @Override boolean equals(Object o); @Override int hashCode(); @Override String toString(); }### Answer:
@Test void throwsExceptionWhenSc2ApiActionRawIsNull() { assertThatExceptionOfType(IllegalArgumentException.class) .isThrownBy(() -> ActionRaw.from(nothing())) .withMessage("sc2api action raw is required"); } |
### Question:
ActionRaw implements Sc2ApiSerializable<Raw.ActionRaw>, GeneralizableAbility<ActionRaw> { @Override public Raw.ActionRaw toSc2Api() { Raw.ActionRaw.Builder aSc2ApiActionRaw = Raw.ActionRaw.newBuilder(); getUnitCommand().map(ActionRawUnitCommand::toSc2Api).ifPresent(aSc2ApiActionRaw::setUnitCommand); getCameraMove().map(ActionRawCameraMove::toSc2Api).ifPresent(aSc2ApiActionRaw::setCameraMove); getToggleAutocast().map(ActionRawToggleAutocast::toSc2Api).ifPresent(aSc2ApiActionRaw::setToggleAutocast); return aSc2ApiActionRaw.build(); } private ActionRaw(Raw.ActionRaw sc2ApiActionRaw); private ActionRaw(ActionRawUnitCommand unitCommand); private ActionRaw(ActionRawCameraMove cameraMove); private ActionRaw(ActionRawToggleAutocast toggleAutocast); static ActionRaw from(Raw.ActionRaw sc2ApiActionRaw); static ActionRaw of(ActionRawUnitCommand unitCommand); static ActionRaw of(ActionRawCameraMove cameraMove); static ActionRaw of(ActionRawToggleAutocast toggleAutocast); @Override Raw.ActionRaw toSc2Api(); Optional<ActionRawUnitCommand> getUnitCommand(); Optional<ActionRawCameraMove> getCameraMove(); Optional<ActionRawToggleAutocast> getToggleAutocast(); @Override ActionRaw generalizeAbility(UnaryOperator<Ability> generalize); @Override boolean equals(Object o); @Override int hashCode(); @Override String toString(); }### Answer:
@Test void serializesToSc2ApiActionRawWithToggleAutocast() { Raw.ActionRaw sc2ApiActionRaw = actionRawWithToggleAutocast().toSc2Api(); assertThat(sc2ApiActionRaw.hasToggleAutocast()).as("sc2api action raw: case of action is toggle autocast") .isTrue(); assertThat(sc2ApiActionRaw.hasCameraMove()).as("sc2api action raw: case of action is camera move").isFalse(); assertThat(sc2ApiActionRaw.hasUnitCommand()).as("sc2api action raw: case of action is unit command").isFalse(); }
@Test void serializesToSc2ApiActionRawWithUnitCommand() { Raw.ActionRaw sc2ApiActionRaw = actionRawWithUnitCommand().toSc2Api(); assertThat(sc2ApiActionRaw.hasToggleAutocast()).as("sc2api action raw: case of action is toggle autocast") .isFalse(); assertThat(sc2ApiActionRaw.hasCameraMove()).as("sc2api action raw: case of action is camera move").isFalse(); assertThat(sc2ApiActionRaw.hasUnitCommand()).as("sc2api action raw: case of action is unit command").isTrue(); }
@Test void serializesToSc2ApiActionRawWithCameraMove() { Raw.ActionRaw sc2ApiActionRaw = actionRawWithCameraMove().toSc2Api(); assertThat(sc2ApiActionRaw.hasToggleAutocast()).as("sc2api action raw: case of action is toggle autocast") .isFalse(); assertThat(sc2ApiActionRaw.hasCameraMove()).as("sc2api action raw: case of action is camera move").isTrue(); assertThat(sc2ApiActionRaw.hasUnitCommand()).as("sc2api action raw: case of action is unit command").isFalse(); } |
### Question:
ActionRaw implements Sc2ApiSerializable<Raw.ActionRaw>, GeneralizableAbility<ActionRaw> { @Override public ActionRaw generalizeAbility(UnaryOperator<Ability> generalize) { Optional<ActionRawUnitCommand> commandUnit = getUnitCommand(); Optional<ActionRawCameraMove> commandCamera = getCameraMove(); Optional<ActionRawToggleAutocast> commandAutocast = getToggleAutocast(); if (commandUnit.isPresent()) { return ActionRaw.of(commandUnit.get().generalizeAbility(generalize)); } if (commandCamera.isPresent()) { return this; } if (commandAutocast.isPresent()) { return ActionRaw.of(commandAutocast.get().generalizeAbility(generalize)); } throw new AssertionError("Invalid state: one of action case must be set."); } private ActionRaw(Raw.ActionRaw sc2ApiActionRaw); private ActionRaw(ActionRawUnitCommand unitCommand); private ActionRaw(ActionRawCameraMove cameraMove); private ActionRaw(ActionRawToggleAutocast toggleAutocast); static ActionRaw from(Raw.ActionRaw sc2ApiActionRaw); static ActionRaw of(ActionRawUnitCommand unitCommand); static ActionRaw of(ActionRawCameraMove cameraMove); static ActionRaw of(ActionRawToggleAutocast toggleAutocast); @Override Raw.ActionRaw toSc2Api(); Optional<ActionRawUnitCommand> getUnitCommand(); Optional<ActionRawCameraMove> getCameraMove(); Optional<ActionRawToggleAutocast> getToggleAutocast(); @Override ActionRaw generalizeAbility(UnaryOperator<Ability> generalize); @Override boolean equals(Object o); @Override int hashCode(); @Override String toString(); }### Answer:
@Test void createsCopyWithGeneralizedAbility() { ActionRaw actionRawWithCameraMove = actionRawWithCameraMove(); ActionRaw actionRawWithToggleAutocast = actionRawWithToggleAutocast(); ActionRaw actionRawWithUnitCommand = actionRawWithUnitCommand(); UnaryOperator<Ability> generalize = ability -> Abilities.ATTACK_REDIRECT; assertThat(actionRawWithCameraMove.generalizeAbility(generalize)).isSameAs(actionRawWithCameraMove); assertThat(actionRawWithToggleAutocast.generalizeAbility(generalize)).isNotEqualTo(actionRawWithToggleAutocast); assertThat(actionRawWithUnitCommand.generalizeAbility(generalize)).isNotEqualTo(actionRawWithUnitCommand); } |
### Question:
ActionRawUnitCommand implements Sc2ApiSerializable<Raw.ActionRawUnitCommand>, GeneralizableAbility<ActionRawUnitCommand> { public static ActionRawUnitCommand from(Raw.ActionRawUnitCommand sc2ApiActionRawUnitCommand) { require("sc2api action raw unit command", sc2ApiActionRawUnitCommand); return new ActionRawUnitCommand(sc2ApiActionRawUnitCommand); } private ActionRawUnitCommand(Builder builder); private ActionRawUnitCommand(Raw.ActionRawUnitCommand sc2ApiActionRawUnitCommand); static ActionRawUnitCommandSyntax unitCommand(); static ActionRawUnitCommand from(Raw.ActionRawUnitCommand sc2ApiActionRawUnitCommand); @Override Raw.ActionRawUnitCommand toSc2Api(); Ability getAbility(); Optional<Tag> getTargetedUnitTag(); Optional<Point2d> getTargetedWorldSpacePosition(); Set<Tag> getUnitTags(); boolean isQueued(); @Override ActionRawUnitCommand generalizeAbility(UnaryOperator<Ability> generalize); @Override boolean equals(Object o); @Override int hashCode(); @Override String toString(); }### Answer:
@Test void throwsExceptionWhenSc2ApiActionRawUnitCommandIsNull() { assertThatExceptionOfType(IllegalArgumentException.class) .isThrownBy(() -> ActionRawUnitCommand.from(nothing())) .withMessage("sc2api action raw unit command is required"); }
@Test void convertsSc2ApiActionRawUnitCommandToActionRawUnitCommand() { assertThatAllFieldsAreConverted(ActionRawUnitCommand.from(sc2ApiActionRawUnitCommand())); }
@Test void throwsExceptionWhenAbilityIdIsNotProvided() { assertThatExceptionOfType(IllegalArgumentException.class) .isThrownBy(() -> ActionRawUnitCommand.from(sc2ApiActionRawUnitCommandWithoutAbilityId())) .withMessage("ability id is required"); assertThatExceptionOfType(IllegalArgumentException.class) .isThrownBy(() -> unitCommandBuilder().build()) .withMessage("ability id is required"); }
@Test void throwsExceptionIfUnitTagSetIsEmpty() { assertThatExceptionOfType(IllegalArgumentException.class) .isThrownBy(() -> ActionRawUnitCommand.from(without( () -> sc2ApiActionRawUnitCommand().toBuilder(), Raw.ActionRawUnitCommand.Builder::clearUnitTags).build())) .withMessage("unit tag list is required"); assertThatExceptionOfType(IllegalArgumentException.class) .isThrownBy(() -> unitCommandBuilder().useAbility(Abilities.ATTACK).build()) .withMessage("unit tag list is required"); }
@Test void serializesOnlyRecentlyAddedTarget() { assertCorrectTarget(fullAccessTo(defaultUnitCommand().target(Tag.from(UNIT_TAG))) .target(Point2d.of(10, 20)).build()); assertCorrectTargetAfterOrderChange(fullAccessTo(defaultUnitCommand().target(Point2d.of(10, 20))) .target(Tag.from(UNIT_TAG)).build()); } |
### Question:
ActionRawUnitCommand implements Sc2ApiSerializable<Raw.ActionRawUnitCommand>, GeneralizableAbility<ActionRawUnitCommand> { @Override public Raw.ActionRawUnitCommand toSc2Api() { Raw.ActionRawUnitCommand.Builder aSc2ApiUnitCommand = Raw.ActionRawUnitCommand.newBuilder() .setAbilityId(ability.toSc2Api()) .addAllUnitTags(unitTags.stream().map(Tag::toSc2Api).collect(toSet())) .setQueueCommand(queued); getTargetedUnitTag().map(Tag::toSc2Api).ifPresent(aSc2ApiUnitCommand::setTargetUnitTag); getTargetedWorldSpacePosition().map(Point2d::toSc2Api).ifPresent(aSc2ApiUnitCommand::setTargetWorldSpacePos); return aSc2ApiUnitCommand.build(); } private ActionRawUnitCommand(Builder builder); private ActionRawUnitCommand(Raw.ActionRawUnitCommand sc2ApiActionRawUnitCommand); static ActionRawUnitCommandSyntax unitCommand(); static ActionRawUnitCommand from(Raw.ActionRawUnitCommand sc2ApiActionRawUnitCommand); @Override Raw.ActionRawUnitCommand toSc2Api(); Ability getAbility(); Optional<Tag> getTargetedUnitTag(); Optional<Point2d> getTargetedWorldSpacePosition(); Set<Tag> getUnitTags(); boolean isQueued(); @Override ActionRawUnitCommand generalizeAbility(UnaryOperator<Ability> generalize); @Override boolean equals(Object o); @Override int hashCode(); @Override String toString(); }### Answer:
@Test void serializedDefaultValueForQueuedFieldIsNotProvided() { assertThat(defaultUnitCommand().build().toSc2Api().getQueueCommand()) .as("sc2api action raw unit command: default queued value").isFalse(); } |
### Question:
ActionRawToggleAutocast implements Sc2ApiSerializable<Raw.ActionRawToggleAutocast>, GeneralizableAbility<ActionRawToggleAutocast> { public static ActionRawToggleAutocast from(Raw.ActionRawToggleAutocast sc2ApiActionRawToggleAutocast) { require("sc2api action raw toggle autocast", sc2ApiActionRawToggleAutocast); return new ActionRawToggleAutocast(sc2ApiActionRawToggleAutocast); } private ActionRawToggleAutocast(Builder builder); private ActionRawToggleAutocast(Raw.ActionRawToggleAutocast sc2ApiActionRawToggleAutocast); static ActionRawToggleAutocastSyntax toggleAutocast(); static ActionRawToggleAutocast from(Raw.ActionRawToggleAutocast sc2ApiActionRawToggleAutocast); @Override Raw.ActionRawToggleAutocast toSc2Api(); Ability getAbility(); Set<Tag> getUnitTags(); @Override ActionRawToggleAutocast generalizeAbility(UnaryOperator<Ability> generalize); @Override boolean equals(Object o); @Override int hashCode(); @Override String toString(); }### Answer:
@Test void throwsExceptionWhenSc2ApiActionRawToggleAutocastIsNull() { assertThatExceptionOfType(IllegalArgumentException.class) .isThrownBy(() -> ActionRawToggleAutocast.from(nothing())) .withMessage("sc2api action raw toggle autocast is required"); }
@Test void convertsSc2ApiActionRawToggleAutocastToActionRawToggleAutocast() { assertThatAllFieldsAreConverted(ActionRawToggleAutocast.from(sc2ApiActionRawToggleAutocast())); } |
### Question:
Action implements Sc2ApiSerializable<Sc2Api.Action> { public static Action from(Sc2Api.Action sc2ApiAction) { require("sc2api action", sc2ApiAction); return new Action(sc2ApiAction); } private Action(Builder builder); private Action(Sc2Api.Action sc2ApiAction); static ActionSyntax action(); static Action from(Sc2Api.Action sc2ApiAction); @Override Sc2Api.Action toSc2Api(); Optional<ActionRaw> getRaw(); Optional<ActionSpatial> getFeatureLayer(); Optional<ActionSpatial> getRender(); Optional<ActionUi> getUi(); Optional<ActionChat> getChat(); Optional<Integer> getGameLoop(); @Override boolean equals(Object o); @Override int hashCode(); @Override String toString(); }### Answer:
@Test void throwsExceptionWhenSc2ApiActionIsNull() { assertThatExceptionOfType(IllegalArgumentException.class) .isThrownBy(() -> Action.from(nothing())) .withMessage("sc2api action is required"); }
@Test void convertsAllFieldsFromSc2ApiAction() { assertThatAllFieldsAreConverted(Action.from(sc2ApiAction())); } |
### Question:
RequestQuery extends Request { public static RequestQuerySyntax query() { return new Builder(); } private RequestQuery(Builder builder); static RequestQuerySyntax query(); @Override Sc2Api.Request toSc2Api(); @Override ResponseType responseType(); List<QueryPathing> getPathings(); List<QueryAvailableAbilities> getAbilities(); List<QueryBuildingPlacement> getPlacements(); boolean isIgnoreResourceRequirements(); @Override boolean equals(Object o); @Override int hashCode(); @Override String toString(); }### Answer:
@Test void throwsExceptionWhenQueriesAreEmpty() { assertThatExceptionOfType(IllegalArgumentException.class) .isThrownBy(() -> ((RequestQuery.Builder) query()).build()) .withMessage("one of query is required"); } |
### Question:
RequestReplayInfo extends Request { public static RequestReplayInfoSyntax replayInfo() { return new Builder(); } private RequestReplayInfo(Builder builder); static RequestReplayInfoSyntax replayInfo(); @Override Sc2Api.Request toSc2Api(); @Override ResponseType responseType(); Optional<Path> getReplayPath(); Optional<byte[]> getReplayDataInBytes(); boolean isDownloadData(); @Override boolean equals(Object o); @Override int hashCode(); @Override String toString(); }### Answer:
@Test void throwsExceptionWhenReplayCaseIsNull() { assertThatExceptionOfType(IllegalArgumentException.class) .isThrownBy(() -> fullAccessTo(replayInfo()).build()) .withMessage("replay case is required"); } |
### Question:
RequestData extends Request { @Override public Sc2Api.Request toSc2Api() { return Sc2Api.Request.newBuilder() .setData(Sc2Api.RequestData.newBuilder() .setAbilityId(ability) .setBuffId(buff) .setEffectId(effect) .setUnitTypeId(unitType) .setUpgradeId(upgrade) .build()) .build(); } private RequestData(Builder builder); static RequestDataSyntax data(); @Override Sc2Api.Request toSc2Api(); @Override ResponseType responseType(); boolean isAbility(); boolean isUnitType(); boolean isUpgrade(); boolean isBuff(); boolean isEffect(); @Override boolean equals(Object o); @Override int hashCode(); @Override String toString(); }### Answer:
@Test void serializesDefaultAbilityValueIfNotSet() { Sc2Api.RequestData aSc2ApiRequestData = defaultRequestData().toSc2Api().getData(); assertThat(aSc2ApiRequestData.hasAbilityId()).as("data: ability value is set").isTrue(); assertThat(aSc2ApiRequestData.getAbilityId()).as("data: default ability value").isFalse(); }
@Test void serializesDefaultBuffValueIfNotSet() { Sc2Api.RequestData aSc2ApiRequestData = defaultRequestData().toSc2Api().getData(); assertThat(aSc2ApiRequestData.hasBuffId()).as("data: buff value is set").isTrue(); assertThat(aSc2ApiRequestData.getBuffId()).as("data: default buff value").isFalse(); }
@Test void serializesDefaultEffectValueIfNotSet() { Sc2Api.RequestData aSc2ApiRequestData = defaultRequestData().toSc2Api().getData(); assertThat(aSc2ApiRequestData.hasEffectId()).as("data: effect value is set").isTrue(); assertThat(aSc2ApiRequestData.getEffectId()).as("data: default effect value").isFalse(); }
@Test void serializesDefaultUnitTypeValueIfNotSet() { Sc2Api.RequestData aSc2ApiRequestData = defaultRequestData().toSc2Api().getData(); assertThat(aSc2ApiRequestData.hasUnitTypeId()).as("data: unit type value is set").isTrue(); assertThat(aSc2ApiRequestData.getUnitTypeId()).as("data: default unit type value").isFalse(); }
@Test void serializesDefaultUpgradeValueIfNotSet() { Sc2Api.RequestData aSc2ApiRequestData = defaultRequestData().toSc2Api().getData(); assertThat(aSc2ApiRequestData.hasUpgradeId()).as("data: upgrade value is set").isTrue(); assertThat(aSc2ApiRequestData.getUpgradeId()).as("data: default upgrade value").isFalse(); } |
### Question:
RequestJoinGame extends Request { public static RequestJoinGameSyntax joinGame() { return new Builder(); } private RequestJoinGame(Builder builder); static RequestJoinGameSyntax joinGame(); @Override Sc2Api.Request toSc2Api(); @Override ResponseType responseType(); Optional<Race> getRace(); Optional<Observer> getObserverOf(); InterfaceOptions getInterfaceOptions(); Optional<MultiplayerOptions> getMultiplayerOptions(); Optional<String> getPlayerName(); @Override boolean equals(Object o); @Override int hashCode(); @Override String toString(); }### Answer:
@Test void throwsExceptionWhenParticipantCaseIsNotSet() { assertThatExceptionOfType(IllegalArgumentException.class) .isThrownBy(() -> fullAccessTo(joinGame()).build()) .withMessage("participant case is required"); }
@Test void throwsExceptionIfInterfaceOptionsAreNotSet() { assertThatExceptionOfType(IllegalArgumentException.class) .isThrownBy(() -> joinGame().as(Race.RANDOM).use((InterfaceOptions) nothing()).build()) .withMessage("interface options are required"); } |
### Question:
RequestObserverAction extends Request { public static RequestObserverActionSyntax observerActions() { return new Builder(); } private RequestObserverAction(Builder builder); static RequestObserverActionSyntax observerActions(); @Override Sc2Api.Request toSc2Api(); @Override ResponseType responseType(); List<ObserverAction> getActions(); @Override boolean equals(Object o); @Override int hashCode(); @Override String toString(); }### Answer:
@Test void throwsExceptionWhenObserverActionListIsEmpty() { assertThatExceptionOfType(IllegalArgumentException.class) .isThrownBy(() -> ((RequestObserverAction.Builder) observerActions()).build()) .withMessage("action list is required"); } |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.