Skip to content

Commit

Permalink
fix: use gradle artifact from MAVEN_HOME
Browse files Browse the repository at this point in the history
  • Loading branch information
chriswk committed Nov 30, 2023
1 parent 35d6f8a commit 71ed14f
Show file tree
Hide file tree
Showing 12 changed files with 447 additions and 435 deletions.
6 changes: 2 additions & 4 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -56,11 +56,9 @@

<dependencies>
<dependency>
<artifactId>unleash-engine</artifactId>
<artifactId>yggdrasil-engine</artifactId>
<groupId>io.getunleash</groupId>
<scope>system</scope>
<version>0.0.1-SNAPSHOT</version>
<systemPath>${project.basedir}/unleash-engine-all.jar</systemPath>
<version>0.1.0-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>com.google.code.gson</groupId>
Expand Down
2 changes: 0 additions & 2 deletions src/main/java/io/getunleash/strategy/Strategy.java
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package io.getunleash.strategy;

import io.getunleash.UnleashContext;

import java.util.Map;

public interface Strategy {
Expand All @@ -13,5 +12,4 @@ public interface Strategy {
default boolean isEnabled(Map<String, String> parameters, UnleashContext unleashContext) {
return isEnabled(parameters);
}

}
1 change: 0 additions & 1 deletion src/main/java/io/getunleash/strategy/StrategyUtils.java
Original file line number Diff line number Diff line change
Expand Up @@ -18,5 +18,4 @@ public static int getNormalizedNumber(String identifier, String groupId, long se
long hash = Murmur3.hash_x86_32(value, value.length, seed);
return (int) (hash % ONE_HUNDRED) + 1;
}

}
Original file line number Diff line number Diff line change
@@ -1,24 +1,23 @@
package io.getunleash.strategy;

import static org.junit.jupiter.api.Assertions.assertFalse;
import static org.junit.jupiter.api.Assertions.assertTrue;
import static org.mockito.Mockito.mock;

import com.google.common.collect.ImmutableList;
import io.getunleash.ActivationStrategy;
import io.getunleash.DefaultUnleash;
import io.getunleash.FeatureToggle;
import io.getunleash.repository.UnleashEngineStateHandler;
import io.getunleash.util.UnleashConfig;
import io.getunleash.util.UnleashScheduledExecutor;
import org.junit.jupiter.api.AfterEach;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;

import java.net.InetAddress;
import java.net.UnknownHostException;
import java.util.HashMap;
import java.util.Map;

import static org.junit.jupiter.api.Assertions.assertFalse;
import static org.junit.jupiter.api.Assertions.assertTrue;
import static org.mockito.Mockito.mock;
import org.junit.jupiter.api.AfterEach;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;

public class ApplicationHostnameStrategyTest {

Expand All @@ -28,13 +27,12 @@ public class ApplicationHostnameStrategyTest {
@BeforeEach
void init() {
UnleashConfig config =
new UnleashConfig.Builder()
.appName("test")
.unleashAPI("http://localhost:4242/api/")
.environment("test")
.scheduledExecutor(mock(UnleashScheduledExecutor.class))
.build();

new UnleashConfig.Builder()
.appName("test")
.unleashAPI("http://localhost:4242/api/")
.environment("test")
.scheduledExecutor(mock(UnleashScheduledExecutor.class))
.build();

engine = new DefaultUnleash(config);
stateHandler = new UnleashEngineStateHandler(engine);
Expand All @@ -50,11 +48,11 @@ public void should_be_disabled_if_no_HostNames_in_params() {
Map<String, String> params = new HashMap<>();
params.put("hostNames", null);

stateHandler.setState(new FeatureToggle(
"test",
true,
ImmutableList.of(new ActivationStrategy("applicationHostname", params))
));
stateHandler.setState(
new FeatureToggle(
"test",
true,
ImmutableList.of(new ActivationStrategy("applicationHostname", params))));
assertFalse(engine.isEnabled("test"));
}

Expand All @@ -63,11 +61,11 @@ public void should_be_disabled_if_hostname_not_in_list() {
Map<String, String> params = new HashMap<>();
params.put("hostNames", "MegaHost,MiniHost, happyHost");

stateHandler.setState(new FeatureToggle(
"test",
true,
ImmutableList.of(new ActivationStrategy("applicationHostname", params))
));
stateHandler.setState(
new FeatureToggle(
"test",
true,
ImmutableList.of(new ActivationStrategy("applicationHostname", params))));
assertFalse(engine.isEnabled("test"));
}

Expand All @@ -79,11 +77,11 @@ public void so_close_but_no_cigar() {
Map<String, String> params = new HashMap<>();

params.put("hostNames", "MegaHost, MiniHost, SuperhostOne");
stateHandler.setState(new FeatureToggle(
"test",
true,
ImmutableList.of(new ActivationStrategy("applicationHostname", params))
));
stateHandler.setState(
new FeatureToggle(
"test",
true,
ImmutableList.of(new ActivationStrategy("applicationHostname", params))));
assertFalse(engine.isEnabled("test"));
}

Expand All @@ -94,21 +92,22 @@ public void should_be_enabled_for_InetAddress() throws UnknownHostException {

Map<String, String> params = new HashMap<>();
params.put("hostNames", "MegaHost," + hostName + ",MiniHost, happyHost");
stateHandler.setState(new FeatureToggle(
"test",
true,
ImmutableList.of(new ActivationStrategy("applicationHostname", params))
));
stateHandler.setState(
new FeatureToggle(
"test",
true,
ImmutableList.of(new ActivationStrategy("applicationHostname", params))));
assertTrue(engine.isEnabled("test"));
}

@Test
public void null_test() {
stateHandler.setState(new FeatureToggle(
"test",
true,
ImmutableList.of(new ActivationStrategy("applicationHostname", new HashMap<>()))
));
stateHandler.setState(
new FeatureToggle(
"test",
true,
ImmutableList.of(
new ActivationStrategy("applicationHostname", new HashMap<>()))));
assertFalse(engine.isEnabled("test"));
}
}
Loading

0 comments on commit 71ed14f

Please sign in to comment.