mirror of
https://github.com/eclipse-sailing-analytics/sailing-analytics.git
synced 2026-11-14 06:18:12 +00:00
Merge branch 'bug3484' of ssh://sapsailing.com/home/trac/git into bug3484
This commit is contained in:
commit
20b63ba9b0
3 files changed
+82
-46
No files matched your search
@@ -4,10 +4,8 @@ import com.sap.sse.pairinglist.AbstractPairingFrameProvider;
|
||||
|
||||
/**
|
||||
* Instances of this class are used for test generations of PairingLists
|
||||
* @author D070264
|
||||
*
|
||||
*/
|
||||
|
||||
public class PairingFrameProviderTest extends AbstractPairingFrameProvider {
|
||||
|
||||
private int flights, groups, competitors;
|
||||
|
||||
+30
-3
@@ -3,8 +3,6 @@ package com.sap.see.pairinglist.test;
|
||||
import static org.junit.Assert.assertNotNull;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.stream.IntStream;
|
||||
|
||||
import org.junit.Before;
|
||||
@@ -23,7 +21,23 @@ public class PairingListTemplateFactoryTest {
|
||||
public void testSetup() {
|
||||
factoryImpl = new PairingListTemplateFactoryImpl();
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
public void testPairingListCreationForValidValues() {
|
||||
final int flights = 15;
|
||||
final int groups = 3;
|
||||
final int competitors = 18;
|
||||
|
||||
int[][] plTemplate = factoryImpl.getOrCreatePairingListTemplate(new PairingFrameProviderTest(flights, groups, competitors)).
|
||||
getPairingListTemplate();
|
||||
|
||||
Assert.assertNotNull(plTemplate);
|
||||
for(int[] i:plTemplate){
|
||||
for (int z: i){
|
||||
if(z<=0) Assert.fail("Values of Pairing List Template must not be 0!");
|
||||
}
|
||||
}
|
||||
}
|
||||
/**
|
||||
* Checks if the Factory returns the same PairingListTemplate if one exists
|
||||
*/
|
||||
@@ -61,6 +75,19 @@ public class PairingListTemplateFactoryTest {
|
||||
*/
|
||||
}
|
||||
|
||||
@Test
|
||||
public void qualityCheck(){
|
||||
PairingListTemplate template = factoryImpl.getOrCreatePairingListTemplate(new PairingFrameProviderTest(15, 3, 18));
|
||||
if(template.getQuality()>=0.7) {
|
||||
Assert.fail("Quality of Pairinglist is worse than usual!");
|
||||
}
|
||||
|
||||
PairingListTemplate template2 = factoryImpl.getOrCreatePairingListTemplate(new PairingFrameProviderTest(10, 3, 30));
|
||||
if(template2.getQuality()>=1.2) {
|
||||
Assert.fail("Quality of Pairinglist is worse than usual!");
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if the competitors of all single flights are divided up correctly (e.g. multiple competitors, absenced competitors)
|
||||
* flights, groups and competitors can be variable.
|
||||
|
||||
+52
-41
@@ -1,7 +1,6 @@
|
||||
package com.sap.see.pairinglist.test;
|
||||
|
||||
import static org.junit.Assert.assertArrayEquals;
|
||||
|
||||
import org.junit.Test;
|
||||
|
||||
import com.sap.sse.pairinglist.impl.PairingListTemplateFactoryImpl;
|
||||
@@ -11,30 +10,13 @@ import junit.framework.Assert;
|
||||
|
||||
public class PairingListTemplateTest extends PairingListTemplateImpl{
|
||||
|
||||
|
||||
public PairingListTemplateTest() {
|
||||
super(new PairingFrameProviderTest(15, 3, 18));
|
||||
}
|
||||
|
||||
PairingListTemplateFactoryImpl factory;
|
||||
|
||||
@Test
|
||||
public void testPairingListCreationForValidValues() {
|
||||
final int flights = 15;
|
||||
final int groups = 3;
|
||||
final int competitors = 18;
|
||||
|
||||
factory = new PairingListTemplateFactoryImpl();
|
||||
|
||||
int[][] plTemplate = factory.getOrCreatePairingListTemplate(new PairingFrameProviderTest(flights, groups, competitors)).
|
||||
getPairingListTemplate();
|
||||
|
||||
Assert.assertNotNull(plTemplate);
|
||||
for(int[] i:plTemplate){
|
||||
for (int z: i){
|
||||
if(z<=0) Assert.fail("Values of Pairing List Template must not be 0!");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testArrayCopy() {
|
||||
@@ -98,19 +80,6 @@ public class PairingListTemplateTest extends PairingListTemplateImpl{
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
public void qualityCheck(){
|
||||
this.createPairingListTemplate(15, 3, 18);
|
||||
if(getQuality()>=0.7) {
|
||||
Assert.fail("Quality of Pairinglist is worse than usual!");
|
||||
}
|
||||
|
||||
this.createPairingListTemplate(10, 3, 30);
|
||||
if(getQuality()>=1.2) {
|
||||
Assert.fail("Quality of Pairinglist is worse than usual!");
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testAverageTimeForSingleCase(){
|
||||
final int tests = 5;
|
||||
@@ -134,15 +103,57 @@ public class PairingListTemplateTest extends PairingListTemplateImpl{
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testAssignmentQuality(){
|
||||
this.createPairingListTemplate(15, 3, 18);
|
||||
if(calcStandardDev(getAssignmentAssociations(this.getPairingListTemplate(), new int[18][6]))>=1.5) {
|
||||
Assert.fail("Quality of Boat Assignments is worse than usual!");
|
||||
}
|
||||
this.createPairingListTemplate(10, 3, 30);
|
||||
if(calcStandardDev(getAssignmentAssociations(this.getPairingListTemplate(), new int[30][10]))>=0.6) {
|
||||
Assert.fail("Quality of Boat Assignments is worse than usual!");
|
||||
public void testStandardDevCalc(){
|
||||
int[][] givenPairingList={
|
||||
{18,15,17,14,16,8},
|
||||
{13,1,10,9,12,11},
|
||||
{3,5,2,4,6,7},
|
||||
{18,13,17,4,12,7},
|
||||
{11,15,16,6,1,5},
|
||||
{14,10,8,2,9,3},
|
||||
{15,18,11,2,13,3},
|
||||
{17,10,14,6,7,1},
|
||||
{8,4,16,5,9,12},
|
||||
{7,3,16,1,9,18},
|
||||
{12,15,10,17,5,2},
|
||||
{6,11,4,13,8,14},
|
||||
{16,11,4,17,3,10},
|
||||
{12,2,6,8,18,1},
|
||||
{7,13,5,15,14,9},
|
||||
{1,3,12,15,14,4},
|
||||
{9,17,6,16,13,2},
|
||||
{5,18,7,11,10,8},
|
||||
{16,2,7,11,14,12},
|
||||
{3,1,5,8,17,13},
|
||||
{6,9,4,10,15,18},
|
||||
{14,16,13,10,5,18},
|
||||
{11,2,1,9,4,17},
|
||||
{8,12,3,7,6,15},
|
||||
{10,13,8,7,16,15},
|
||||
{2,14,18,4,5,1},
|
||||
{6,17,9,12,11,3},
|
||||
{14,17,18,12,11,5},
|
||||
{15,16,13,1,4,2},
|
||||
{8,6,3,10,7,9},
|
||||
{16,6,12,18,2,10},
|
||||
{1,8,15,14,17,9},
|
||||
{5,7,13,3,4,11},
|
||||
{9,7,18,2,15,11},
|
||||
{13,3,14,1,12,10},
|
||||
{17,4,5,16,8,6},
|
||||
{17,4,12,15,10,7},
|
||||
{3,1,11,18,8,16},
|
||||
{2,9,6,5,13,14},
|
||||
{18,9,17,5,3,15},
|
||||
{12,7,1,13,16,6},
|
||||
{10,14,2,8,11,4},
|
||||
{7,14,2,17,3,16},
|
||||
{15,5,10,11,1,6},
|
||||
{4,12,8,9,18,13}
|
||||
};
|
||||
System.out.println(calcStandardDev(getAssociationsFromPairingList(givenPairingList, new int[18][18])));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user