Skip to content
This repository was archived by the owner on Dec 4, 2023. It is now read-only.

Commit 2d4ef62

Browse files
Remove health check feature (#1052)
Co-authored-by: tracyboehrer <tracyboehrer@users.noreply.github.com>
1 parent 4dd06e0 commit 2d4ef62

File tree

5 files changed

+0
-349
lines changed

5 files changed

+0
-349
lines changed

libraries/bot-builder/src/main/java/com/microsoft/bot/builder/ActivityHandler.java

Lines changed: 0 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -11,11 +11,9 @@
1111

1212
import org.apache.commons.lang3.StringUtils;
1313

14-
import com.microsoft.bot.connector.ConnectorClient;
1514
import com.microsoft.bot.schema.Activity;
1615
import com.microsoft.bot.schema.ActivityTypes;
1716
import com.microsoft.bot.schema.ChannelAccount;
18-
import com.microsoft.bot.schema.HealthCheckResponse;
1917
import com.microsoft.bot.schema.MessageReaction;
2018
import com.microsoft.bot.schema.ResourceResponse;
2119
import com.microsoft.bot.schema.SignInConstants;
@@ -415,10 +413,6 @@ protected CompletableFuture<InvokeResponse> onInvokeActivity(TurnContext turnCon
415413
}
416414
return new InvokeResponse(HttpURLConnection.HTTP_INTERNAL_ERROR, null);
417415
});
418-
} else if (StringUtils.equals(turnContext.getActivity().getName(), "healthCheck")) {
419-
CompletableFuture<InvokeResponse> result = new CompletableFuture<>();
420-
result.complete(new InvokeResponse(HttpURLConnection.HTTP_OK, onHealthCheck(turnContext)));
421-
return result;
422416
}
423417

424418
CompletableFuture<InvokeResponse> result = new CompletableFuture<>();
@@ -450,18 +444,6 @@ protected CompletableFuture<Void> onSignInInvoke(TurnContext turnContext) {
450444
return result;
451445
}
452446

