Skip to content
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
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,24 @@ class AlertingException(message: String, val status: RestStatus, val ex: Excepti
return AlertingException(friendlyMsg, status, Exception("${ex.javaClass.name}: ${ex.message}"))
}

/**
* Checks whether the given throwable (or any of its causes) is an IndexNotFoundException.
* The remote metadata SDK wraps IndexNotFoundException inside OpenSearchStatusException,
* so the original "no such index" message may be buried in the cause chain.
*/
@JvmStatic
fun isIndexNotFoundException(e: Throwable): Boolean {
var cause: Throwable? = e
while (cause != null) {
if (cause is IndexNotFoundException || cause.message?.contains("no such index") == true) {
log.debug("IndexNotFoundException found in cause chain: ${cause.message}")
return true
}
cause = cause.cause
}
return false
}

@JvmStatic
fun merge(vararg ex: AlertingException): AlertingException {
var friendlyMsg = ""
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
*/
package org.opensearch.commons.notifications.action

import com.fasterxml.jackson.core.JsonParseException
import org.junit.jupiter.api.Assertions.assertEquals
import org.junit.jupiter.api.Assertions.assertNull
import org.junit.jupiter.api.Test
Expand All @@ -23,7 +22,7 @@ import org.opensearch.commons.notifications.model.Webhook
import org.opensearch.commons.utils.createObjectFromJsonString
import org.opensearch.commons.utils.getJsonString
import org.opensearch.commons.utils.recreateObject

import org.opensearch.tools.jackson.core.JsonParseException
internal class CreateNotificationConfigRequestTests {

private fun createWebhookContentConfigObject(): NotificationConfig {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,13 @@
*/
package org.opensearch.commons.notifications.action

import com.fasterxml.jackson.core.JsonParseException
import org.junit.jupiter.api.Assertions.assertEquals
import org.junit.jupiter.api.Test
import org.junit.jupiter.api.assertThrows
import org.opensearch.commons.utils.createObjectFromJsonString
import org.opensearch.commons.utils.getJsonString
import org.opensearch.commons.utils.recreateObject

import org.opensearch.tools.jackson.core.JsonParseException
internal class CreateNotificationConfigResponseTests {

@Test
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,13 @@
*/
package org.opensearch.commons.notifications.action

import com.fasterxml.jackson.core.JsonParseException
import org.junit.jupiter.api.Assertions.assertEquals
import org.junit.jupiter.api.Test
import org.junit.jupiter.api.assertThrows
import org.opensearch.commons.utils.createObjectFromJsonString
import org.opensearch.commons.utils.getJsonString
import org.opensearch.commons.utils.recreateObject

import org.opensearch.tools.jackson.core.JsonParseException
internal class DeleteNotificationConfigRequestTests {

@Test
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,14 @@
*/
package org.opensearch.commons.notifications.action

import com.fasterxml.jackson.core.JsonParseException
import org.junit.jupiter.api.Assertions.assertEquals
import org.junit.jupiter.api.Test
import org.junit.jupiter.api.assertThrows
import org.opensearch.commons.utils.createObjectFromJsonString
import org.opensearch.commons.utils.getJsonString
import org.opensearch.commons.utils.recreateObject
import org.opensearch.core.rest.RestStatus

import org.opensearch.tools.jackson.core.JsonParseException
internal class DeleteNotificationConfigResponseTests {

@Test
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,13 @@
*/
package org.opensearch.commons.notifications.action

import com.fasterxml.jackson.core.JsonParseException
import org.junit.jupiter.api.Assertions.assertEquals
import org.junit.jupiter.api.Test
import org.junit.jupiter.api.assertThrows
import org.opensearch.commons.utils.createObjectFromJsonString
import org.opensearch.commons.utils.getJsonString
import org.opensearch.commons.utils.recreateObject

import org.opensearch.tools.jackson.core.JsonParseException
internal class GetChannelListRequestTests {

private fun assertGetRequestEquals(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,14 @@
*/
package org.opensearch.commons.notifications.action

import com.fasterxml.jackson.core.JsonParseException
import org.junit.jupiter.api.Assertions.assertEquals
import org.junit.jupiter.api.Test
import org.junit.jupiter.api.assertThrows
import org.opensearch.commons.utils.createObjectFromJsonString
import org.opensearch.commons.utils.getJsonString
import org.opensearch.commons.utils.recreateObject
import org.opensearch.search.sort.SortOrder

import org.opensearch.tools.jackson.core.JsonParseException
internal class GetNotificationConfigRequestTests {

private fun assertGetRequestEquals(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,13 @@
*/
package org.opensearch.commons.notifications.action

import com.fasterxml.jackson.core.JsonParseException
import org.junit.jupiter.api.Assertions.assertEquals
import org.junit.jupiter.api.Test
import org.junit.jupiter.api.assertThrows
import org.opensearch.commons.utils.createObjectFromJsonString
import org.opensearch.commons.utils.getJsonString
import org.opensearch.commons.utils.recreateObject

import org.opensearch.tools.jackson.core.JsonParseException
internal class GetPluginFeaturesRequestTests {

private fun assertGetRequestEquals(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
*/
package org.opensearch.commons.notifications.action

import com.fasterxml.jackson.core.JsonParseException
import org.junit.jupiter.api.Assertions.assertEquals
import org.junit.jupiter.api.Assertions.assertNotNull
import org.junit.jupiter.api.Assertions.assertNull
Expand All @@ -16,7 +15,7 @@ import org.opensearch.commons.notifications.model.SeverityType
import org.opensearch.commons.utils.createObjectFromJsonString
import org.opensearch.commons.utils.getJsonString
import org.opensearch.commons.utils.recreateObject

import org.opensearch.tools.jackson.core.JsonParseException
internal class SendNotificationRequestTests {

private fun assertGetRequestEquals(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
*/
package org.opensearch.commons.notifications.action

import com.fasterxml.jackson.core.JsonParseException
import org.junit.Test
import org.junit.jupiter.api.Assertions.assertEquals
import org.junit.jupiter.api.assertThrows
Expand All @@ -17,7 +16,7 @@ import org.opensearch.commons.notifications.model.SeverityType
import org.opensearch.commons.utils.createObjectFromJsonString
import org.opensearch.commons.utils.getJsonString
import org.opensearch.commons.utils.recreateObject

import org.opensearch.tools.jackson.core.JsonParseException
internal class SendNotificationResponseTests {

@Test
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
*/
package org.opensearch.commons.notifications.action

import com.fasterxml.jackson.core.JsonParseException
import org.junit.jupiter.api.Assertions.assertEquals
import org.junit.jupiter.api.Assertions.assertNull
import org.junit.jupiter.api.Test
Expand All @@ -23,7 +22,7 @@ import org.opensearch.commons.notifications.model.Webhook
import org.opensearch.commons.utils.createObjectFromJsonString
import org.opensearch.commons.utils.getJsonString
import org.opensearch.commons.utils.recreateObject

import org.opensearch.tools.jackson.core.JsonParseException
internal class UpdateNotificationConfigRequestTests {

private fun createWebhookContentConfigObject(): NotificationConfig {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,13 @@
*/
package org.opensearch.commons.notifications.action

import com.fasterxml.jackson.core.JsonParseException
import org.junit.jupiter.api.Assertions.assertEquals
import org.junit.jupiter.api.Test
import org.junit.jupiter.api.assertThrows
import org.opensearch.commons.utils.createObjectFromJsonString
import org.opensearch.commons.utils.getJsonString
import org.opensearch.commons.utils.recreateObject

import org.opensearch.tools.jackson.core.JsonParseException
internal class UpdateNotificationConfigResponseTests {

@Test
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,14 @@
*/
package org.opensearch.commons.notifications.model

import com.fasterxml.jackson.core.JsonParseException
import org.junit.jupiter.api.Assertions.assertEquals
import org.junit.jupiter.api.Test
import org.junit.jupiter.api.assertThrows
import org.opensearch.commons.utils.createObjectFromJsonString
import org.opensearch.commons.utils.getJsonString
import org.opensearch.commons.utils.recreateObject
import org.opensearch.tools.jackson.core.JsonParseException
import java.net.MalformedURLException

internal class ChimeTests {

@Test
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,13 @@

package org.opensearch.commons.notifications.model

import com.fasterxml.jackson.core.JsonParseException
import org.junit.jupiter.api.Assertions.assertEquals
import org.junit.jupiter.api.Test
import org.junit.jupiter.api.assertThrows
import org.opensearch.commons.utils.createObjectFromJsonString
import org.opensearch.commons.utils.getJsonString
import org.opensearch.commons.utils.recreateObject

import org.opensearch.tools.jackson.core.JsonParseException
internal class DeliveryStatusTests {
@Test
fun `DeliveryStatus serialize and deserialize should be equal`() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,13 @@
*/
package org.opensearch.commons.notifications.model

import com.fasterxml.jackson.core.JsonParseException
import org.junit.jupiter.api.Assertions.assertEquals
import org.junit.jupiter.api.Test
import org.junit.jupiter.api.assertThrows
import org.opensearch.commons.utils.createObjectFromJsonString
import org.opensearch.commons.utils.getJsonString
import org.opensearch.commons.utils.recreateObject

import org.opensearch.tools.jackson.core.JsonParseException
internal class EmailGroupTests {

@Test
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,13 @@

package org.opensearch.commons.notifications.model

import com.fasterxml.jackson.core.JsonParseException
import org.junit.jupiter.api.Assertions.assertEquals
import org.junit.jupiter.api.Test
import org.junit.jupiter.api.assertThrows
import org.opensearch.commons.utils.createObjectFromJsonString
import org.opensearch.commons.utils.getJsonString
import org.opensearch.commons.utils.recreateObject

import org.opensearch.tools.jackson.core.JsonParseException
internal class EmailRecipientStatusTests {
@Test
fun `EmailRecipientStatus serialize and deserialize should be equal`() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,14 @@
*/
package org.opensearch.commons.notifications.model

import com.fasterxml.jackson.core.JsonParseException
import org.junit.jupiter.api.Assertions.assertEquals
import org.junit.jupiter.api.Test
import org.junit.jupiter.api.assertDoesNotThrow
import org.junit.jupiter.api.assertThrows
import org.opensearch.commons.utils.createObjectFromJsonString
import org.opensearch.commons.utils.getJsonString
import org.opensearch.commons.utils.recreateObject

import org.opensearch.tools.jackson.core.JsonParseException
internal class EmailRecipientTests {

private fun checkValidEmailAddress(emailAddress: String) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,13 @@
*/
package org.opensearch.commons.notifications.model

import com.fasterxml.jackson.core.JsonParseException
import org.junit.jupiter.api.Assertions.assertEquals
import org.junit.jupiter.api.Test
import org.junit.jupiter.api.assertThrows
import org.opensearch.commons.utils.createObjectFromJsonString
import org.opensearch.commons.utils.getJsonString
import org.opensearch.commons.utils.recreateObject

import org.opensearch.tools.jackson.core.JsonParseException
internal class EmailTests {

@Test
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,14 @@
*/
package org.opensearch.commons.notifications.model

import com.fasterxml.jackson.core.JsonParseException
import org.junit.jupiter.api.Assertions
import org.junit.jupiter.api.Assertions.assertEquals
import org.junit.jupiter.api.Test
import org.junit.jupiter.api.assertThrows
import org.opensearch.commons.utils.createObjectFromJsonString
import org.opensearch.commons.utils.getJsonString
import org.opensearch.commons.utils.recreateObject

import org.opensearch.tools.jackson.core.JsonParseException
internal class EventStatusTests {

@Test
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,14 @@
*/
package org.opensearch.commons.notifications.model

import com.fasterxml.jackson.core.JsonParseException
import org.junit.jupiter.api.Assertions.assertEquals
import org.junit.jupiter.api.Test
import org.junit.jupiter.api.assertThrows
import org.opensearch.commons.utils.createObjectFromJsonString
import org.opensearch.commons.utils.getJsonString
import org.opensearch.commons.utils.recreateObject
import org.opensearch.tools.jackson.core.JsonParseException
import java.net.MalformedURLException

internal class MicrosoftTeamsTests {

@Test
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,13 @@

package org.opensearch.commons.notifications.model

import com.fasterxml.jackson.core.JsonParseException
import org.junit.jupiter.api.Assertions.assertEquals
import org.junit.jupiter.api.Test
import org.junit.jupiter.api.assertThrows
import org.opensearch.commons.utils.createObjectFromJsonString
import org.opensearch.commons.utils.getJsonString
import org.opensearch.commons.utils.recreateObject

import org.opensearch.tools.jackson.core.JsonParseException
internal class SesAccountTests {

@Test
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,14 @@
*/
package org.opensearch.commons.notifications.model

import com.fasterxml.jackson.core.JsonParseException
import org.junit.jupiter.api.Assertions.assertEquals
import org.junit.jupiter.api.Test
import org.junit.jupiter.api.assertThrows
import org.opensearch.commons.utils.createObjectFromJsonString
import org.opensearch.commons.utils.getJsonString
import org.opensearch.commons.utils.recreateObject
import org.opensearch.tools.jackson.core.JsonParseException
import java.net.MalformedURLException

internal class SlackTests {

@Test
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,13 @@
*/
package org.opensearch.commons.notifications.model

import com.fasterxml.jackson.core.JsonParseException
import org.junit.jupiter.api.Assertions.assertEquals
import org.junit.jupiter.api.Test
import org.junit.jupiter.api.assertThrows
import org.opensearch.commons.utils.createObjectFromJsonString
import org.opensearch.commons.utils.getJsonString
import org.opensearch.commons.utils.recreateObject

import org.opensearch.tools.jackson.core.JsonParseException
internal class SmtpAccountTests {

@Test
Expand Down
Loading
Loading