src_fm_fc_ms_ff stringlengths 43 86.8k | target stringlengths 20 276k |
|---|---|
CompositeParameters extends AbstractParameterParser { @Nonnull public CompositeParameters add (final String sKey, final AbstractParameterParser aParam) { getParameterParsers ().put (sKey, aParam); return this; } CompositeParameters(final boolean bIgnoreMissingParsers); CompositeParameters(final boolean bIgnoreMissingP... | @Test public void testBasic () throws AS2InvalidParameterException { final AS2Message aMsg = new AS2Message (); aMsg.headers ().addHeader ("message-id", "12345"); aMsg.partnership ().setSenderAS2ID ("s1"); aMsg.partnership ().setReceiverAS2ID ("r1"); final ZonedDateTime aTestDT = PDTFactory.getCurrentZonedDateTime (); ... |
MongoDBPartnershipFactory extends AbstractDynamicComponent implements IPartnershipFactory { @Override public EChange addPartnership (final Partnership aPartnership) throws AS2Exception { m_aPartnerships.insertOne (_toDocument (aPartnership)); return EChange.CHANGED; } MongoDBPartnershipFactory(final MongoCollection <Do... | @Test public void testAddPartnership () throws AS2Exception { final Partnership partnership = new Partnership ("Test partnership"); assertTrue (mongoDBPartnershipFactory.addPartnership (partnership).isChanged ()); assertEquals (1, collection.countDocuments ()); assertNotNull (mongoDBPartnershipFactory.getPartnershipByN... |
DiscreteAnneal { public String getStatus() { final StringBuilder result = new StringBuilder(); result.append("k="); result.append(this.k); result.append(",kMax="); result.append(this.kMax); result.append(",t="); result.append(this.currentTemperature); result.append(",prob="); result.append(this.lastProbability); return... | @Test public void testStatus() { final DiscreteAnnealSubclass anneal = new DiscreteAnnealSubclass(1000, 4000, 1); assertEquals("k=0,kMax=1000,t=0.0,prob=0.0", anneal.getStatus()); } |
KMeans { public void initForgy(final List<BasicData> theObservations) { final int dimensions = findDimensions(theObservations); this.clusters.clear(); final Set<Integer> usedObservations = new HashSet<Integer>(); for (int i = 0; i < this.k; i++) { final Cluster cluster = new Cluster(dimensions); this.clusters.add(clust... | @Test(expected = AIFHError.class) public void testNoObservations() { final List<BasicData> list = new ArrayList<BasicData>(); final KMeans kmeans = new KMeans(3); kmeans.initForgy(list); }
@Test(expected = AIFHError.class) public void testNoDimension() { final List<BasicData> list = new ArrayList<BasicData>(); list.add... |
BasicData { public String toString() { final StringBuilder result = new StringBuilder(); result.append("[BasicData: input:"); result.append(Arrays.toString(this.input)); result.append(", ideal:"); result.append(Arrays.toString(this.ideal)); result.append(", label:"); result.append(this.label); result.append("]"); retur... | @Test public void testToString() { final BasicData data = new BasicData(2); assertEquals("[BasicData: input:[0.0, 0.0], ideal:[], label:null]", data.toString()); } |
VectorUtil { public static int maxIndex(final double[] a) { int result = -1; double max = Double.NEGATIVE_INFINITY; for (int i = 0; i < a.length; i++) { if (a[i] > max) { max = a[i]; result = i; } } return result; } private VectorUtil(); static int maxIndex(final double[] a); } | @Test public void testMaxIndex() { final double[] a = {2, 4, 10, 8}; assertEquals(2, VectorUtil.maxIndex(a), AIFH.DEFAULT_PRECISION); } |
LogLinkFunction implements Fn { @Override public double evaluate(final double[] x) { if (x.length > 1) { throw new AIFHError("The logistic link function can only accept one parameter."); } return Math.log(x[0]); } @Override double evaluate(final double[] x); } | @Test public void testEvaluate() { final LogLinkFunction fn = new LogLinkFunction(); final double[] x = {2}; final double y = fn.evaluate(x); assertEquals(0.6931471805599453, y, AIFH.DEFAULT_PRECISION); }
@Test(expected = AIFHError.class) public void testException() { final LogLinkFunction fn = new LogLinkFunction(); f... |
IdentityLinkFunction implements Fn { @Override public double evaluate(final double[] x) { if (x.length > 1) { throw new AIFHError("The linear link function can only accept one parameter."); } return x[0]; } @Override double evaluate(final double[] x); } | @Test public void testEvaluate() { final IdentityLinkFunction fn = new IdentityLinkFunction(); final double[] x = {2}; final double y = fn.evaluate(x); assertEquals(2, y, AIFH.DEFAULT_PRECISION); }
@Test(expected = AIFHError.class) public void testException() { final IdentityLinkFunction fn = new IdentityLinkFunction()... |
InverseLinkFunction implements Fn { @Override public double evaluate(final double[] x) { if (x.length > 1) { throw new AIFHError("The inverse link function can only accept one parameter."); } return -Math.pow(x[0], -1); } @Override double evaluate(final double[] x); } | @Test public void testEvaluate() { final InverseLinkFunction fn = new InverseLinkFunction(); final double[] x = {2}; final double y = fn.evaluate(x); assertEquals(-0.5, y, AIFH.DEFAULT_PRECISION); }
@Test(expected = AIFHError.class) public void testException() { final InverseLinkFunction fn = new InverseLinkFunction();... |
DiscreteAnneal { public double coolingSchedule() { final double ex = (double) k / (double) kMax; return this.startingTemperature * Math.pow(this.endingTemperature / this.startingTemperature, ex); } DiscreteAnneal(final int theKMax, final double theStartingTemperature, final double theEndingTemperature); double coolingS... | @Test public void testCoolingSchedule() { final DiscreteAnnealSubclass anneal = new DiscreteAnnealSubclass(1000, 400, 1); assertEquals(400, anneal.coolingSchedule(), AIFH.DEFAULT_PRECISION); anneal.iteration(); assertEquals(397.61057939346017, anneal.coolingSchedule(), AIFH.DEFAULT_PRECISION); } |
LogitLinkFunction implements Fn { @Override public double evaluate(final double[] x) { if (x.length > 1) { throw new AIFHError("The logistic link function can only accept one parameter."); } return 1.0 / (1.0 + Math.exp(-x[0])); } @Override double evaluate(final double[] x); } | @Test public void testEvaluate() { final LogitLinkFunction fn = new LogitLinkFunction(); final double[] x = {2}; final double y = fn.evaluate(x); assertEquals(0.8807970779778823, y, AIFH.DEFAULT_PRECISION); }
@Test(expected = AIFHError.class) public void testException() { final LogitLinkFunction fn = new LogitLinkFunct... |
InverseSquaredLinkFunction implements Fn { @Override public double evaluate(final double[] x) { if (x.length > 1) { throw new AIFHError("The inverse squared link function can only accept one parameter."); } return -Math.pow(x[0], -2); } @Override double evaluate(final double[] x); } | @Test public void testEvaluate() { final InverseSquaredLinkFunction fn = new InverseSquaredLinkFunction(); final double[] x = {2}; final double y = fn.evaluate(x); assertEquals(-0.25, y, AIFH.DEFAULT_PRECISION); }
@Test(expected = AIFHError.class) public void testException() { final InverseSquaredLinkFunction fn = new ... |
GaussianFunction extends AbstractRBF { @Override public double evaluate(final double[] x) { double value = 0; final double width = getWidth(); for (int i = 0; i < getDimensions(); i++) { final double center = this.getCenter(i); value += Math.pow(x[i] - center, 2) / (2.0 * width * width); } return Math.exp(-value); } Ga... | @Test public void testEvaluate() { final double[] params = {5, 0, 0, 0}; final GaussianFunction funct = new GaussianFunction(3, params, 0); final double[] x = {-1, 0, 1}; final double y = funct.evaluate(x); assertEquals(0.9607894391523232, y, AIFH.DEFAULT_PRECISION); }
@Test public void testToString() { final double[] ... |
MultiquadricFunction extends AbstractRBF { @Override public double evaluate(final double[] x) { double value = 0; final double width = getWidth(); for (int i = 0; i < getDimensions(); i++) { final double center = getCenter(i); value += Math.pow(x[i] - center, 2) + (width * width); } return Math.sqrt(value); } Multiquad... | @Test public void testEvaluate() { final double[] params = {5, 0, 0, 0}; final MultiquadricFunction funct = new MultiquadricFunction(3, params, 0); final double[] x = {-1, 0, 1}; final double y = funct.evaluate(x); assertEquals(8.774964387392123, y, AIFH.DEFAULT_PRECISION); }
@Test public void testToString() { final do... |
InverseMultiquadricFunction extends AbstractRBF { @Override public double evaluate(final double[] x) { double value = 0; final double width = getWidth(); for (int i = 0; i < getDimensions(); i++) { final double center = getCenter(i); value += Math.pow(x[i] - center, 2) + (width * width); } return 1 / Math.sqrt(value); ... | @Test public void testEvaluate() { final double[] params = {5, 0, 0, 0}; final InverseMultiquadricFunction funct = new InverseMultiquadricFunction(3, params, 0); final double[] x = {-1, 0, 1}; final double y = funct.evaluate(x); assertEquals(0.11396057645963795, y, AIFH.DEFAULT_PRECISION); }
@Test public void testToStr... |
ScoreClassificationData implements ScoreFunction { @Override public double calculateScore(final MachineLearningAlgorithm algo) { int incorrectCount = 0; int totalCount = 0; final ClassificationAlgorithm ralgo = (ClassificationAlgorithm) algo; for (final BasicData aTrainingData : this.trainingData) { totalCount++; final... | @Test public void testClassification() { final double[] ACTUAL = {0.0, 1.0, 0.0, 0.0}; final List<BasicData> training = BasicData.convertArrays(TEST_INPUT, TEST_IDEAL); final ScoreClassificationData score = new ScoreClassificationData(training); final SimpleAlgo simple = new SimpleAlgo(ACTUAL); final double s = score.c... |
MexicanHatFunction extends AbstractRBF { @Override public double evaluate(final double[] x) { double norm = 0; for (int i = 0; i < getDimensions(); i++) { final double center = this.getCenter(i); norm += Math.pow(x[i] - center, 2); } return (1 - norm) * Math.exp(-norm / 2); } MexicanHatFunction(final int theDimensions,... | @Test public void testEvaluate() { final double[] params = {5, 0, 0, 0}; final MexicanHatFunction funct = new MexicanHatFunction(3, params, 0); final double[] x = {-1, 0, 1}; final double y = funct.evaluate(x); assertEquals(-0.36787944117144233, y, AIFH.DEFAULT_PRECISION); }
@Test public void testToString() { final dou... |
DataSet { @Override public boolean equals(final Object other) { if (!(other instanceof DataSet)) { return false; } final DataSet otherSet = (DataSet) other; if (getHeaderCount() != otherSet.getHeaderCount()) { return false; } if (size() != otherSet.size()) { return false; } for (int i = 0; i < getHeaderCount(); i++) { ... | @Test public void testEqual() { final DataSet ds1 = generateTestData(); final DataSet ds2 = generateTestData(); assertTrue(ds1.equals(ds2)); }
@Test public void testNotEqualOtherObject() { final DataSet ds1 = generateTestData(); assertFalse(ds1.equals("")); } |
DataSet { public double getMin(final int column) { double result = Double.POSITIVE_INFINITY; for (final Object[] obj : this.data) { result = Math.min(result, convertNumeric(obj, column)); } return result; } DataSet(final String[] theHeaders); static DataSet load(final File filename); static DataSet load(final InputStre... | @Test public void testMin() { final DataSet ds1 = generateTestData(); assertEquals(1.0, ds1.getMin(1), AIFH.DEFAULT_PRECISION); assertEquals(1.0, ds1.getMin(1), AIFH.DEFAULT_PRECISION); } |
DataSet { public double getMax(final int column) { double result = Double.NEGATIVE_INFINITY; for (final Object[] obj : this.data) { result = Math.max(result, convertNumeric(obj, column)); } return result; } DataSet(final String[] theHeaders); static DataSet load(final File filename); static DataSet load(final InputStre... | @Test public void testMax() { final DataSet ds1 = generateTestData(); assertEquals(3.0, ds1.getMax(1), AIFH.DEFAULT_PRECISION); assertEquals(3.0, ds1.getMax(1), AIFH.DEFAULT_PRECISION); } |
DataSet { public void normalizeRange(final int column, final double dataLow, final double dataHigh, final double normalizedLow, final double normalizedHigh) { for (final Object[] obj : this.data) { final double x = convertNumeric(obj, column); obj[column] = ((x - dataLow) / (dataHigh - dataLow)) * (normalizedHigh - nor... | @Test public void testNormalizeRange() { final DataSet ds1 = generateTestData(); ds1.normalizeRange(1, -1, 1); assertEquals(-1.0, Double.parseDouble(ds1.getData().get(0)[1].toString()) , AIFH.DEFAULT_PRECISION); } |
DataSet { public void deNormalizeRange(final int column, final double dataLow, final double dataHigh, final double normalizedLow, final double normalizedHigh) { for (final Object[] obj : this.data) { final double x = convertNumeric(obj, column); obj[column] = ((dataLow - dataHigh) * x - normalizedHigh * dataLow + dataH... | @Test public void testDeNormalizeRange() { final DataSet ds1 = generateTestData(); final double min = ds1.getMin(2); final double max = ds1.getMax(2); ds1.normalizeRange(2, min, max, -1, 1); assertEquals(-1.0, Double.parseDouble(ds1.getData().get(0)[2].toString()) , AIFH.DEFAULT_PRECISION); ds1.deNormalizeRange(2, min,... |
DataSet { public void normalizeReciprocal(final int column) { for (final Object[] obj : this.data) { final double x = convertNumeric(obj, column); obj[column] = 1 / x; } } DataSet(final String[] theHeaders); static DataSet load(final File filename); static DataSet load(final InputStream is); static void save(final File... | @Test public void testNormalizeReciprocal() { final DataSet ds1 = generateTestData(); ds1.normalizeReciprocal(1); assertEquals(0.5, Double.parseDouble(ds1.getData().get(1)[1].toString()) , AIFH.DEFAULT_PRECISION); ds1.deNormalizeReciprocal(1); assertEquals(2.0, Double.parseDouble(ds1.getData().get(1)[1].toString()) , A... |
DataSet { public Map<String, Integer> encodeNumeric(final int column) { final Map<String, Integer> classes = enumerateClasses(column); for (final Object[] obj : this.data) { final int index = classes.get(obj[column].toString()); obj[column] = index; } return classes; } DataSet(final String[] theHeaders); static DataSet... | @Test public void testEncodeNumeric() { final DataSet ds1 = generateTestData(); ds1.encodeNumeric(0); } |
RBFNetwork implements RegressionAlgorithm, ClassificationAlgorithm { @Override public double[] computeRegression(final double[] input) { final double[] rbfOutput = new double[rbf.length + 1]; rbfOutput[rbfOutput.length - 1] = 1; for (int rbfIndex = 0; rbfIndex < rbf.length; rbfIndex++) { final double[] weightedInput = ... | @Test public void testComputeRegression() { final RBFNetwork network = new RBFNetwork(2, 1, 1); final double[] ltm = { 2.0, 2.0, 5.0, 2.0, 4.0, 3.0, 4.0}; System.arraycopy(ltm, 0, network.getLongTermMemory(), 0, ltm.length); final double[] x = {1, 2}; final double y = network.computeRegression(x)[0]; assertEquals(7, y,... |
DataSet { public Map<String, Integer> encodeOneOfN(final int column) { return encodeOneOfN(column, 0, 1); } DataSet(final String[] theHeaders); static DataSet load(final File filename); static DataSet load(final InputStream is); static void save(final File filename, final DataSet ds); static void save(final OutputStrea... | @Test public void testEncodeOneOfN() { final DataSet ds1 = generateTestData(); ds1.encodeOneOfN(0); } |
DataSet { public Map<String, Integer> encodeEquilateral(final int column) { return encodeEquilateral(column, 0, 1); } DataSet(final String[] theHeaders); static DataSet load(final File filename); static DataSet load(final InputStream is); static void save(final File filename, final DataSet ds); static void save(final O... | @Test public void testEncodeEquilateral() { final DataSet ds1 = generateTestData(); ds1.encodeEquilateral(0,-1,1); assertEquals(4,ds1.getHeaderCount()); Set<Double> col1=new HashSet<>(); Set<Double> col2=new HashSet<>(); for (Object[] row:ds1.getData()){ col1.add(round((Double)row[0])); col2.add(round((Double)row[1]));... |
DataSet { public void deleteColumn(final int col) { final String[] headers2 = new String[headers.length - 1]; int h2Index = 0; for (int i = 0; i < headers.length; i++) { if (i != col) { headers2[h2Index++] = headers[i]; } } this.headers = headers2; int rowIndex = 0; for (final Object[] row : this.data) { final Object[]... | @Test public void testDeleteColumn() { final DataSet ds1 = generateTestData(); ds1.deleteColumn(0); assertEquals(2, ds1.getHeaderCount()); assertTrue(ds1.getHeaders()[0].equals("numeric")); assertTrue(ds1.getHeaders()[1].equals("dec")); } |
DataSet { public List<BasicData> extractUnsupervisedLabeled(final int labelIndex) { final List<BasicData> result = new ArrayList<BasicData>(); final int dimensions = getHeaderCount() - 1; for (int rowIndex = 0; rowIndex < size(); rowIndex++) { final Object[] raw = this.data.get(rowIndex); final BasicData row = new Basi... | @Test public void testExtractUnsupervisedLabeled() { final DataSet ds1 = generateTestData(); final List<BasicData> result = ds1.extractUnsupervisedLabeled(0); assertEquals(3, result.size()); assertTrue(result.get(0).getLabel().equals("One")); } |
DataSet { public List<BasicData> extractSupervised(final int inputBegin, final int inputCount, final int idealBegin, final int idealCount) { final List<BasicData> result = new ArrayList<BasicData>(); for (int rowIndex = 0; rowIndex < size(); rowIndex++) { final Object[] raw = this.data.get(rowIndex); final BasicData ro... | @Test public void testExtractSupervised() { final DataSet ds1 = generateTestData(); final List<BasicData> result = ds1.extractSupervised(1, 1, 2, 1); assertEquals(3, result.size()); } |
DataSet { public void replaceColumn(final int columnIndex, final double searchFor, final double replaceWith, final double others) { for (final Object[] row : this.data) { final double d = convertNumeric(row, columnIndex); if (Math.abs(d - searchFor) < 0.0001) { row[columnIndex] = replaceWith; } else { row[columnIndex] ... | @Test public void testReplaceColumn() { final DataSet ds1 = generateTestData(); ds1.replaceColumn(1, 2, 1, 0); final List<BasicData> result = ds1.extractSupervised(1, 1, 2, 1); assertEquals(0.0, result.get(0).getInput()[0], AIFH.DEFAULT_PRECISION); assertEquals(1.0, result.get(1).getInput()[0], AIFH.DEFAULT_PRECISION);... |
DataSet { public void deleteUnknowns() { int rowIndex = 0; while (rowIndex < this.data.size()) { final Object[] row = data.get(rowIndex); boolean remove = false; for (final Object aRow : row) { if (aRow.toString().equals("?")) { remove = true; break; } } if (remove) { data.remove(rowIndex); } else { rowIndex++; } } } D... | @Test public void testDeleteUnknowns() { final DataSet ds1 = generateTestData(); ds1.getData().get(1)[2] = "?"; ds1.deleteUnknowns(); assertEquals(2, ds1.getData().size()); } |
Equilateral implements Serializable { public final double[] encode(final int set) { if (set < 0 || set > this.matrix.length) { throw new AIFHError("Class out of range for equilateral: " + set); } return this.matrix[set]; } Equilateral(final int count, final double low, final double high); final int decode(final double[... | @Test public void testEncode() { final Equilateral eq = new Equilateral(3, -1, 1); final double[] d = eq.encode(1); assertEquals(0.8660254037844386, d[0], AIFH.DEFAULT_PRECISION); assertEquals(-0.5, d[1], AIFH.DEFAULT_PRECISION); }
@Test(expected = AIFHError.class) public void testError() { final Equilateral eq = new E... |
Equilateral implements Serializable { public final int decode(final double[] activations) { double minValue = Double.POSITIVE_INFINITY; int minSet = -1; for (int i = 0; i < this.matrix.length; i++) { final double dist = getDistance(activations, i); if (dist < minValue) { minValue = dist; minSet = i; } } return minSet; ... | @Test public void testDecode() { final Equilateral eq = new Equilateral(3, -1, 1); final double[] d0 = {0.866, 0.5}; final double[] d1 = {-0.866, 0.5}; final double[] d2 = {0, -1}; assertEquals(2, eq.decode(d0)); assertEquals(2, eq.decode(d1)); assertEquals(0, eq.decode(d2)); } |
RBFNetwork implements RegressionAlgorithm, ClassificationAlgorithm { @Override public int computeClassification(final double[] input) { final double[] output = computeRegression(input); return VectorUtil.maxIndex(output); } RBFNetwork(final int theInputCount, final int rbfCount, final int theOutputCount); @Override dou... | @Test public void testComputeClassification() { final RBFNetwork network = new RBFNetwork(2, 1, 2); final double[] ltm = { 2.0, 2.0, 5.0, 2.0, 4.0, 3.0, 4.0, 5.0, 6.0}; System.arraycopy(ltm, 0, network.getLongTermMemory(), 0, ltm.length); final double[] x = {1, 2}; final double[] y = network.computeRegression(x); asser... |
BasicGenerateRandom extends AbstractGenerateRandom { @Override public boolean nextBoolean() { return this.rand.nextBoolean(); } BasicGenerateRandom(final long seed); BasicGenerateRandom(); @Override int nextInt(); @Override double nextDouble(); @Override float nextFloat(); @Override long nextLong(); @Override boolean ... | @Test public void testGenerateBoolean() { final BasicGenerateRandom rnd = new BasicGenerateRandom(1); for (final boolean aBOOLEAN_TEST : BOOLEAN_TEST) { final boolean g = rnd.nextBoolean(); assertEquals(g, aBOOLEAN_TEST); } } |
BasicGenerateRandom extends AbstractGenerateRandom { @Override public double nextDouble() { return this.rand.nextDouble(); } BasicGenerateRandom(final long seed); BasicGenerateRandom(); @Override int nextInt(); @Override double nextDouble(); @Override float nextFloat(); @Override long nextLong(); @Override boolean nex... | @Test public void testDoubleRange() { final BasicGenerateRandom rnd = new BasicGenerateRandom(1); for (final double aDOUBLE_RANGE_TEST : DOUBLE_RANGE_TEST) { final double g = rnd.nextDouble(-1, 1); assertEquals(g, aDOUBLE_RANGE_TEST, AIFH.DEFAULT_PRECISION); } }
@Test public void testDouble() { final BasicGenerateRando... |
BasicGenerateRandom extends AbstractGenerateRandom { @Override public long nextLong() { return this.rand.nextLong(); } BasicGenerateRandom(final long seed); BasicGenerateRandom(); @Override int nextInt(); @Override double nextDouble(); @Override float nextFloat(); @Override long nextLong(); @Override boolean nextBoole... | @Test public void testLong() { final BasicGenerateRandom rnd = new BasicGenerateRandom(1); for (final long aLONG_TEST : LONG_TEST) { final long l = rnd.nextLong(); assertEquals(l, aLONG_TEST, AIFH.DEFAULT_PRECISION); } } |
BasicGenerateRandom extends AbstractGenerateRandom { @Override public float nextFloat() { return this.rand.nextFloat(); } BasicGenerateRandom(final long seed); BasicGenerateRandom(); @Override int nextInt(); @Override double nextDouble(); @Override float nextFloat(); @Override long nextLong(); @Override boolean nextBo... | @Test public void testFloat() { final BasicGenerateRandom rnd = new BasicGenerateRandom(1); for (final float aFLOAT_TEST : FLOAT_TEST) { final float l = (float) rnd.nextFloat(); assertEquals(l, aFLOAT_TEST, AIFH.DEFAULT_PRECISION); } } |
BasicGenerateRandom extends AbstractGenerateRandom { @Override public double nextGaussian() { return this.rand.nextGaussian(); } BasicGenerateRandom(final long seed); BasicGenerateRandom(); @Override int nextInt(); @Override double nextDouble(); @Override float nextFloat(); @Override long nextLong(); @Override boolean... | @Test public void testGaussianFloat() { final BasicGenerateRandom rnd = new BasicGenerateRandom(1); for (final double aGAUSSIAN_TEST : GAUSSIAN_TEST) { final double g = rnd.nextGaussian(); assertEquals(g, aGAUSSIAN_TEST, AIFH.DEFAULT_PRECISION); } } |
BasicGenerateRandom extends AbstractGenerateRandom { @Override public int nextInt() { return this.rand.nextInt(); } BasicGenerateRandom(final long seed); BasicGenerateRandom(); @Override int nextInt(); @Override double nextDouble(); @Override float nextFloat(); @Override long nextLong(); @Override boolean nextBoolean(... | @Test public void testInt() { final BasicGenerateRandom rnd = new BasicGenerateRandom(1); for (final int aINT_TEST : INT_TEST) { final int g = rnd.nextInt(); assertEquals(g, aINT_TEST, AIFH.DEFAULT_PRECISION); } }
@Test public void testIntRange() { final BasicGenerateRandom rnd = new BasicGenerateRandom(1); for (final ... |
MultiplyWithCarryGenerateRandom extends AbstractBoxMuller { @Override public boolean nextBoolean() { return nextDouble() > 0.5; } MultiplyWithCarryGenerateRandom(final long seed); MultiplyWithCarryGenerateRandom(); MultiplyWithCarryGenerateRandom(long[] seeds, final long carry, final int r, final long multiplier); @O... | @Test public void testGenerateBoolean() { final MultiplyWithCarryGenerateRandom rnd = new MultiplyWithCarryGenerateRandom(1); for (final boolean aBOOLEAN_TEST : BOOLEAN_TEST) { final boolean g = rnd.nextBoolean(); assertEquals(g, aBOOLEAN_TEST); } } |
ChebyshevDistance extends AbstractDistance { @Override public double calculate(final double[] position1, final int pos1, final double[] position2, final int pos2, final int length) { double result = 0; for (int i = 0; i < length; i++) { final double d = Math.abs(position1[pos1 + i] - position2[pos2 + i]); result = Math... | @Test public void testDistanceCalc() { final CalculateDistance calc = new ChebyshevDistance(); final double[] pos1 = {0.5, 1.0, 2.5,}; final double[] pos2 = {0.1, 2.0, -2.5,}; assertEquals(5.0, calc.calculate(pos1, pos2), 0.001); } |
MultiplyWithCarryGenerateRandom extends AbstractBoxMuller { @Override public double nextDouble() { return (((long) next(26) << 27) + next(27)) / (double) (1L << 53); } MultiplyWithCarryGenerateRandom(final long seed); MultiplyWithCarryGenerateRandom(); MultiplyWithCarryGenerateRandom(long[] seeds, final long carry, f... | @Test public void testDoubleRange() { final MultiplyWithCarryGenerateRandom rnd = new MultiplyWithCarryGenerateRandom(1); for (final double aDOUBLE_RANGE_TEST : DOUBLE_RANGE_TEST) { final double g = rnd.nextDouble(-1, 1); assertEquals(g, aDOUBLE_RANGE_TEST, AIFH.DEFAULT_PRECISION); } }
@Test public void testDouble() { ... |
MultiplyWithCarryGenerateRandom extends AbstractBoxMuller { @Override public long nextLong() { return ((long) next(32) << 32) + next(32); } MultiplyWithCarryGenerateRandom(final long seed); MultiplyWithCarryGenerateRandom(); MultiplyWithCarryGenerateRandom(long[] seeds, final long carry, final int r, final long multi... | @Test public void testLong() { final MultiplyWithCarryGenerateRandom rnd = new MultiplyWithCarryGenerateRandom(1); for (final long aLONG_TEST : LONG_TEST) { final long l = rnd.nextLong(); assertEquals(l, aLONG_TEST); } } |
MultiplyWithCarryGenerateRandom extends AbstractBoxMuller { @Override public float nextFloat() { return (float) nextDouble(); } MultiplyWithCarryGenerateRandom(final long seed); MultiplyWithCarryGenerateRandom(); MultiplyWithCarryGenerateRandom(long[] seeds, final long carry, final int r, final long multiplier); @Ove... | @Test public void testFloat() { final MultiplyWithCarryGenerateRandom rnd = new MultiplyWithCarryGenerateRandom(1); for (final float aFLOAT_TEST : FLOAT_TEST) { final float l = (float) rnd.nextFloat(); assertEquals(l, aFLOAT_TEST, AIFH.DEFAULT_PRECISION); } } |
MultiplyWithCarryGenerateRandom extends AbstractBoxMuller { @Override public int nextInt() { return (int) nextLong(); } MultiplyWithCarryGenerateRandom(final long seed); MultiplyWithCarryGenerateRandom(); MultiplyWithCarryGenerateRandom(long[] seeds, final long carry, final int r, final long multiplier); @Override do... | @Test public void testInt() { final MultiplyWithCarryGenerateRandom rnd = new MultiplyWithCarryGenerateRandom(1); for (final int aINT_TEST : INT_TEST) { final int g = rnd.nextInt(); assertEquals(g, aINT_TEST); } }
@Test public void testIntRange() { final MultiplyWithCarryGenerateRandom rnd = new MultiplyWithCarryGenera... |
LinearCongruentialRandom extends AbstractBoxMuller { @Override public boolean nextBoolean() { return nextDouble() > 0.5; } LinearCongruentialRandom(final long theSeed); LinearCongruentialRandom(); LinearCongruentialRandom(final long theModulus,
final long theMultiplier, final long ... | @Test public void testGenerateBoolean() { final LinearCongruentialRandom rnd = new LinearCongruentialRandom(1); for (final boolean aBOOLEAN_TEST : BOOLEAN_TEST) { final boolean g = rnd.nextBoolean(); assertEquals(g, aBOOLEAN_TEST); } } |
LinearCongruentialRandom extends AbstractBoxMuller { @Override public final double nextDouble() { return (double) nextLong() / LinearCongruentialRandom.MAX_RAND; } LinearCongruentialRandom(final long theSeed); LinearCongruentialRandom(); LinearCongruentialRandom(final long theModulus,
... | @Test public void testDoubleRange() { final LinearCongruentialRandom rnd = new LinearCongruentialRandom(1); for (final double aDOUBLE_RANGE_TEST : DOUBLE_RANGE_TEST) { final double g = rnd.nextDouble(-1, 1); assertEquals(g, aDOUBLE_RANGE_TEST, AIFH.DEFAULT_PRECISION); } }
@Test public void testDouble() { final LinearCo... |
LinearCongruentialRandom extends AbstractBoxMuller { @Override public final long nextLong() { this.seed = (this.multiplier * this.seed + this.increment) % this.modulus; return this.seed; } LinearCongruentialRandom(final long theSeed); LinearCongruentialRandom(); LinearCongruentialRandom(final long theModulus,
... | @Test public void testLong() { final LinearCongruentialRandom rnd = new LinearCongruentialRandom(1); for (final long aLONG_TEST : LONG_TEST) { final long l = rnd.nextLong(); assertEquals(l, aLONG_TEST, AIFH.DEFAULT_PRECISION); } } |
EuclideanDistance extends AbstractDistance { @Override public double calculate(final double[] position1, final int pos1, final double[] position2, final int pos2, final int length) { double sum = 0; for (int i = 0; i < length; i++) { final double d = position1[i + pos1] - position2[i + pos1]; sum += d * d; } return Mat... | @Test public void testDistanceCalc() { final CalculateDistance calc = new EuclideanDistance(); final double[] pos1 = {0.5, 1.0, 2.5,}; final double[] pos2 = {0.1, 2.0, -2.5,}; assertEquals(5.1146, calc.calculate(pos1, pos2), 0.001); } |
LinearCongruentialRandom extends AbstractBoxMuller { @Override public float nextFloat() { return (float) nextDouble(); } LinearCongruentialRandom(final long theSeed); LinearCongruentialRandom(); LinearCongruentialRandom(final long theModulus,
final long theMultiplier, final long th... | @Test public void testFloat() { final LinearCongruentialRandom rnd = new LinearCongruentialRandom(1); for (final float aFLOAT_TEST : FLOAT_TEST) { final float l = (float) rnd.nextFloat(); assertEquals(l, aFLOAT_TEST, AIFH.DEFAULT_PRECISION); } } |
LinearCongruentialRandom extends AbstractBoxMuller { @Override public int nextInt() { return (int) nextLong(); } LinearCongruentialRandom(final long theSeed); LinearCongruentialRandom(); LinearCongruentialRandom(final long theModulus,
final long theMultiplier, final long theIncreme... | @Test public void testInt() { final LinearCongruentialRandom rnd = new LinearCongruentialRandom(1); for (final int aINT_TEST : INT_TEST) { final int g = rnd.nextInt(); assertEquals(g, aINT_TEST, AIFH.DEFAULT_PRECISION); } }
@Test public void testIntRange() { final LinearCongruentialRandom rnd = new LinearCongruentialRa... |
MersenneTwisterGenerateRandom extends AbstractBoxMuller { @Override public double nextDouble() { return (((long) next(26) << 27) + next(27)) / (double) (1L << 53); } MersenneTwisterGenerateRandom(); MersenneTwisterGenerateRandom(final long seed); MersenneTwisterGenerateRandom(final int[] array); void setSeed(final lo... | @Test public void testBasic() { final MersenneTwisterGenerateRandom rnd = new MersenneTwisterGenerateRandom(1); assertEquals(4.1702200468159925, rnd.nextDouble(10), AIFH.DEFAULT_PRECISION); }
@Test public void testBasic2() { final int[] seed = {1, 2, 3}; final MersenneTwisterGenerateRandom rnd = new MersenneTwisterGene... |
MersenneTwisterGenerateRandom extends AbstractBoxMuller { @Override public boolean nextBoolean() { return nextDouble() > 0.5; } MersenneTwisterGenerateRandom(); MersenneTwisterGenerateRandom(final long seed); MersenneTwisterGenerateRandom(final int[] array); void setSeed(final long seed); void setSeed(final int[] arr... | @Test public void testGenerateBoolean() { final MersenneTwisterGenerateRandom rnd = new MersenneTwisterGenerateRandom(1); for (final boolean aBOOLEAN_TEST : BOOLEAN_TEST) { final boolean g = rnd.nextBoolean(); assertEquals(g, aBOOLEAN_TEST); } } |
MersenneTwisterGenerateRandom extends AbstractBoxMuller { public long nextLong() { return ((long) next(32) << 32) + next(32); } MersenneTwisterGenerateRandom(); MersenneTwisterGenerateRandom(final long seed); MersenneTwisterGenerateRandom(final int[] array); void setSeed(final long seed); void setSeed(final int[] arr... | @Test public void testLong() { final MersenneTwisterGenerateRandom rnd = new MersenneTwisterGenerateRandom(1); for (final long aLONG_TEST : LONG_TEST) { final long l = rnd.nextLong(); assertEquals(l, aLONG_TEST); } } |
MersenneTwisterGenerateRandom extends AbstractBoxMuller { @Override public float nextFloat() { return (float) nextDouble(); } MersenneTwisterGenerateRandom(); MersenneTwisterGenerateRandom(final long seed); MersenneTwisterGenerateRandom(final int[] array); void setSeed(final long seed); void setSeed(final int[] array... | @Test public void testFloat() { final MersenneTwisterGenerateRandom rnd = new MersenneTwisterGenerateRandom(1); for (final float aFLOAT_TEST : FLOAT_TEST) { final float l = (float) rnd.nextFloat(); assertEquals(l, aFLOAT_TEST, AIFH.DEFAULT_PRECISION); } } |
ManhattanDistance extends AbstractDistance { @Override public double calculate(final double[] position1, final int pos1, final double[] position2, final int pos2, final int length) { double sum = 0; for (int i = 0; i < length; i++) { final double d = Math.abs(position1[pos1 + i] - position2[pos1 + i]); sum += d; } retu... | @Test public void testDistanceCalc() { final CalculateDistance calc = new ManhattanDistance(); final double[] pos1 = {0.5, 1.0, 2.5,}; final double[] pos2 = {0.1, 2.0, -2.5,}; assertEquals(6.4, calc.calculate(pos1, pos2), 0.001); } |
MersenneTwisterGenerateRandom extends AbstractBoxMuller { @Override public int nextInt() { return (int) nextLong(); } MersenneTwisterGenerateRandom(); MersenneTwisterGenerateRandom(final long seed); MersenneTwisterGenerateRandom(final int[] array); void setSeed(final long seed); void setSeed(final int[] array); @Over... | @Test public void testInt() { final MersenneTwisterGenerateRandom rnd = new MersenneTwisterGenerateRandom(1); for (final int aINT_TEST : INT_TEST) { final int g = rnd.nextInt(); assertEquals(g, aINT_TEST); } }
@Test public void testIntRange() { final MersenneTwisterGenerateRandom rnd = new MersenneTwisterGenerateRandom... |
BasicNetwork implements RegressionAlgorithm, ClassificationAlgorithm { public double getWeight(final int fromLayer, final int fromNeuron, final int toNeuron) { validateNeuron(fromLayer, fromNeuron); validateNeuron(fromLayer + 1, toNeuron); final int fromLayerNumber = this.layers.size() - fromLayer - 1; final int toLaye... | @Test public void testWeightAccess() { BasicNetwork network = TestBasicNetwork.buildSimpleXOR(); Assert.assertEquals(-0.48463710059519793,network.getWeight(0,0,0), AIFH.DEFAULT_PRECISION); Assert.assertEquals(0.8420570357334933,network.getWeight(0,0,1), AIFH.DEFAULT_PRECISION); Assert.assertEquals(-0.5286518143323836,n... |
BasicNetwork implements RegressionAlgorithm, ClassificationAlgorithm { @Override public double[] computeRegression(double[] input) { if( input.length!=getInputCount()) { throw new AIFHError("Invalid input count("+ input.length+"), this network is designed for: " + getInputCount()); } double[] output = new double[getOut... | @Test public void testCalculate() { BasicNetwork network = TestBasicNetwork.buildSimpleXOR(); double[] out1 = network.computeRegression(new double[] {0.0, 0.0}); Assert.assertEquals(0.34688637738116557, out1[0], AIFH.DEFAULT_PRECISION); double[] out2 = network.computeRegression(new double[] {1.0, 0.0}); Assert.assertEq... |
XaiverRandomizeNetwork extends AbstractRandomizeNetwork { @Override public void randomize(BasicNetwork network) { for (int i = 0; i < network.getLayers().size() - 1; i++) { randomizeLayer(network, i); } } @Override void randomize(BasicNetwork network); } | @Test public void testRandomize() { BasicNetwork network = new BasicNetwork(); network.addLayer(new BasicLayer(null,true,2)); network.addLayer(new BasicLayer(new ActivationSigmoid(),true,3)); network.addLayer(new BasicLayer(new ActivationSigmoid(),false,1)); network.finalizeStructure(); XaiverRandomizeNetwork randomize... |
KMeans { public void initRandom(final List<BasicData> theObservations) { final int dimensions = findDimensions(theObservations); for (int i = 0; i < this.k; i++) { this.clusters.add(new Cluster(dimensions)); } for (final BasicData observation : theObservations) { final int clusterIndex = this.randomGeneration.nextInt(t... | @Test(expected = AIFHError.class) public void testTooManyClusters() { final KMeans kmeans = new KMeans(13); kmeans.initRandom(getDataSet()); } |
KMeans { public boolean iteration() { if (this.clusters.size() == 0) { throw new AIFHError("Must call one of the init methods first."); } final boolean done = assignmentStep(); if (!done) { updateStep(); } return done; } KMeans(final int theK); void initRandom(final List<BasicData> theObservations); void initForgy(fina... | @Test(expected = AIFHError.class) public void testEarlyIteration() { final KMeans kmeans = new KMeans(3); kmeans.iteration(); } |
SvgSanitizer { public static String sanitize(String svg){ svg = removeXMLNS(svg); svg = removeDuplicateXmlnsXlink(svg); svg = removeNS1(svg); return svg; } static String sanitize(String svg); } | @Test void sanitize_withTwoXmlns_RemovesSuperfluousXmlns(){ String expectedSVG = "<svg height=\"1000\" width=\"1583\" xmlns:xlink=\"http: String inputSVG = "<svg xmlns=\"http: assertEquals(expectedSVG, SvgSanitizer.sanitize(inputSVG)); }
@Test void sanitize_withTwoXmlnsInImageTagAndOneInSvgTag_RemovesSuperfluousXmlnsIn... |
StepIdentifier { @JsonIgnore public URI getStepUriForRedirect() { return createUriForRedirect(RedirectType.STEP, null); } StepIdentifier(); StepIdentifier(final BuildIdentifier buildIdentifier, final String usecaseName, final String scenarioName,
final String pageName, final int pageOccurrence, final int stepInPage... | @Test public void redirectUrlForStepWithoutContextPath() { String contextPath = ContextPathHolder.INSTANCE.getContextPath(); ContextPathHolder.INSTANCE.setContextPath(""); try { assertEquals( "/rest/branch/bugfix-branch/build/build-2014-08-12/usecase/Find the answer/scenario/Actually find it/pageName/pageName1/pageOccu... |
AvailableBuildsList { public synchronized List<BranchBuilds> getBranchBuildsList() { return branchBuildsList; } synchronized List<BranchBuilds> getBranchBuildsList(); synchronized BranchBuilds getBranchBuilds(final String branchName); synchronized void updateBuildsWithSuccessfullyImportedBuilds(final List<BranchBuilds... | @Test void testInitializedEmpty() { assertEquals(0, availableBuildsList.getBranchBuildsList().size(), "Expected initialized as empty list"); } |
AvailableBuildsList { public synchronized void updateBuildsWithSuccessfullyImportedBuilds(final List<BranchBuilds> branchBuildsList, final Map<BuildIdentifier, BuildImportSummary> buildImportSummaries) { List<BranchBuilds> result = new ArrayList<BranchBuilds>(); for (BranchBuilds branchBuilds : branchBuildsList) { Bran... | @Test void testUpdatingAvailableBuildsFromNoSuccessfullyImported() { List<BranchBuilds> branchBuilds = new ArrayList<>(Arrays.asList( createBranchBuilds("trunk", build5, build1, build6, build3, build7), createBranchBuilds("branch", build2, build4))); Map<BuildIdentifier, BuildImportSummary> buildImportSummaries = creat... |
BuildByDateSorter { public static List<BuildImportSummary> sortBuildsByDateDescending(final Collection<BuildImportSummary> unsortedSummaries) { List<BuildImportSummary> summaries = new LinkedList<BuildImportSummary>(); summaries.addAll(unsortedSummaries); Collections.sort(summaries, new BuildImportSummaryDateDescending... | @Test void sortBuildsByDateDescending_givenTwoBuildsInAscendingOder_resultsInTwoBuildsInDescendingOrder() { List<BuildImportSummary> buildsAscending = new LinkedList<>(); buildsAscending.add(OLDER_BUILD); buildsAscending.add(NEWER_BUILD); List<BuildImportSummary> buildsByDateDescending = BuildByDateSorter.sortBuildsByD... |
BuildSorter implements Comparator<BuildLink> { public static void sort(final List<BuildLink> builds) { Collections.sort(builds, new BuildSorter()); } static void sort(final List<BuildLink> builds); @Override int compare(final BuildLink bl1, final BuildLink bl2); } | @Test void testSortingSomeBuilds() { BuildLink build1 = createBuildSuccess("build1", 1); BuildLink build2 = createBuildSuccess("build2", 2); BuildLink build3 = createBuildFailed("build3", 3); BuildLink aliasCurrent = createBuildAlias(Configuration.DEFAULT_ALIAS_FOR_LAST_SUCCESSFUL_BUILD, build2.getBuild()); BuildLink a... |
UseCaseComparator extends AbstractStructureComparator<UseCase, String, UseCase> { public BuildDiffInfo compare() { final List<UseCase> baseUseCases = scenarioDocuReader.loadUsecases(parameters.getBaseBranchName(), parameters.getBaseBuildName()); final List<UseCase> comparisonUseCases = scenarioDocuReader.loadUsecases( ... | @Test void testCompareBuildsEqual() { List<UseCase> baseUseCases = getUseCases(USE_CASE_NAME_1, USE_CASE_NAME_2, USE_CASE_NAME_3); List<UseCase> comparisonUseCases = getUseCases(USE_CASE_NAME_1, USE_CASE_NAME_2, USE_CASE_NAME_3); UseCaseDiffInfo useCaseDiffInfo = getUseCaseDiffInfo(0, 0, 0, 0); initMocks(baseUseCases, ... |
StepComparator extends AbstractStructureComparator<StepLink, Integer, StepInfo> { public ScenarioDiffInfo compare(final String baseUseCaseName, final String baseScenarioName) { this.baseUseCaseName = baseUseCaseName; this.baseScenarioName = baseScenarioName; final List<Step> baseSteps = loadSteps(parameters.getBaseBran... | @Test void buildsEqual() { List<Step> baseSteps = getSteps(PAGE_NAME_1, PAGE_NAME_1, PAGE_NAME_2); List<Step> comparisonSteps = getSteps(PAGE_NAME_1, PAGE_NAME_1, PAGE_NAME_2); initMocks(baseSteps, comparisonSteps, 0.0); ScenarioDiffInfo scenarioDiffInfo = stepComparator.compare(USE_CASE_NAME, SCENARIO_NAME); assertEqu... |
ScenarioComparator extends AbstractStructureComparator<Scenario, String, ScenarioSummary> { public UseCaseDiffInfo compare(final String baseUseCaseName) { this.baseUseCaseName = baseUseCaseName; final List<Scenario> baseScenarios = scenarioDocuReader.loadScenarios(parameters.getBaseBranchName(), parameters.getBaseBuild... | @Test void testCompareBuildsEqual() { List<Scenario> baseScenarios = getScenarios(SCENARIO_NAME_1, SCENARIO_NAME_2, SCENARIO_NAME_3); List<Scenario> comparisonScenarios = getScenarios(SCENARIO_NAME_1, SCENARIO_NAME_2, SCENARIO_NAME_3); ScenarioDiffInfo scenarioDiffInfo = getScenarioDiffInfo(0, 0, 0, 0); initMocks(baseS... |
ComparisonExecutor { synchronized List<ComparisonConfiguration> getComparisonConfigurationsForBaseBranch(String baseBranchName) { List<ComparisonConfiguration> comparisonConfigurationsForBaseBranch = new LinkedList<>(); List<ComparisonConfiguration> comparisonConfigurations = configurationRepository.getConfiguration() ... | @Test void testGetComparisonConfigurationsForBaseBranch1() { List<ComparisonConfiguration> result = comparisonExecutor .getComparisonConfigurationsForBaseBranch(BRANCH_NAME_1); assertEquals(NUMBER_OF_COMPARISONS_FOR_BRANCH_1, result.size()); assertThat(result.get(0)).isEqualToComparingFieldByField(comparisonConfigurati... |
ComparisonExecutor { ComparisonConfiguration resolveComparisonConfiguration( ComparisonConfiguration comparisonConfiguration, String baseBuildName) { String lastSuccessFulAlias = configurationRepository.getConfiguration().getAliasForLastSuccessfulBuild(); String mostRecentAlias = configurationRepository.getConfiguratio... | @Test void testResolveComparisonConfigurationLastSuccessfulSameBranch() { ComparisonConfiguration result = comparisonExecutor.resolveComparisonConfiguration( comparisonConfiguration1, BUILD_NAME_3); assertEquals(BRANCH_NAME_1, result.getBaseBranchName()); assertEquals(BRANCH_NAME_1, result.getComparisonBranchName()); a... |
ComparisonExecutor { public boolean areAllComparisonCalculationsFinished() { return asyncComparisonExecutor.getActiveCount() == 0; } ComparisonExecutor(AliasResolver aliasResolver); ComparisonExecutor(ThreadPoolExecutor executorService, AliasResolver aliasResolver); void scheduleAllConfiguredComparisonsForOneBuild(St... | @Test void testAreAllComparisonCalculationsFinishedWithNoRunningThreadsReturnsTrue() { when(threadPoolExecutor.getActiveCount()).thenReturn(0); assertTrue(comparisonExecutor.areAllComparisonCalculationsFinished()); }
@Test void testAreAllComparisonCalculationsFinishedWithRunningThreadsReturnsFalse() { when(threadPoolEx... |
PageNameSanitizer { public static void sanitizePageName(final Step step) { if (step == null || step.getPage() == null) { return; } step.getPage().setName(sanitize(step.getPage().getName())); } static void sanitizePageNames(final List<Step> steps); static void sanitizePageName(final Step step); } | @Test void givenStepWithIllegalPageName_sanitizingPageNames_replacesIllegalCharacters() { Step step = getStepWithIllegalPageName(); PageNameSanitizer.sanitizePageName(step); assertEquals(SANITIZED, step.getPage().getName()); } |
PageNameSanitizer { public static void sanitizePageNames(final List<Step> steps) { if (steps == null) { return; } for (Step step : steps) { sanitizePageName(step); } } static void sanitizePageNames(final List<Step> steps); static void sanitizePageName(final Step step); } | @Test void givenStepListWithIllegalPageNames_sanitizingPageNames_replacesIllegalCharacters() { List<Step> steps = getStepsWithIllegalPageName(); PageNameSanitizer.sanitizePageNames(steps); assertEquals(SANITIZED, steps.get(0).getPage().getName()); assertEquals(SANITIZED, steps.get(1).getPage().getName()); } |
Configuration { @JsonIgnore public Color getDiffImageAwtColor() { int rgba = Long.decode(diffImageColor).intValue(); return new Color(rgba, true); } String getDefaultBranchName(); void setDefaultBranchName(final String defaultBranchName); String getDefaultBuildName(); void setDefaultBuildName(final String defaultBuild... | @Test void testDefaultDiffImageColor() { Color actual = configuration.getDiffImageAwtColor(); assertThat(actual).isEqualTo(DEFAULT_DIFF_COLOR); } |
ScenarioPageSteps { public int getTotalNumberOfStepsInPageOccurrence(final String pageName, final int pageOccurrence) { PageSteps pageWithSteps = getOccurrence(pageName, pageOccurrence); if (pageWithSteps == null) { return 0; } return pageWithSteps.getSteps().size(); } Scenario getScenario(); void setScenario(final Sc... | @Test void getTotalNumberOfStepsInPageOccurrence() { givenScenarioPagesAndSteps(); whenGettingTotalStepsForPage1SecondOccurrence(); expectTotalNumberOfStepsEquals(4); } |
ScenarioPageSteps { public StepStatistics getStepStatistics(final String pageName, final int pageOccurrence) { StepStatistics statistics = new StepStatistics(); statistics.setTotalNumberOfStepsInScenario(getTotalNumberOfStepsInScenario()); statistics .setTotalNumberOfStepsInPageOccurrence(getTotalNumberOfStepsInPageOcc... | @Test void getStepStatistics() { givenScenarioPagesAndSteps(); whenGettingPageStatisticsForPage1SecondOccurrence(); expectTotalNumberOfStepsInStatisticsEquals(7); expectTotalNumberOfStepsInPageOccurrenceInStatisticsEquals(4); expectTotalNumberOfPagesInScenarioInStatisticsEquals(3); } |
LongObjectNamesResolver { public synchronized String resolveObjectFileName(final String fullLengthName) { if (fullLengthName.length() > 100) { return resolveLongName(fullLengthName); } else { return fullLengthName; } } synchronized String resolveObjectFileName(final String fullLengthName); } | @Test void testSmallNamesJustPass() { String shortName = "aShortName"; String resolvedFileName = resolver.resolveObjectFileName(shortName); assertEquals(shortName, resolvedFileName); }
@Test void testLongNameIsShortened() { String longObjectName = "veryVeryVeryLongNameThatIsLongerThan100CharactersIsExpectedToBeShortene... |
ZipFileExtractor { public static void extractFile(final File zipFileToExtract, final File targetDir) throws ZipFileExtractionException { ZipFile zipFile = getZipFile(zipFileToExtract); if (targetDir.exists()) { try { FileUtils.deleteDirectory(targetDir); } catch (IOException e) { throw new ZipFileExtractionException("C... | @Test void extractFile_withFileThatExists_successful() throws IOException, ZipFileExtractionException { File extractedFolder = new File(targetFolder, "aFolder"); FileUtils.deleteDirectory(extractedFolder); assertFalse(extractedFolder.exists()); ZipFileExtractor.extractFile(zipFile, targetFolder); assertAllFoldersAndFil... |
NumberFormatter { public static final String formatMinimumThreeDigits(long number) { if(number < 0) { throw new RuntimeException("Encountered a negative number, which must be a bug: " + number); } return NumberFormatter.createNumberFormatWithMinimumIntegerDigits(3).format(number); } static final String formatMinimumTh... | @Test void formatMinimumThreeDigits_positiveNumbersAndZero_returnsFormattedNumber() { assertEquals("000", NumberFormatter.formatMinimumThreeDigits(0)); assertEquals("001", NumberFormatter.formatMinimumThreeDigits(1)); assertEquals("999", NumberFormatter.formatMinimumThreeDigits(999)); assertEquals("1000", NumberFormatt... |
ScenariooDataPathLogic { String getDataPath(final ServletContext servletContext) { String configSource = "servlet context"; String configurationDirectory = servletContext.getInitParameter( "scenariooDataDirectory"); if (StringUtils.isBlank(configurationDirectory)) { configSource = "SCENARIOO_DATA environment variable o... | @Test void getDocumentationPath_GivenServletConfigAndEnvVariable_ChosesServletContextFirst() { when(servletContext.getInitParameter("scenariooDataDirectory")).thenReturn("tmp/test"); when(systemEnvironment.getScenariooDataDirectory()).thenReturn("tmp/itShouldNotBeMe"); String actual = logic.getDataPath(servletContext);... |
IdGenerator { public static String generateRandomId() { UUID uuid = UUID.randomUUID(); return generateIdUsingHash(uuid.toString()); } static String generateRandomId(); static String generateIdUsingHash(final String value); } | @Test void randomIdHasLength8() { assertEquals(8, IdGenerator.generateRandomId().length()); }
@Test void randomValuesAreAlwaysDifferent() { String first = IdGenerator.generateRandomId(); String second = IdGenerator.generateRandomId(); assertNotEquals(first, second); } |
IdGenerator { public static String generateIdUsingHash(final String value) { MessageDigest converter; try { converter = MessageDigest.getInstance("SHA1"); String id = new String(Hex.encodeHex(converter.digest(value.getBytes()))); return id.substring(0, 8); } catch (final NoSuchAlgorithmException e) { LOGGER.info("Can't... | @Test void allHashesAreOfLength8() { assertEquals(8, IdGenerator.generateIdUsingHash("").length()); assertEquals(8, IdGenerator.generateIdUsingHash("hello").length()); assertEquals(8, IdGenerator.generateIdUsingHash("hello world").length()); }
@Test void hashOfNullString_throwsException() { assertThrows(NullPointerExce... |
SketcherDao { public void persistIssue(final String branchName, final Issue issue) { final File destinationFile = getIssueFile(branchName, issue.getIssueId()); createParentDirectoryIfNeeded(destinationFile); ScenarioDocuXMLFileUtil.marshal(issue, destinationFile); } SketcherDao(); File getRootDirectory(); File getBranc... | @Test void persistIssue() { givenIssueDirectoryDoesNotExist(); sketcherDao.persistIssue(BRANCH_NAME, createIssue(ISSUE_ID)); expectIssueDirectoryExists(); expectIssuePersisted(); } |
SketcherDao { public void persistStepSketch(final String branchName, final String issueId, final String scenarioSketchId, final StepSketch stepSketch) { final File stepSketchXmlFile = getStepSketchXmlFile(branchName, issueId, scenarioSketchId, stepSketch); createParentDirectoryIfNeeded(stepSketchXmlFile); ScenarioDocuX... | @Test void persistStepSketch() { givenIssueDirectoryDoesNotExist(); sketcherDao.persistStepSketch(BRANCH_NAME, ISSUE_ID, SCENARIO_SKETCH_ID, STEP_SKETCH); expectStepSketchDirectoryCreated(); expectStepSketchPersisted(); } |
SketcherDao { public void persistSketchAsSvgAndPng(final String branchName, final String issueId, final String scenarioSketchId, final StepSketch stepSketch) { storeSvgFile(branchName, issueId, scenarioSketchId, stepSketch); storePngFile(branchName, issueId, scenarioSketchId, stepSketch.getStepSketchId(), stepSketch.ge... | @Test void persistSketchAsSvgAndPng() { givenIssueDirectoryDoesNotExist(); sketcherDao.persistSketchAsSvgAndPng(BRANCH_NAME, ISSUE_ID, SCENARIO_SKETCH_ID, STEP_SKETCH); expectStepSketchDirectoryCreated(); expectSketchAsSvgPersisted(); expectSketchAsPngPersisted(); } |
FileSystemOperationsDao { public void deleteBuild(final BuildIdentifier buildIdentifier) { File buildFolder = getBuildFolder( buildIdentifier); if (!buildFolder.exists()) { LOGGER.debug("Build folder " + buildFolder.getAbsolutePath() + " does not exist, therefore it can't be deleted."); return; } try { FileUtils.delete... | @Test void deleteBuild_deletesTheEntireBuildFolderWithAllSubfoldersAndFiles() { givenBuildFolderContainingSubfoldersAndFiles(); fileSystemOperationsDao.deleteBuild(buildIdentifier); expectBuildFolderIsDeleted(); expectBranchFolderStillExists(); } |
FileSystemOperationsDao { public void createBuildFolderIfItDoesNotExist(final BuildIdentifier buildIdentifier) { File buildFolder = getBuildFolder(buildIdentifier); if (buildFolder.exists()) { LOGGER.debug("Build folder " + buildFolder.getAbsolutePath() + " already exists."); return; } buildFolder.mkdirs(); if (buildFo... | @Test void createBuildFolderIfItDoesNotExist_createsTheFolderBecauseIfItDoesNotExist() { givenBuildFolderDoesNotExist(); fileSystemOperationsDao.createBuildFolderIfItDoesNotExist(buildIdentifier); expectBuildFolderExists(); } |
DiffViewerDao { public BuildDiffInfo loadBuildDiffInfo(final String baseBranchName, final String baseBuildName, final String comparisonName) { final File file = diffFiles.getBuildFile(baseBranchName, baseBuildName, comparisonName); return ScenarioDocuXMLFileUtil.unmarshal(BuildDiffInfo.class, file); } List<BuildDiffIn... | @Test void testWriteAndReadBuildDiffInfo() { final BuildDiffInfo buildDiffInfo = getBuildDiffInfo(COMPARISON_NAME); buildWriter.saveBuildDiffInfo(buildDiffInfo); final BuildDiffInfo actualBuildDiffInfo = dao.loadBuildDiffInfo(BASE_BRANCH_NAME, BASE_BUILD_NAME, COMPARISON_NAME); assertStructueDiffInfo(actualBuildDiffInf... |
DiffViewerDao { public UseCaseDiffInfo loadUseCaseDiffInfo(final String baseBranchName, final String baseBuildName, final String comparisonName, final String useCaseName) { final File file = diffFiles.getUseCaseFile(baseBranchName, baseBuildName, comparisonName, useCaseName); return ScenarioDocuXMLFileUtil.unmarshal(Us... | @Test void testWriteAndReadUseCaseDiffInfo() { final UseCaseDiffInfo useCaseDiffInfo = getUseCaseDiffInfo(USE_CASE_NAME); buildWriter.saveUseCaseDiffInfo(useCaseDiffInfo); final UseCaseDiffInfo actualUseCaseDiffInfo = dao.loadUseCaseDiffInfo(BASE_BRANCH_NAME, BASE_BUILD_NAME, COMPARISON_NAME, USE_CASE_NAME); assertStru... |
DiffViewerDao { public ScenarioDiffInfo loadScenarioDiffInfo(final String baseBranchName, final String baseBuildName, final String comparisonName, final String useCaseName, final String scenarioName) { final File file = diffFiles.getScenarioFile(baseBranchName, baseBuildName, comparisonName, useCaseName, scenarioName);... | @Test void testWriteAndReadScenarioDiffInfo() { final ScenarioDiffInfo scenarioDiffInfo = getScenarioDiffInfo(SCENARIO_NAME); buildWriter.saveScenarioDiffInfo(scenarioDiffInfo, USE_CASE_NAME); final ScenarioDiffInfo actualScenarioDiffInfo = dao.loadScenarioDiffInfo(BASE_BRANCH_NAME, BASE_BUILD_NAME, COMPARISON_NAME, US... |
DiffViewerDao { public StepDiffInfo loadStepDiffInfo(final String baseBranchName, final String baseBuildName, final String comparisonName, final String useCaseName, final String scenarioName, final int stepIndex) { final File file = diffFiles.getStepFile(baseBranchName, baseBuildName, comparisonName, useCaseName, scena... | @Test void testWriteAndReadStepDiffInfo() { final StepDiffInfo stepDiffInfo = getStepDiffInfo(STEP_INDEX); buildWriter.saveStepDiffInfo(USE_CASE_NAME, SCENARIO_NAME, stepDiffInfo); final StepDiffInfo actualStepDiffInfo = dao.loadStepDiffInfo(BASE_BRANCH_NAME, BASE_BUILD_NAME, COMPARISON_NAME, USE_CASE_NAME, SCENARIO_NA... |
DiffViewerDao { public List<UseCaseDiffInfo> loadUseCaseDiffInfos(final String baseBranchName, final String baseBuildName, final String comparisonName) { final List<File> files = diffFiles.getUseCaseFiles(baseBranchName, baseBuildName, comparisonName); return ScenarioDocuXMLFileUtil.unmarshalListOfFiles(UseCaseDiffInfo... | @Test void testWriteAndReadUseCaseDiffInfos() { for (int i = 0; i < NUMBER_OF_FILES; i++) { final UseCaseDiffInfo useCaseDiffInfo = getUseCaseDiffInfo(USE_CASE_NAME + i); buildWriter.saveUseCaseDiffInfo(useCaseDiffInfo); } final List<UseCaseDiffInfo> actualUseCaseDiffInfos = dao.loadUseCaseDiffInfos(BASE_BRANCH_NAME, B... |
DiffViewerDao { public List<ScenarioDiffInfo> loadScenarioDiffInfos(final String baseBranchName, final String baseBuildName, final String comparisonName, final String useCaseName) { final List<File> files = diffFiles.getScenarioFiles(baseBranchName, baseBuildName, comparisonName, useCaseName); return ScenarioDocuXMLFil... | @Test void testWriteAndReadScenarioDiffInfos() { for (int i = 0; i < NUMBER_OF_FILES; i++) { final ScenarioDiffInfo scenarioDiffInfo = getScenarioDiffInfo(SCENARIO_NAME + i); buildWriter.saveScenarioDiffInfo(scenarioDiffInfo, USE_CASE_NAME); } final List<ScenarioDiffInfo> actualScenarioDiffInfos = dao.loadScenarioDiffI... |
DiffViewerDao { public List<StepDiffInfo> loadStepDiffInfos(final String baseBranchName, final String baseBuildName, final String comparisonName, final String useCaseName, final String scenarioName) { final List<File> files = diffFiles.getStepFiles(baseBranchName, baseBuildName, comparisonName, useCaseName, scenarioNam... | @Test void testWriteAndReadStepDiffInfos() { for (int i = 0; i < NUMBER_OF_FILES; i++) { final StepDiffInfo stepDiffInfo = getStepDiffInfo(STEP_INDEX + i); buildWriter.saveStepDiffInfo(USE_CASE_NAME, SCENARIO_NAME, stepDiffInfo); } final List<StepDiffInfo> actualStepDiffInfos = dao.loadStepDiffInfos(BASE_BRANCH_NAME, B... |
FullTextSearch { public void indexUseCases(final UseCaseScenariosList useCaseScenariosList, final BuildIdentifier buildIdentifier) { if(!searchAdapter.isEngineRunning()) { return; } searchAdapter.setupNewBuild(buildIdentifier); searchAdapter.indexUseCases(useCaseScenariosList, buildIdentifier); LOGGER.info("Indexed use... | @Test void indexUseCaseWithoutRunningEngine() { givenNoRunningEngine(); fullTextSearch.indexUseCases(new UseCaseScenariosList(), new BuildIdentifier("testBranch", "testBuild")); thenJustReturns(); } |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.