mirror of
https://github.com/eclipse-sailing-analytics/sailing-analytics.git
synced 2026-11-11 21:33:09 +00:00
bug3484 fixed test methods
This commit is contained in:
commit
d206e4d6f2
5 files changed
+90
-9
No files matched your search
@@ -0,0 +1,9 @@
|
||||
---
|
||||
VM version: Oct 9 2017 15:07:17 - 81_REL - optU - windows amd64 - 6 - bas2:294982 (mixed mode)
|
||||
|
||||
Time:2017-10-2509:39:58
|
||||
Pid: 12004
|
||||
Hostname: WDFN34222622A
|
||||
current dir: C:\Users\D070307\.git\.projects\git\java\com.sap.sse.test
|
||||
---
|
||||
: [10152] 09:39:58 ***ERROR (:0): Java assert: "null" in junit.framework.Assert.fail(Assert.java:47)
|
||||
@@ -0,0 +1,9 @@
|
||||
---
|
||||
VM version: Oct 9 2017 15:07:17 - 81_REL - optU - windows amd64 - 6 - bas2:294982 (mixed mode)
|
||||
|
||||
Time:2017-10-2509:48:59
|
||||
Pid: 16808
|
||||
Hostname: WDFN34222622A
|
||||
current dir: C:\Users\D070307\.git\.projects\git\java\com.sap.sse.test
|
||||
---
|
||||
: [14196] 09:48:59 ***ERROR (:0): Java assert: "" in org.junit.Assert.fail(Assert.java:91)
|
||||
@@ -0,0 +1,9 @@
|
||||
---
|
||||
VM version: Oct 9 2017 15:07:17 - 81_REL - optU - windows amd64 - 6 - bas2:294982 (mixed mode)
|
||||
|
||||
Time:2017-10-2509:46:48
|
||||
Pid: 9096
|
||||
Hostname: WDFN34222622A
|
||||
current dir: C:\Users\D070307\.git\.projects\git\java\com.sap.sse.test
|
||||
---
|
||||
: [8248] 09:46:48 ***ERROR (:0): Java assert: "null" in junit.framework.Assert.fail(Assert.java:47)
|
||||
@@ -1,6 +1,11 @@
|
||||
package com.sap.see.pairinglist.test;
|
||||
|
||||
import java.security.acl.Group;
|
||||
import static org.junit.Assert.assertArrayEquals;
|
||||
import static org.junit.Assert.fail;
|
||||
import static org.junit.Assert.assertNotNull;
|
||||
|
||||
|
||||
|
||||
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
@@ -26,14 +31,52 @@ public class PairingListTest<Flight, Group, Competitor> {
|
||||
public void testPairingListCreation() {
|
||||
int[][] plTemplate = this.aImpl.getPairingListTemplate();
|
||||
|
||||
Assert.assertNotNull(plTemplate);
|
||||
assertNotNull(plTemplate);
|
||||
for(int[] i:plTemplate){
|
||||
for (int z: i){
|
||||
if(z<=0) Assert.fail("Problem in .create!");
|
||||
if(z<=0) fail("Problem in .create!");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
public void testArrayCopy() {
|
||||
|
||||
int[][] flightColumn={
|
||||
{1,2,3,4,5,6},
|
||||
{7,8,9,10,11,12},
|
||||
{13,14,15,16,17,18}
|
||||
};
|
||||
|
||||
int[][][] associationRow=new int[3][5][18];
|
||||
int[][] currentAssociations={
|
||||
{1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18},
|
||||
{0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},
|
||||
{0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},
|
||||
{0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},
|
||||
{0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},
|
||||
{0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},
|
||||
{1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18},
|
||||
{0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},
|
||||
{0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},
|
||||
{0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},
|
||||
{0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},
|
||||
{0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},
|
||||
{0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},
|
||||
{0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},
|
||||
{0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},
|
||||
{0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},
|
||||
{0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},
|
||||
{0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},
|
||||
};
|
||||
|
||||
|
||||
this.aImpl.copyInto3rdDimension(18, currentAssociations, associationRow, flightColumn, 1,0);
|
||||
assertArrayEquals(currentAssociations[0],associationRow[0][0]);
|
||||
this.aImpl.copyInto3rdDimension(18, currentAssociations, associationRow, flightColumn, 1,1);
|
||||
assertArrayEquals(currentAssociations[6],associationRow[1][0]);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testTeamAssociationCreation() {
|
||||
int[][] plTemplate = this.aImpl.getPairingListTemplate();
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
package com.sap.sse.pairinglist.impl;
|
||||
|
||||
import java.util.Arrays;
|
||||
|
||||
|
||||
import com.sap.sse.pairinglist.PairingFrameProvider;
|
||||
import com.sap.sse.pairinglist.PairingList;
|
||||
@@ -43,13 +43,17 @@ public class PairingListTemplateImpl<Flight,Group,Competitor> implements Pairing
|
||||
public int[][] getPairingListTemplate(){
|
||||
return pairingListTemplate;
|
||||
}
|
||||
|
||||
public int[][] create(int flights, int groups, int competitors) {
|
||||
return this.create(flights, groups, competitors, 1000000);
|
||||
}
|
||||
|
||||
public int[][] create(int flights, int groups, int competitors){
|
||||
public int[][] create(int flights, int groups, int competitors, int iterationCount){
|
||||
int[][] bestPLT = new int[groups][competitors / groups];
|
||||
|
||||
double bestDev = Double.POSITIVE_INFINITY;
|
||||
|
||||
for (int iteration = 0; iteration < 1000000; iteration++) {
|
||||
for (int iteration = 0; iteration < iterationCount; iteration++) {
|
||||
int[][] currentAssociations = new int[competitors][competitors];
|
||||
int[][] currentPLT = new int[groups * flights][competitors / groups];
|
||||
int[][][] associationRow = new int[groups][(competitors / groups) - 1][competitors];
|
||||
@@ -63,7 +67,7 @@ public class PairingListTemplateImpl<Flight,Group,Competitor> implements Pairing
|
||||
for (int zGroups = 1; zGroups <= (competitors / groups) - 1; zGroups++) {
|
||||
int associationSum = Integer.MAX_VALUE;
|
||||
associationHigh[0] = flights + 1;
|
||||
System.arraycopy(currentAssociations[flightColumn[0][zGroups - 1] - 1], 0, associationRow[0][zGroups - 1], 0, competitors);
|
||||
associationRow=copyInto3rdDimension(competitors, currentAssociations, associationRow, flightColumn, zGroups,0);
|
||||
|
||||
for (int comp = 1; comp <= competitors; comp++) {
|
||||
if ((sum(associationRow, 0, comp - 1) <= associationSum) &&
|
||||
@@ -87,7 +91,7 @@ public class PairingListTemplateImpl<Flight,Group,Competitor> implements Pairing
|
||||
for (int zGroups = 1; zGroups < (competitors / groups); zGroups++) {
|
||||
int associationSum = Integer.MAX_VALUE;
|
||||
associationHigh[fleets] = flights + 1;
|
||||
System.arraycopy(currentAssociations[flightColumn[fleets][zGroups - 1] - 1], 0, associationRow[fleets][zGroups - 1], 0, competitors);
|
||||
associationRow=copyInto3rdDimension(competitors, currentAssociations, associationRow, flightColumn, zGroups,fleets);
|
||||
|
||||
for (int comp = 1; comp <= competitors; comp++) {
|
||||
if ((sum(associationRow, fleets, comp - 1) <= associationSum) &&
|
||||
@@ -131,8 +135,15 @@ public class PairingListTemplateImpl<Flight,Group,Competitor> implements Pairing
|
||||
}
|
||||
|
||||
this.standardDev = bestDev;
|
||||
this.pairingListTemplate=bestPLT;
|
||||
return bestPLT;
|
||||
}
|
||||
|
||||
public int[][][] copyInto3rdDimension(int competitors, int[][] currentAssociations, int[][][] associationRow,
|
||||
int[][] flightColumn, int zGroups,int fleet) {
|
||||
System.arraycopy(currentAssociations[flightColumn[fleet][zGroups - 1] -1], 0, associationRow[fleet][zGroups -1], 0, competitors);
|
||||
return associationRow;
|
||||
}
|
||||
|
||||
private boolean contains(int[][] flightColumn, int comp) {
|
||||
for (int i = 0; i < flightColumn.length; i++) {
|
||||
|
||||
Reference in new issue
Block a user