Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
19 commits
Select commit Hold shift + click to select a range
0802796
Added 'monster-count' as an option for attribute linking
Hanziness Apr 11, 2018
21ccfad
Added example mapping file that maps major warnings to monster-count
Hanziness Apr 11, 2018
50366b4
Monster-count in mapping example now has 5 levels
Hanziness Apr 15, 2018
e6e9e76
Spawner class added
bkarola Apr 15, 2018
5e98d4a
Spawners added to Garden
bkarola Apr 15, 2018
c12513c
Number of spawners by monster-count
bkarola Apr 15, 2018
cf5f96f
Added unit test cases for the converter's ConverterLoader class
Hanziness Apr 20, 2018
9c92cc1
Added unit tests for the ConverterExecutorArgs constructor in the con…
Hanziness Apr 20, 2018
3d74fbb
Added unit tests for the MappingExecutorArgs class in the mapping tool
Hanziness Apr 20, 2018
036aa37
Swapped arguments to match JUnit 'expected' and 'actual' parameters i…
Hanziness Apr 20, 2018
1a8b78e
Unit tests added for Conversion and NormalizeConversion classes in th…
Hanziness Apr 20, 2018
7a02c37
Unit tests added for Buildable, Point and Time classes in the commons…
Hanziness Apr 20, 2018
ca04999
Added a monster-label attribute to mapping to be used as the signpost…
Hanziness Apr 20, 2018
8848525
Signpost added for the monster spawners
ggmarkk Apr 20, 2018
6f99130
Unit tests added for Time class in the commons toolchain element, and…
ggmarkk Apr 21, 2018
a045674
Unit tests added for Layout class in the placing toolchain element, a…
ggmarkk Apr 21, 2018
3a759f0
Unit tests for mapping and rendering
bkarola Apr 21, 2018
0c3c6be
Unit tests for SonarMetric class
bkarola Apr 21, 2018
f3cce32
Unit tests for MappingController and PackLayout
bkarola Apr 21, 2018
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
84 changes: 84 additions & 0 deletions examples/mapping/sourcemeter_mapping_example_2_0_monsters.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
<mapping version="2.0">
<resources>
<constant id="cellar_character" value="planks"/>
<constant id="cellar_external_character" value="wood"/>
</resources>
<linking source="package" target="ground"/>
<linking source="class" target="garden">
<binding from="CBO" to="flower-ratio">
<conversions>
<conversion type="normalize"/>
</conversions>
</binding>
<binding from="WarningMajor" to="monster-count">
<conversions>
<conversion type="quantization">
<parameter name="level0" value="0" />
<parameter name="level1" value="1" />
<parameter name="level2" value="2" />
<parameter name="level3" value="3" />
<parameter name="level4" value="4" />
</conversion>
</conversions>
</binding>
<binding from="WarningMajor" to="monster-label">
<conversions>
<conversion type="quantization">
<parameter name="level0" value="No errors" />
<parameter name="level1" value="Few major warnings" />
<parameter name="level2" value="More major warnings" />
<parameter name="level3" value="Lots of major warnings" />
<parameter name="level4" value="A large number of major warnings" />
</conversion>
</conversions>
</binding>
</linking>
<linking source="method" target="floor">
<binding from="LLOC" to="height"/>
<binding from="NII" to="width"/>
<binding from="NOI" to="length"/>
<binding from="McCC" to="character">
<conversions>
<conversion type="quantization">
<parameter name="level0" value="glass"/>
<parameter name="level1" value="sand"/>
<parameter name="level2" value="planks"/>
<parameter name="level3" value="stone"/>
<parameter name="level4" value="obsidian"/>
</conversion>
</conversions>
</binding>
<binding from="McCC" to="external_character">
<conversions>
<conversion type="quantization">
<parameter name="level0" value="metal"/>
<parameter name="level1" value="sandstone"/>
<parameter name="level2" value="wood"/>
<parameter name="level3" value="cobblestone"/>
<parameter name="level4" value="obsidian"/>
</conversion>
</conversions>
</binding>
<binding from="NUMPAR" to="torches">
<conversions>
<conversion type="quantization">
<parameter name="level0" value="1"/>
<parameter name="level1" value="2"/>
<parameter name="level2" value="3"/>
</conversion>
</conversions>
</binding>
</linking>
<linking source="attribute" target="cellar">
<binding from="WarningP0" to="torches">
<conversions>
<conversion type="quantization">
<parameter name="level0" value="1"/>
<parameter name="level1" value="2"/>
</conversion>
</conversions>
</binding>
<binding from="${cellar_character}" to="character"/>
<binding from="${cellar_external_character}" to="external_character"/>
</linking>
</mapping>
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
package codemetropolis.toolchain.commons.cmxml;

