Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[SDKS-7517] Add new property in Split dto #436

Merged
merged 1 commit into from
Sep 11, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion client/src/main/java/io/split/client/dtos/Split.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package io.split.client.dtos;

import java.util.HashSet;
import java.util.List;
import java.util.Map;

Expand All @@ -16,7 +17,7 @@ public class Split {
public Integer trafficAllocationSeed;
public int algo;
public Map<String, String> configurations;

public HashSet<String> sets;

@Override
public String toString() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,20 +8,18 @@
import io.split.telemetry.storage.InMemoryTelemetryStorage;
import io.split.telemetry.storage.TelemetryRuntimeProducer;
import io.split.telemetry.storage.TelemetryStorage;
import org.apache.hc.client5.http.classic.methods.HttpUriRequestBase;
import org.apache.hc.client5.http.impl.classic.CloseableHttpClient;
import org.apache.hc.client5.http.impl.classic.CloseableHttpResponse;
import org.apache.hc.client5.http.impl.classic.HttpClients;
import org.apache.hc.core5.http.*;
import org.apache.hc.core5.http.io.entity.StringEntity;
import org.apache.hc.core5.http.message.BasicClassicHttpResponse;
import org.hamcrest.Matchers;
import org.apache.hc.core5.http.ClassicHttpRequest;
import org.apache.hc.core5.http.ClassicHttpResponse;
import org.apache.hc.core5.http.Header;
import org.apache.hc.core5.http.HttpEntity;
import org.apache.hc.core5.http.HttpStatus;
import org.junit.Assert;
import org.junit.Test;
import org.mockito.ArgumentCaptor;
import org.mockito.Mockito;

import java.io.Closeable;
import java.io.IOException;
import java.io.StringBufferInputStream;
import java.lang.reflect.InvocationTargetException;
Expand All @@ -42,34 +40,31 @@ public void testDefaultURL() throws URISyntaxException {
CloseableHttpClient httpClient = HttpClients.custom().build();
Metrics.NoopMetrics metrics = new Metrics.NoopMetrics();
HttpSplitChangeFetcher fetcher = HttpSplitChangeFetcher.create(httpClient, rootTarget, TELEMETRY_STORAGE);
Assert.assertThat(fetcher.getTarget().toString(), Matchers.is(Matchers.equalTo("https://api.split.io/api/splitChanges")));
Assert.assertEquals("https://api.split.io/api/splitChanges", fetcher.getTarget().toString());
}

@Test
public void testCustomURLNoPathNoBackslash() throws URISyntaxException {
URI rootTarget = URI.create("https://kubernetesturl.com/split");
CloseableHttpClient httpClient = HttpClients.custom().build();
Metrics.NoopMetrics metrics = new Metrics.NoopMetrics();
HttpSplitChangeFetcher fetcher = HttpSplitChangeFetcher.create(httpClient, rootTarget, TELEMETRY_STORAGE);
Assert.assertThat(fetcher.getTarget().toString(), Matchers.is(Matchers.equalTo("https://kubernetesturl.com/split/api/splitChanges")));
Assert.assertEquals("https://kubernetesturl.com/split/api/splitChanges", fetcher.getTarget().toString());
}

@Test
public void testCustomURLAppendingPath() throws URISyntaxException {
URI rootTarget = URI.create("https://kubernetesturl.com/split/");
CloseableHttpClient httpClient = HttpClients.custom().build();
Metrics.NoopMetrics metrics = new Metrics.NoopMetrics();
HttpSplitChangeFetcher fetcher = HttpSplitChangeFetcher.create(httpClient, rootTarget, TELEMETRY_STORAGE);
Assert.assertThat(fetcher.getTarget().toString(), Matchers.is(Matchers.equalTo("https://kubernetesturl.com/split/api/splitChanges")));
Assert.assertEquals("https://kubernetesturl.com/split/api/splitChanges", fetcher.getTarget().toString());
}

@Test
public void testCustomURLAppendingPathNoBackslash() throws URISyntaxException {
URI rootTarget = URI.create("https://kubernetesturl.com/split");
CloseableHttpClient httpClient = HttpClients.custom().build();
Metrics.NoopMetrics metrics = new Metrics.NoopMetrics();
HttpSplitChangeFetcher fetcher = HttpSplitChangeFetcher.create(httpClient, rootTarget, TELEMETRY_STORAGE);
Assert.assertThat(fetcher.getTarget().toString(), Matchers.is(Matchers.equalTo("https://kubernetesturl.com/split/api/splitChanges")));
Assert.assertEquals("https://kubernetesturl.com/split/api/splitChanges", fetcher.getTarget().toString());
}

@Test
Expand All @@ -78,7 +73,6 @@ public void testFetcherWithSpecialCharacters() throws URISyntaxException, Invoca

CloseableHttpClient httpClientMock = TestHelper.mockHttpClient("split-change-special-characters.json", HttpStatus.SC_OK);

Metrics.NoopMetrics metrics = new Metrics.NoopMetrics();
HttpSplitChangeFetcher fetcher = HttpSplitChangeFetcher.create(httpClientMock, rootTarget, TELEMETRY_STORAGE);

SplitChange change = fetcher.fetch(1234567, new FetchOptions.Builder().cacheControlHeaders(true).build());
Expand All @@ -92,6 +86,7 @@ public void testFetcherWithSpecialCharacters() throws URISyntaxException, Invoca
Assert.assertEquals(2, configs.size());
Assert.assertEquals("{\"test\": \"blue\",\"grüne Straße\": 13}", configs.get("on"));
Assert.assertEquals("{\"test\": \"blue\",\"size\": 15}", configs.get("off"));
Assert.assertEquals(2, split.sets.size());
}

@Test
Expand Down Expand Up @@ -136,4 +131,4 @@ public void testRandomNumberGeneration() throws URISyntaxException {

Assert.assertTrue(seen.size() >= (total * 0.9999));
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
"killed": false,
"defaultTreatment": "of",
"changeNumber": 1491244291288,
"sets": [ "set1", "set2" ],
"algo": 2,
"configurations": {
"on": "{\"test\": \"blue\",\"grüne Straße\": 13}",
Expand Down