Skip to content

Commit

Permalink
revert + test on java 11
Browse files Browse the repository at this point in the history
  • Loading branch information
stas-panasiuk committed Feb 12, 2024
1 parent d8003db commit cf0b30f
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 31 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/build_and_test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ jobs:
- name: Set up JDK 8
uses: actions/setup-java@v3
with:
java-version: '8'
java-version: '11'
distribution: 'temurin'
# cache: maven
- name: Build with Maven
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,10 +48,9 @@

@EnableRuleMigrationSupport
public class RestFunctionsIntegrationTest {
public static final Context CONTEXT = new Context.Builder().build();
@Rule
public TemporaryFolder tempDir = new TemporaryFolder();

private static final int MOCK_PROXY_PORT = 1080;

// Use plain Java API, because we can't use the @Rule and the JUnit5 extension isn't released.
Expand Down Expand Up @@ -85,17 +84,11 @@ public void setup() throws Exception {
FileUtils.writeStringToFile(proxyBasicAuthPasswordFile, proxyAuthPassword, StandardCharsets.UTF_8);

// By default, the mock server expects a GET request with the path set to /get
// System.out.println("TESTING MOCK_PROXY_PORT: " + MOCK_PROXY_PORT);
baseUri = String.format("http://localhost:%d", MOCK_PROXY_PORT);
// System.out.println("TESTING baseUri: " + baseUri);
getUri = baseUri + "/get";
// System.out.println("TESTING getUri: " + getUri);
emptyGetUri = baseUri + "/get/empty";
// System.out.println("TESTING emptyGetUri: " + emptyGetUri);
postUri = baseUri + "/post";
// System.out.println("TESTING postUri: " + postUri);
emptyPostUri = baseUri + "/post/empty";
// System.out.println("TESTING emptyPostUri: " + emptyPostUri);
mockServerClient.when(
request()
.withMethod("GET")
Expand All @@ -122,7 +115,6 @@ public void setup() throws Exception {
.withPath("/post/empty"))
.respond(response()
.withStatusCode(404));
assertNotNull(CONTEXT);
}

@AfterEach
Expand All @@ -136,7 +128,6 @@ public void teardown() {
@Test
@SuppressWarnings("unchecked")
public void restGetShouldSucceed() {
assertEquals(context, CONTEXT);
Map<String, Object> actual = (Map<String, Object>) run(String.format("REST_GET('%s')", getUri), context);

assertEquals(1, actual.size());
Expand All @@ -158,7 +149,6 @@ public void restGetShouldSucceedWithQueryParameters() {
.withBody("{\"get.with.query.parameters\":\"success\"}"));

Map<String, Object> variables = ImmutableMap.of("queryParameters", ImmutableMap.of("key", "value"));
assertEquals(context, CONTEXT);
Map<String, Object> actual = (Map<String, Object>) run(String.format("REST_GET('%s', {}, queryParameters)",
baseUri + "/get/with/query/parameters"), variables, context);

Expand All @@ -184,7 +174,6 @@ public void restGetShouldSucceedWithProxy() {
put(PROXY_PORT, MOCK_PROXY_PORT);
}});

assertEquals(context, CONTEXT);
Map<String, Object> actual = (Map<String, Object>) run(String.format("REST_GET('%s')", getUri), context);

assertEquals(1, actual.size());
Expand All @@ -203,7 +192,6 @@ public void restGetShouldHandleErrorStatusCode() {
.respond(response()
.withStatusCode(403));

assertEquals(context, CONTEXT);
assertNull(run(String.format("REST_GET('%s')", getUri), context));
}

Expand All @@ -221,7 +209,6 @@ public void restGetShouldHandleErrorStatusCode() {
*/
@Test
public void restGetShouldReturnEmptyContentOverride() {
assertEquals(context, CONTEXT);
assertEquals("function config override", run(String.format("REST_GET('%s', %s)", emptyGetUri, emptyContentOverride), context));
}

Expand All @@ -245,7 +232,6 @@ public void restGetShouldReturnErrorValueOverride() {
.respond(response()
.withStatusCode(500));

assertEquals(context, CONTEXT);
Object result = run(String.format("REST_GET('%s', %s)", getUri, errorValueOverride), context);
assertEquals("error message" , result);
}
Expand Down Expand Up @@ -274,7 +260,6 @@ public void restGetShouldTimeout() {

context.addCapability(Context.Capabilities.GLOBAL_CONFIG, () -> globalConfig);

assertEquals(context, CONTEXT);
Map<String, Object> actual = (Map<String, Object>) run(String.format("REST_GET('%s')", uri), context);
assertNull(actual);
}
Expand Down Expand Up @@ -303,7 +288,6 @@ public void restGetShouldTimeoutWithSuppliedTimeout() {
.withBody("{\"get\":\"success\"}"));

String expression = String.format("REST_GET('%s', %s)", uri, timeoutConfig);
assertEquals(context, CONTEXT);
Map<String, Object> actual = (Map<String, Object>) run(expression, context);
assertNull(actual);
}
Expand All @@ -313,7 +297,6 @@ public void restGetShouldTimeoutWithSuppliedTimeout() {
*/
@Test
public void restGetShouldHandleURISyntaxException() {
assertEquals(context, CONTEXT);
ParseException e = assertThrows(ParseException.class, () -> run("REST_GET('some invalid uri')", context));
assertEquals("Unable to parse REST_GET('some invalid uri'): Unable to parse: REST_GET('some invalid uri') due to: Illegal character in path at index 4: some invalid uri", e.getMessage());
}
Expand All @@ -325,7 +308,6 @@ public void restGetShouldHandleURISyntaxException() {
*/
@Test
public void restGetShouldThrownExceptionOnMissingParameter() {
assertEquals(context, CONTEXT);
ParseException e = assertThrows(ParseException.class, () -> run("REST_GET()", context));
assertEquals("Unable to parse REST_GET(): Unable to parse: REST_GET() due to: Expected at least 1 argument(s), found 0", e.getMessage());
}
Expand All @@ -343,7 +325,6 @@ public void restGetShouldUseGlobalConfig() {
}};
context.addCapability(Context.Capabilities.GLOBAL_CONFIG, () -> globalConfig);

assertEquals(context, CONTEXT);
assertEquals("global config override", run(String.format("REST_GET('%s')", emptyGetUri), context));
}

Expand All @@ -363,7 +344,6 @@ public void restGetShouldUseGetConfig() {
}};
context.addCapability(Context.Capabilities.GLOBAL_CONFIG, () -> globalConfig);

assertEquals(context, CONTEXT);
assertEquals("get config override", run(String.format("REST_GET('%s')", emptyGetUri), context));
}