import codemetropolis.toolchain.commons.cmxml.Buildable.Type;
import junit.framework.TestCase;

public class BuildableTest extends TestCase {

Buildable b1, b2, b3;

public void setup() {
b1 = null;
b2 = null;
b3 = null;
}

public void testIsOverlapping() {
b1 = new Buildable("test1", "testBuilding1", Type.FLOOR, new Point(0, 0, 0), new Point(2, 2, 2));
b2 = new Buildable("test2", "testBuilding2", Type.FLOOR, new Point(1, 1, 1), new Point(2, 2, 2));
b3 = new Buildable("test3", "testBuilding3", Type.FLOOR, new Point(-1, -1, -1), new Point(2, 2, 2));

assertTrue(b1.isOverlapping(b2));
assertTrue(b3.isOverlapping(b1));
assertFalse(b2.isOverlapping(b3));
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
package codemetropolis.toolchain.commons.cmxml;

import junit.framework.TestCase;

public class PointTest extends TestCase {

Point testObj;

public void setup() {
testObj = null;
}

public void testTranslate() {
testObj = new Point(0, 0, 0);

Point newPoint = testObj.translate(new Point(1, 2, 3));

assertEquals(1, newPoint.getX());
assertEquals(2, newPoint.getY());
assertEquals(3, newPoint.getZ());
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
package codemetropolis.toolchain.commons.util;

import junit.framework.TestCase;

public class TimeTest extends TestCase {

Time testObj;

public void setup() {
testObj = null;
}

public void testGetHours() {
testObj = new Time(0);
assertEquals(0, testObj.getHours());

testObj = new Time(3599999); // 0 hrs 59 mins 59 seconds, 999 milliseconds
assertEquals(0, testObj.getHours());

testObj = new Time(86400001); // 24 hrs 1 milliseconds
assertEquals(24, testObj.getHours());
}

public void testGetMinutes() {
testObj = new Time(0);
assertEquals(0, testObj.getMinutes());

testObj = new Time(6999);
assertEquals(0, testObj.getMinutes());

testObj = new Time(59999);
assertEquals(0, testObj.getMinutes());

testObj = new Time(60000);
assertEquals(1, testObj.getMinutes());

testObj = new Time(3600000);
assertEquals(0, testObj.getMinutes());

testObj = new Time(3730000);
assertEquals(2, testObj.getMinutes());
}

public void testGetSeconds() {
testObj = new Time(0);
assertEquals(0, testObj.getSeconds());

testObj = new Time(3999);
assertEquals(3, testObj.getSeconds());

testObj = new Time(60000);
assertEquals(0, testObj.getSeconds());

testObj = new Time(74500);
assertEquals(14, testObj.getSeconds());
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
package codemetropolis.toolchain.converter;

import java.util.HashMap;

import codemetropolis.toolchain.converter.control.ConverterType;
import junit.framework.TestCase;

public class ConverterExecutorArgsTest extends TestCase {
ConverterExecutorArgs testObj;

public void setup () {
testObj = null;
}

public void testConverterExecutorArgsConstructorNoParams() {
testObj = new ConverterExecutorArgs(ConverterType.SOURCEMETER, "testSource", "testOutput");
assertEquals("testOutput", testObj.getOutputFile());
assertEquals("testSource", testObj.getSource());
assertEquals(ConverterType.SOURCEMETER, testObj.getType());
}

public void testConverterExecutorArgsConstructor() {
testObj = new ConverterExecutorArgs(ConverterType.SONARQUBE, "testSource", "testOutput", new HashMap<String, String>());
assertEquals("testOutput", testObj.getOutputFile());
assertEquals("testSource", testObj.getSource());
assertEquals(ConverterType.SONARQUBE, testObj.getType());
assertNotNull(testObj.getParams());
assertTrue(testObj.getParams().isEmpty());
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
package codemetropolis.toolchain.converter.control;

import java.util.HashMap;
import java.util.Map;

import codemetropolis.toolchain.commons.cdf.converter.CdfConverter;
import codemetropolis.toolchain.converter.control.*;
import codemetropolis.toolchain.converter.sonarqube.SonarQubeConverter;
import codemetropolis.toolchain.converter.sourcemeter.GraphConverter;
import junit.framework.TestCase;

public class ConverterLoaderTest extends TestCase {

CdfConverter result;


public void setup() {
result = null;
}

public void testLoadSourceMeter() {
result = ConverterLoader.load(ConverterType.SOURCEMETER, new HashMap<String, String>());
assert(result instanceof GraphConverter);
}

public void testLoadSonarQube() {
result = ConverterLoader.load(ConverterType.SONARQUBE, new HashMap<String, String>());
assert(result instanceof SonarQubeConverter);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
package codemetropolis.toolchain.converter.sonarqube;

import codemetropolis.toolchain.converter.sonarqube.SonarMetric.MetricType;
import junit.framework.TestCase;

public class SonarMetricTest extends TestCase {

SonarMetric testObj;


public void setup() {
testObj = null;
}

public void testHashCode() {

testObj = new SonarMetric(null, null, null);
assertEquals(29791, testObj.hashCode());

testObj = new SonarMetric("name1", "value1", null);
int value = ((31+"name1".hashCode())*31)*31+"value1".hashCode();
assertEquals(value, testObj.hashCode());
}

public void testEquals() {
testObj = new SonarMetric("name1", "value1", MetricType.STRING);

assertEquals(true, testObj.equals(testObj));
assertEquals(true, testObj.equals(new SonarMetric("name1", "value1", MetricType.STRING)));
assertEquals(false, testObj.equals(null));
assertEquals(false, testObj.equals(3));
assertEquals(false, testObj.equals(new SonarMetric(null, null, null)));
assertEquals(false, testObj.equals(new SonarMetric("name1", "value1", null)));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ public class Linking {
static {
SUPPORTED_TARGETS.put(Type.FLOOR, new String[]{"width", "height", "length", "character", "external_character", "torches"});
SUPPORTED_TARGETS.put(Type.CELLAR, new String[]{"width", "height", "length", "character", "external_character", "torches"});
SUPPORTED_TARGETS.put(Type.GARDEN, new String[]{"tree-ratio", "mushroom-ratio", "flower-ratio"});
SUPPORTED_TARGETS.put(Type.GARDEN, new String[]{"tree-ratio", "mushroom-ratio", "flower-ratio", "monster-count", "monster-label"});
SUPPORTED_TARGETS.put(Type.GROUND, new String[]{});
}

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
package codemetropolis.toolchain.mapping;

import junit.framework.TestCase;

public class MappingExecutorArgsTest extends TestCase {

MappingExecutorArgs testObj;

public void setup() {
testObj = null;
}

public void testMappingExecutorArgs() {
testObj = new MappingExecutorArgs("testCDF", "testOutput", "testMapping", 1.0, true);
assertEquals("testCDF", testObj.getCdfFile());
assertEquals("testOutput", testObj.getOutputFile());
assertEquals("testMapping", testObj.getMappingFile());
assertEquals(1.0, testObj.getScale());
assertEquals(true, testObj.isHierarchyValidationEnabled());
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
package codemetropolis.toolchain.mapping.control;

import junit.framework.TestCase;

public class LimitControllerTest extends TestCase {

LimitController testObj;

public void setup() {
testObj = null;
}

public void testAdd() {
testObj = new LimitController();

testObj.add("name", "from", 2.0);

assertNotNull(testObj.getLimit("name", "from"));
assertEquals(1, testObj.getLimit("name", "from").getValueSetSize());
}

}
Loading