Skip to content

Commit

Permalink
jira: remove okhttp2 dependency (#171)
Browse files Browse the repository at this point in the history
  • Loading branch information
benbroadaway authored Aug 19, 2024
1 parent 046dcc9 commit 9247677
Show file tree
Hide file tree
Showing 7 changed files with 9 additions and 261 deletions.
6 changes: 0 additions & 6 deletions tasks/jira/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -73,12 +73,6 @@
<scope>provided</scope>
</dependency>

<dependency>
<groupId>com.squareup.okhttp</groupId>
<artifactId>okhttp</artifactId>
<version>2.7.5</version>
</dependency>

<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-api</artifactId>
Expand Down

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -495,25 +495,17 @@ JiraHttpClient getClient(TaskParams in) {
return getNativeClient(in);
} catch (NoClassDefFoundError e) {
// client2 may not exist
log.info("Falling back to okhttp client");
log.info("Error while creating jira http client: {}", e.getMessage());
log.info("Add com.walmartlabs.concord.client2 to classpath?");
}

try {
return getOkHttpClient(in);
} catch (Exception | NoClassDefFoundError e) {
// that's very unexpected as long as okhttp is still allowed
throw new IllegalStateException("No jira http client found");
}
throw new IllegalStateException("Unexpected error while creating JiraHttpClient.");
}

JiraHttpClient getNativeClient(TaskParams in) {
return new NativeJiraHttpClient(in);
}

JiraHttpClient getOkHttpClient(TaskParams in) {
return new JiraClient(in);
}

JiraSecretService getSecretService() {
return secretService;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,27 +56,15 @@ void testLoadClient() {
}

@Test
void testLoadClientFallback() {
void testLoadNotFound() {
Map<String, Object> input = new HashMap<>();
input.put("action", "getIssues");

doThrow(new NoClassDefFoundError()).when(delegate).getNativeClient(any());

var client = delegate.getClient(TaskParams.of(new MapBackedVariables(input), Map.of()));
assertInstanceOf(JiraClient.class, client);
}

@Test
void testNoClient() {
Map<String, Object> input = new HashMap<>();
input.put("action", "getIssues");

doThrow(new NoClassDefFoundError()).when(delegate).getNativeClient(any());
doThrow(new NoClassDefFoundError()).when(delegate).getOkHttpClient(any());

var params = TaskParams.of(new MapBackedVariables(input), Map.of());
var ex = assertThrows(IllegalStateException.class,
() -> delegate.getClient(TaskParams.of(new MapBackedVariables(input), Map.of())));

var expected = assertThrows(IllegalStateException.class, () -> delegate.getClient(params));
assertTrue(expected.getMessage().contains("No jira http client found"));
assertTrue(ex.getMessage().contains("Unexpected error while creating JiraHttpClient"));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@
class CommonTest {

@Mock
JiraClient jiraClient;
JiraHttpClient jiraClient;

@Mock
JiraSecretService jiraSecretService;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ class JiraClientTest extends AbstractWiremockTest {

@Override
JiraHttpClient getClient(JiraClientCfg cfg) {
return new JiraClient(cfg);
return new NativeJiraHttpClient(cfg);
}

}

0 comments on commit 9247677

Please sign in to comment.