453-
/**
454-
* Invoked when a 'healthCheck' event is
455-
* received when the base behavior of onInvokeActivity is used.
456-
*
457-
* @param turnContext The current TurnContext.
458-
* @return A task that represents a HealthCheckResponse.
459-
*/
460-
protected CompletableFuture<HealthCheckResponse> onHealthCheck(TurnContext turnContext) {
461-
ConnectorClient client = turnContext.getTurnState().get(BotFrameworkAdapter.CONNECTOR_CLIENT_KEY);
462-
return CompletableFuture.completedFuture(HealthCheck.createHealthCheckResponse(client));
463-
}
464-
465447
/**
466448
* Creates a success InvokeResponse with the specified body.
467449
*

libraries/bot-builder/src/main/java/com/microsoft/bot/builder/HealthCheck.java

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

libraries/bot-builder/src/test/java/com/microsoft/bot/builder/ActivityHandlerTests.java

Lines changed: 0 additions & 101 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,6 @@
1010
import java.util.ArrayList;
1111
import java.util.List;
1212
import java.util.concurrent.CompletableFuture;
13-
import java.util.concurrent.ExecutionException;
14-
import java.util.concurrent.atomic.AtomicReference;
15-
import org.mockito.internal.matchers.Not;
1613

1714
public class ActivityHandlerTests {
1815
@Test
@@ -428,98 +425,6 @@ public void TestUnrecognizedActivityType() {
428425
Assert.assertEquals("onUnrecognizedActivityType", bot.getRecord().get(0));
429426
}
430427

431-
@Test
432-
public void TestHealthCheckAsyncOverride() {
433-
Activity activity = new Activity() {
434-
{
435-
setType(ActivityTypes.INVOKE);
436-
setName("healthCheck");
437-
}
438-
};
439-
440-
TurnContext turnContext = new TurnContextImpl(new TestInvokeAdapter(), activity);
441-
442-
TestActivityHandler bot = new TestActivityHandler();
443-
bot.onTurn(turnContext).join();
444-
445-
Assert.assertEquals(2, bot.getRecord().size());
446-
Assert.assertEquals("onInvokeActivity", bot.getRecord().get(0));
447-
Assert.assertEquals("onHealthCheck", bot.getRecord().get(1));
448-
}
449-
450-
@Test
451-
public void TestHealthCheckAsync() {
452-
Activity activity = new Activity() {
453-
{
454-
setType(ActivityTypes.INVOKE);
455-
setName("healthCheck");
456-
}
457-
};
458-
459-
AtomicReference<List<Activity>> activitiesToSend = new AtomicReference<>();
460-
TurnContext turnContext = new TurnContextImpl(new SimpleAdapter(activitiesToSend::set), activity);
461-
462-
ActivityHandler bot = new ActivityHandler();
463-
bot.onTurn(turnContext).join();
464-
465-
Assert.assertNotNull(activitiesToSend.get());
466-
Assert.assertEquals(1, activitiesToSend.get().size());
467-
Assert.assertTrue(activitiesToSend.get().get(0).getValue() instanceof InvokeResponse);
468-
Assert.assertEquals(200, ((InvokeResponse) activitiesToSend.get().get(0).getValue()).getStatus());
469-
CompletableFuture future = ((CompletableFuture) ((InvokeResponse) activitiesToSend.get().get(0).getValue())
470-
.getBody());
471-
HealthCheckResponse result = new HealthCheckResponse();
472-
result = (HealthCheckResponse) future.join();
473-
Assert.assertTrue(result.getHealthResults().getSuccess());
474-
String[] messages = result.getHealthResults().getMessages();
475-
Assert.assertEquals(messages[0], "Health check succeeded.");
476-
}
477-
478-
@Test
479-
public void TestHealthCheckWithConnectorAsync() {
480-
Activity activity = new Activity() {
481-
{
482-
setType(ActivityTypes.INVOKE);
483-
setName("healthCheck");
484-
}
485-
};
486-
487-
AtomicReference<List<Activity>> activitiesToSend = new AtomicReference<>();
488-
TurnContext turnContext = new TurnContextImpl(new SimpleAdapter(activitiesToSend::set), activity);
489-
MockConnectorClient mockConnector = new MockConnectorClient("Windows/3.1", new MockAppCredentials("awesome"));
490-
turnContext.getTurnState().add(BotFrameworkAdapter.CONNECTOR_CLIENT_KEY, mockConnector);
491-
ActivityHandler bot = new ActivityHandler();
492-
bot.onTurn(turnContext).join();
493-
494-
Assert.assertNotNull(activitiesToSend.get());
495-
Assert.assertEquals(1, activitiesToSend.get().size());
496-
Assert.assertTrue(activitiesToSend.get().get(0).getValue() instanceof InvokeResponse);
497-
Assert.assertEquals(
498-
200,
499-
((InvokeResponse) activitiesToSend.get().get(0).getValue()).getStatus()
500-
);
501-
CompletableFuture<HealthCheckResponse> future =
502-
((CompletableFuture<HealthCheckResponse>)
503-
((InvokeResponse) activitiesToSend.get().get(0).getValue()).getBody());
504-
HealthCheckResponse result = new HealthCheckResponse();
505-
result = (HealthCheckResponse) future.join();
506-
Assert.assertTrue(result.getHealthResults().getSuccess());
507-
Assert.assertEquals(result.getHealthResults().getAuthorization(), "awesome");
508-
Assert.assertEquals(result.getHealthResults().getUserAgent(), "Windows/3.1");
509-
String[] messages = result.getHealthResults().getMessages();
510-
Assert.assertEquals(messages[0], "Health check succeeded.");
511-
}
512-
513-
private static class TestInvokeAdapter extends NotImplementedAdapter {
514-
@Override
515-
public CompletableFuture<ResourceResponse[]> sendActivities(
516-
TurnContext context,
517-
List<Activity> activities
518-
) {
519-
return CompletableFuture.completedFuture(new ResourceResponse[0]);
520-
}
521-
}
522-
523428
private static class NotImplementedAdapter extends BotAdapter {
524429
@Override
525430
public CompletableFuture<ResourceResponse[]> sendActivities(
@@ -635,12 +540,6 @@ protected CompletableFuture<InvokeResponse> onInvokeActivity(TurnContext turnCon
635540
return super.onInvokeActivity(turnContext);
636541
}
637542

638-
@Override
639-
protected CompletableFuture<HealthCheckResponse> onHealthCheck(TurnContext turnContext) {
640-
record.add("onHealthCheck");
641-
return super.onHealthCheck(turnContext);
642-
}
643-
644543
@Override
645544
protected CompletableFuture onInstallationUpdate(TurnContext turnContext) {
646545
record.add("onInstallationUpdate");

libraries/bot-schema/src/main/java/com/microsoft/bot/schema/HealthCheckResponse.java

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

libraries/bot-schema/src/main/java/com/microsoft/bot/schema/HealthResults.java

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

0 commit comments

Comments
 (0)