Skip to content

Commit

Permalink
HWKMETRICS-155 Test against regression for metric definition list sta…
Browse files Browse the repository at this point in the history
…tus code 400
  • Loading branch information
tsegismont committed Jun 23, 2015
1 parent 14d9c1a commit ca69df2
Showing 1 changed file with 26 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ import static org.joda.time.Seconds.seconds
import static org.junit.Assert.assertEquals
import static org.junit.Assert.assertTrue

import org.hawkular.metrics.core.api.MetricType
import org.hawkular.metrics.core.impl.DateTimeService
import org.joda.time.DateTime
import org.junit.Test
Expand Down Expand Up @@ -350,6 +351,31 @@ class CassandraBackendITest extends RESTTest {
)
}

@Test
void findMetricsShouldFailProperlyWhenTypeIsMissingOrInvalid() {
def tenantId = nextTenantId()

badGet(path: "metrics",
headers: [(tenantHeaderName): tenantId]) { exception ->
// Missing type
assertEquals(400, exception.response.status)
assertEquals("Missing type param", exception.response.data["errorMsg"])
}

def invalidType = MetricType.values().join('"')
badGet(path: "metrics", query: [type: invalidType],
headers: [(tenantHeaderName): tenantId]) { exception ->
// Invalid type
assertEquals(400, exception.response.status)
assertEquals(invalidType + " is not a recognized metric type", exception.response.data["errorMsg"])
}

def response = hawkularMetrics.get(path: "metrics", query: [type: MetricType.GAUGE.text],
headers: [(tenantHeaderName): tenantId])
// Works fine when type is correctly set (here 204 as not metric has been created)
assertEquals(204, response.status)
}

@Test
void findMetrics() {
DateTime start = now().minusMinutes(20)
Expand Down

0 comments on commit ca69df2

Please sign in to comment.