From 49127ab77cdaabb867cecc6e8669b5fbdb8ccb50 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Magdalena=20Grodzi=C5=84ska?= Date: Fri, 10 Jan 2020 23:18:26 +0100 Subject: Add visual strategy test --- .../agent/modules/GossipGirlStrategyTest.java | 31 ++++++++++++++++++++++ 1 file changed, 31 insertions(+) create mode 100644 src/test/java/pl/edu/mimuw/cloudatlas/agent/modules/GossipGirlStrategyTest.java (limited to 'src') diff --git a/src/test/java/pl/edu/mimuw/cloudatlas/agent/modules/GossipGirlStrategyTest.java b/src/test/java/pl/edu/mimuw/cloudatlas/agent/modules/GossipGirlStrategyTest.java new file mode 100644 index 0000000..681483d --- /dev/null +++ b/src/test/java/pl/edu/mimuw/cloudatlas/agent/modules/GossipGirlStrategyTest.java @@ -0,0 +1,31 @@ +package pl.edu.mimuw.cloudatlas.agent.modules; + +import org.junit.Test; +import pl.edu.mimuw.cloudatlas.agent.modules.GossipGirlStrategies; +import pl.edu.mimuw.cloudatlas.model.PathName; + +import java.util.HashMap; + +public class GossipGirlStrategyTest { + + @Test + public void seeHowTheyWork() { + PathName fullPath = new PathName("/pl/mazowieckie/warszawa/ochota/mimuw"); + GossipGirlStrategies gossipGirlStrategies = new GossipGirlStrategies(fullPath); + int loopCount = 1000; + PathName selectedPath; + HashMap freqs = new HashMap<>(); + freqs.put(new PathName("/pl/mazowieckie/warszawa/ochota/mimuw"), 0); + freqs.put(new PathName("/pl/mazowieckie/warszawa/ochota"), 0); + freqs.put(new PathName("/pl/mazowieckie/warszawa"), 0); + freqs.put(new PathName("/pl/mazowieckie"), 0); + freqs.put(new PathName("/pl"), 0); + + for (int i = 0; i < loopCount; i++) { + selectedPath = + gossipGirlStrategies.selectStrategy(GossipGirlStrategies.ZoneSelectionStrategy.ROUND_ROBIN_EXP_FREQ); + freqs.put(selectedPath, freqs.get(selectedPath) + 1); + System.out.println(selectedPath); + } + } +} -- cgit v1.2.3