Expand All @@ -383,7 +363,6 @@ public void restGetShouldUseFunctionConfig() {
}};
context.addCapability(Context.Capabilities.GLOBAL_CONFIG, () -> globalConfig);

assertEquals(context, CONTEXT);
assertEquals("function config override", run(String.format("REST_GET('%s', %s)", emptyGetUri, emptyContentOverride), context));
}

Expand All @@ -393,7 +372,6 @@ public void restGetShouldUseFunctionConfig() {
@Test
@SuppressWarnings("unchecked")
public void restPostShouldSucceed() {
assertEquals(context, CONTEXT);
Map<String, Object> actual = (Map<String, Object>) run(String.format("REST_POST('%s', '{\"key\":\"value\"}')", postUri), context);

assertEquals(1, actual.size());
Expand All @@ -415,7 +393,6 @@ public void restPostShouldSucceedWithQueryParameters() {
.withBody("{\"post.with.query.parameters\":\"success\"}"));

Map<String, Object> variables = ImmutableMap.of("queryParameters", ImmutableMap.of("key", "value"));
assertEquals(context, CONTEXT);
Map<String, Object> actual = (Map<String, Object>) run(String.format("REST_POST('%s', {}, {}, queryParameters)",
baseUri + "/post/with/query/parameters"), variables, context);

Expand All @@ -430,7 +407,6 @@ public void restPostShouldSucceedWithQueryParameters() {
@SuppressWarnings("unchecked")
public void restPostShouldSucceedWithStellarMap() {
Map<String, Object> variables = ImmutableMap.of("body", ImmutableMap.of("key", "value"));
assertEquals(context, CONTEXT);
Map<String, Object> actual = (Map<String, Object>) run(String.format("REST_POST('%s', body)", postUri), variables, context);

assertEquals(1, actual.size());
Expand All @@ -442,7 +418,6 @@ public void restPostShouldSucceedWithStellarMap() {
*/
@Test
public void restPostShouldHandleURISyntaxException() {
assertEquals(context, CONTEXT);
ParseException e = assertThrows(ParseException.class, () -> run("REST_POST('some invalid uri', {})", context));
assertEquals("Unable to parse REST_POST('some invalid uri', {}): Unable to parse: REST_POST('some invalid uri', {}) due to: Illegal character in path at index 4: some invalid uri", e.getMessage());
}
Expand All @@ -452,7 +427,6 @@ public void restPostShouldHandleURISyntaxException() {
*/
@Test
public void restPostShouldThrowExceptionOnMalformedJson() {
assertEquals(context, CONTEXT);
ParseException e = assertThrows(ParseException.class, () -> run(String.format("REST_POST('%s', 'malformed json')", postUri), context));
assertEquals(
String.format(
Expand All @@ -476,7 +450,6 @@ public void restPostShouldUseGlobalConfig() {
}};
context.addCapability(Context.Capabilities.GLOBAL_CONFIG, () -> globalConfig);

assertEquals(context, CONTEXT);
assertEquals("global config override", run(String.format("REST_POST('%s', {})", emptyGetUri), context));
}

Expand All @@ -496,7 +469,6 @@ public void restPostShouldUseGetConfig() {
}};
context.addCapability(Context.Capabilities.GLOBAL_CONFIG, () -> globalConfig);

assertEquals(context, CONTEXT);
assertEquals("post config override", run(String.format("REST_POST('%s', {})", emptyGetUri), context));
}

Expand All @@ -516,7 +488,6 @@ public void restPostShouldUseFunctionConfig() {
}};
context.addCapability(Context.Capabilities.GLOBAL_CONFIG, () -> globalConfig);

assertEquals(context, CONTEXT);
assertEquals("function config override", run(String.format("REST_POST('%s', {}, %s)", emptyGetUri, emptyContentOverride), context));
}

Expand Down

0 comments on commit cf0b30f

Please sign in to comment.