Skip to content

Commit 6c8344b

Browse files
committed
Revert "Json as a file"
This reverts commit 342ac23.
1 parent 342ac23 commit 6c8344b

2 files changed

Lines changed: 53 additions & 54 deletions

File tree

src/test/java/com/flagsmith/flagengine/unit/mappers/EngineMappersTest.java

Lines changed: 53 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
package com.flagsmith.flagengine.unit.mappers;
22

3+
import com.fasterxml.jackson.core.JsonProcessingException;
34
import com.flagsmith.MapperFactory;
45
import com.flagsmith.flagengine.EvaluationContext;
56
import com.flagsmith.flagengine.FeatureContext;
@@ -12,8 +13,6 @@
1213
import static org.junit.jupiter.api.Assertions.assertEquals;
1314
import static org.junit.jupiter.api.Assertions.assertInstanceOf;
1415

15-
import java.io.IOException;
16-
import java.io.InputStream;
1716
import java.util.List;
1817
import java.util.Map;
1918
import java.util.stream.Stream;
@@ -61,10 +60,59 @@ public void testMapContextAndIdentityDataToContext_returnsExpectedContext(
6160

6261
@Test
6362
public void testMapEnvironmentToContext_preservesMultivariateValueTypes()
64-
throws IOException {
65-
InputStream json = getClass().getResourceAsStream("multivariate_environment.json");
63+
throws JsonProcessingException {
64+
String environmentJson = "{\n"
65+
+ " \"api_key\": \"test-key\",\n"
66+
+ " \"name\": \"Test\",\n"
67+
+ " \"project\": {\n"
68+
+ " \"name\": \"Test project\",\n"
69+
+ " \"organisation\": {\n"
70+
+ " \"feature_analytics\": false,\n"
71+
+ " \"name\": \"Test Org\",\n"
72+
+ " \"id\": 1,\n"
73+
+ " \"persist_trait_data\": true,\n"
74+
+ " \"stop_serving_flags\": false\n"
75+
+ " },\n"
76+
+ " \"id\": 1,\n"
77+
+ " \"hide_disabled_flags\": false,\n"
78+
+ " \"segments\": []\n"
79+
+ " },\n"
80+
+ " \"segment_overrides\": [],\n"
81+
+ " \"id\": 1,\n"
82+
+ " \"feature_states\": [\n"
83+
+ " {\n"
84+
+ " \"feature_state_value\": true,\n"
85+
+ " \"django_id\": 1,\n"
86+
+ " \"featurestate_uuid\": \"40eb539d-3713-4720-bbd4-829dbef10d51\",\n"
87+
+ " \"feature\": { \"name\": \"mv_feature\", \"type\": \"MULTIVARIATE\", \"id\": 1 },\n"
88+
+ " \"enabled\": true,\n"
89+
+ " \"multivariate_feature_state_values\": [\n"
90+
+ " {\n"
91+
+ " \"id\": 1,\n"
92+
+ " \"multivariate_feature_option\": { \"value\": false },\n"
93+
+ " \"percentage_allocation\": 50.0,\n"
94+
+ " \"mv_fs_value_uuid\": \"808cba14-03ca-4835-a7f7-58387f01f87d\"\n"
95+
+ " },\n"
96+
+ " {\n"
97+
+ " \"id\": 2,\n"
98+
+ " \"multivariate_feature_option\": { \"value\": 42 },\n"
99+
+ " \"percentage_allocation\": 30.0,\n"
100+
+ " \"mv_fs_value_uuid\": \"918dbb25-14db-4946-b8a8-69488f02f98e\"\n"
101+
+ " },\n"
102+
+ " {\n"
103+
+ " \"id\": 3,\n"
104+
+ " \"multivariate_feature_option\": { \"value\": \"a string\" },\n"
105+
+ " \"percentage_allocation\": 20.0,\n"
106+
+ " \"mv_fs_value_uuid\": \"a29eca36-25dc-5057-c9b9-7a599f13g09f\"\n"
107+
+ " }\n"
108+
+ " ]\n"
109+
+ " }\n"
110+
+ " ],\n"
111+
+ " \"identity_overrides\": []\n"
112+
+ "}";
113+
66114
EnvironmentModel env = MapperFactory.getMapper()
67-
.readValue(json, EnvironmentModel.class);
115+
.readValue(environmentJson, EnvironmentModel.class);
68116

69117
EvaluationContext context = EngineMappers.mapEnvironmentToContext(env);
70118

src/test/resources/com/flagsmith/flagengine/unit/mappers/multivariate_environment.json

Lines changed: 0 additions & 49 deletions
This file was deleted.

0 commit comments

Comments
 (0)