+ test cases

#SPM-23: add work 20m testing
This commit is contained in:
Johannes Theiner 2019-05-13 16:49:17 +02:00
parent 221c2aea92
commit 20f13467c6
2 changed files with 25 additions and 5 deletions

View File

@ -23,10 +23,15 @@ import java.util.Map;
public class ShoppingCart implements Analysis<Map<List<String>, List<String>>> {
private Instances instances;
private Map<List<String>, List<String>> result;
@Override
public Map<List<String>, List<String>> getResult() {
Map<List<String>, List<String>> result = new HashMap<>();
if(result != null) {
return result;
}
result = new HashMap<>();
Apriori model = new Apriori();

View File

@ -4,13 +4,17 @@ import org.junit.jupiter.api.Test;
import java.io.File;
import java.net.URL;
import java.util.Arrays;
import java.util.Collections;
import java.util.List;
import java.util.Map;
import static org.junit.jupiter.api.Assertions.assertEquals;
/**
* Test class for shopping-cart analysis.
*
* @author Julian Hinxlage
* @author Johannes Theiner
* @version 0.1
*/
class ShoppingCartTest {
@ -23,7 +27,10 @@ class ShoppingCartTest {
ShoppingCart cart = new ShoppingCart(new File(url.getFile()));
Map<List<String>, List<String>> result = cart.getResult();
System.out.println(result);
assertEquals(Collections.singletonList("Eisenwaren"), result.get(Arrays.asList("Handwerkzeuge", "Schliesstechnik")));
assertEquals(Collections.singletonList("Elektromaterial"), result.get(Collections.singletonList("Leuchten")));
assertEquals(Collections.singletonList("Eisenwaren"), result.get(Arrays.asList("Schliesstechnik", "Renovierung")));
assertEquals(Collections.singletonList("Eisenwaren"), result.get(Arrays.asList("Handwerkzeuge", "Schliesstechnik", "Baustoffe")));
}
@Test
@ -34,7 +41,11 @@ class ShoppingCartTest {
ShoppingCart cart = new ShoppingCart(new File(url.getFile()));
Map<List<String>, List<String>> result = cart.getResult();
System.out.println(result);
assertEquals(Collections.singletonList("Eisenwaren"), result.get(Arrays.asList("Handwerkzeuge", "Schliesstechnik", "Elektromaterial")));
assertEquals(Collections.singletonList("Elektromaterial"), result.get(Arrays.asList("Renovierung", "Leuchten")));
assertEquals(Collections.singletonList("Sanitaermaterial"), result.get(Arrays.asList("Fliesen", "Armaturen")));
assertEquals(Collections.singletonList("Eisenwaren"), result.get(Arrays.asList("Handwerkzeuge", "Schliesstechnik", "Renovierung")));
}
@Test
@ -45,7 +56,11 @@ class ShoppingCartTest {
ShoppingCart cart = new ShoppingCart(new File(url.getFile()));
Map<List<String>, List<String>> result = cart.getResult();
System.out.println(result);
assertEquals(Collections.singletonList("Eisenwaren"), result.get(Arrays.asList("Handwerkzeuge", "Schliesstechnik", "Elektromaterial")));
assertEquals(Collections.singletonList("Sanitaermaterial"), result.get(Arrays.asList("Eisenwaren", "Fliesen", "Armaturen")));
assertEquals(Collections.singletonList("Elektromaterial"), result.get(Arrays.asList("Renovierung", "Leuchten")));
assertEquals(Collections.singletonList("Eisenwaren"), result.get(Arrays.asList("Handwerkzeuge", "Schliesstechnik", "Baustoffe")));
}
}