Removed references to SMS support
Change-Id: Icaea565638a61eeb65db8113d5471559ed48d310
This commit is contained in:
parent
4c54a95d54
commit
6e7ef66a58
@ -16,7 +16,7 @@ package monasca.api.domain.model.notificationmethod;
|
|||||||
import com.fasterxml.jackson.annotation.JsonCreator;
|
import com.fasterxml.jackson.annotation.JsonCreator;
|
||||||
|
|
||||||
public enum NotificationMethodType {
|
public enum NotificationMethodType {
|
||||||
EMAIL, SMS, WEBHOOK, PAGERDUTY;
|
EMAIL, WEBHOOK, PAGERDUTY;
|
||||||
|
|
||||||
@JsonCreator
|
@JsonCreator
|
||||||
public static NotificationMethodType fromJson(String text) {
|
public static NotificationMethodType fromJson(String text) {
|
||||||
|
@ -31,7 +31,7 @@ import monasca.api.domain.model.notificationmethod.NotificationMethodType;
|
|||||||
public class CreateNotificationMethodTest extends AbstractModelTest {
|
public class CreateNotificationMethodTest extends AbstractModelTest {
|
||||||
public void shouldDeserializeFromJson() throws Exception {
|
public void shouldDeserializeFromJson() throws Exception {
|
||||||
CreateNotificationMethodCommand newNotificationMethod =
|
CreateNotificationMethodCommand newNotificationMethod =
|
||||||
new CreateNotificationMethodCommand("MySMS", NotificationMethodType.SMS, "9228675309");
|
new CreateNotificationMethodCommand("MyEmail", NotificationMethodType.EMAIL, "a@b");
|
||||||
|
|
||||||
String json = jsonFixture("fixtures/newNotificationMethod.json");
|
String json = jsonFixture("fixtures/newNotificationMethod.json");
|
||||||
CreateNotificationMethodCommand other = fromJson(json, CreateNotificationMethodCommand.class);
|
CreateNotificationMethodCommand other = fromJson(json, CreateNotificationMethodCommand.class);
|
||||||
@ -40,7 +40,7 @@ public class CreateNotificationMethodTest extends AbstractModelTest {
|
|||||||
|
|
||||||
public void shouldDeserializeFromJsonLowerCaseEnum() throws Exception {
|
public void shouldDeserializeFromJsonLowerCaseEnum() throws Exception {
|
||||||
CreateNotificationMethodCommand newNotificationMethod =
|
CreateNotificationMethodCommand newNotificationMethod =
|
||||||
new CreateNotificationMethodCommand("MySMS", NotificationMethodType.SMS, "9228675309");
|
new CreateNotificationMethodCommand("MyEmail", NotificationMethodType.EMAIL, "a@b");
|
||||||
|
|
||||||
String json = jsonFixture("fixtures/newNotificationMethodWithLowercaseEnum.json");
|
String json = jsonFixture("fixtures/newNotificationMethodWithLowercaseEnum.json");
|
||||||
CreateNotificationMethodCommand other = fromJson(json, CreateNotificationMethodCommand.class);
|
CreateNotificationMethodCommand other = fromJson(json, CreateNotificationMethodCommand.class);
|
||||||
@ -50,7 +50,7 @@ public class CreateNotificationMethodTest extends AbstractModelTest {
|
|||||||
@Test(expectedExceptions = JsonMappingException.class)
|
@Test(expectedExceptions = JsonMappingException.class)
|
||||||
public void shouldDeserializeFromJsonEnumError() throws Exception {
|
public void shouldDeserializeFromJsonEnumError() throws Exception {
|
||||||
CreateNotificationMethodCommand newNotificationMethod =
|
CreateNotificationMethodCommand newNotificationMethod =
|
||||||
new CreateNotificationMethodCommand("MySMS", NotificationMethodType.SMS, "9228675309");
|
new CreateNotificationMethodCommand("MyEmail", NotificationMethodType.EMAIL, "a@b");
|
||||||
|
|
||||||
String json = jsonFixture("fixtures/newNotificationMethodWithInvalidEnum.json");
|
String json = jsonFixture("fixtures/newNotificationMethodWithInvalidEnum.json");
|
||||||
CreateNotificationMethodCommand other = fromJson(json, CreateNotificationMethodCommand.class);
|
CreateNotificationMethodCommand other = fromJson(json, CreateNotificationMethodCommand.class);
|
||||||
|
@ -31,7 +31,7 @@ public class NotificationMethodTest extends AbstractModelTest {
|
|||||||
|
|
||||||
public NotificationMethodTest() {
|
public NotificationMethodTest() {
|
||||||
notificationMethod =
|
notificationMethod =
|
||||||
new NotificationMethod("123", "MySMS", NotificationMethodType.SMS, "9228675309");
|
new NotificationMethod("123", "MyEmail", NotificationMethodType.EMAIL, "a@b");
|
||||||
notificationMethod.setLinks(Arrays.asList(new Link("self",
|
notificationMethod.setLinks(Arrays.asList(new Link("self",
|
||||||
"https://cloudsvc.example.com/v1.0")));
|
"https://cloudsvc.example.com/v1.0")));
|
||||||
}
|
}
|
||||||
|
@ -60,11 +60,11 @@ public class NotificationMethodMySqlRepositoryImplTest {
|
|||||||
protected void beforeMethod() {
|
protected void beforeMethod() {
|
||||||
handle.execute("truncate table notification_method");
|
handle.execute("truncate table notification_method");
|
||||||
handle
|
handle
|
||||||
.execute("insert into notification_method (id, tenant_id, name, type, address, created_at, updated_at) values ('123', '444', 'MySMS', 'SMS', '8675309', NOW(), NOW())");
|
.execute("insert into notification_method (id, tenant_id, name, type, address, created_at, updated_at) values ('123', '444', 'MyEmail', 'EMAIL', 'a@b', NOW(), NOW())");
|
||||||
}
|
}
|
||||||
|
|
||||||
public void shouldCreate() {
|
public void shouldCreate() {
|
||||||
NotificationMethod nmA = repo.create("555", "MySMS", NotificationMethodType.SMS, "5555555");
|
NotificationMethod nmA = repo.create("555", "MyEmail", NotificationMethodType.EMAIL, "a@b");
|
||||||
NotificationMethod nmB = repo.findById("555", nmA.getId());
|
NotificationMethod nmB = repo.findById("555", nmA.getId());
|
||||||
|
|
||||||
assertEquals(nmA, nmB);
|
assertEquals(nmA, nmB);
|
||||||
@ -80,15 +80,15 @@ public class NotificationMethodMySqlRepositoryImplTest {
|
|||||||
NotificationMethod nm = repo.findById("444", "123");
|
NotificationMethod nm = repo.findById("444", "123");
|
||||||
|
|
||||||
assertEquals(nm.getId(), "123");
|
assertEquals(nm.getId(), "123");
|
||||||
assertEquals(nm.getType(), NotificationMethodType.SMS);
|
assertEquals(nm.getType(), NotificationMethodType.EMAIL);
|
||||||
assertEquals(nm.getAddress(), "8675309");
|
assertEquals(nm.getAddress(), "a@b");
|
||||||
}
|
}
|
||||||
|
|
||||||
public void shouldFind() {
|
public void shouldFind() {
|
||||||
List<NotificationMethod> nms = repo.find("444", null);
|
List<NotificationMethod> nms = repo.find("444", null);
|
||||||
|
|
||||||
assertEquals(nms, Arrays.asList(new NotificationMethod("123", "MySMS",
|
assertEquals(nms, Arrays.asList(new NotificationMethod("123", "MyEmail",
|
||||||
NotificationMethodType.SMS, "8675309")));
|
NotificationMethodType.EMAIL, "a@b")));
|
||||||
}
|
}
|
||||||
|
|
||||||
public void shouldUpdate() {
|
public void shouldUpdate() {
|
||||||
|
@ -78,9 +78,9 @@ public class AlarmIntegrationTest extends AbstractMonApiResourceTest {
|
|||||||
handle.execute("truncate table alarm");
|
handle.execute("truncate table alarm");
|
||||||
handle.execute("truncate table notification_method");
|
handle.execute("truncate table notification_method");
|
||||||
handle
|
handle
|
||||||
.execute("insert into notification_method (id, tenant_id, name, type, address, created_at, updated_at) values ('29387234', 'alarm-test', 'MySMS', 'SMS', '8675309', NOW(), NOW())");
|
.execute("insert into notification_method (id, tenant_id, name, type, address, created_at, updated_at) values ('29387234', 'alarm-test', 'MyEmail', 'EMAIL', 'a@b', NOW(), NOW())");
|
||||||
handle
|
handle
|
||||||
.execute("insert into notification_method (id, tenant_id, name, type, address, created_at, updated_at) values ('77778687', 'alarm-test', 'MySMS', 'SMS', '8675309', NOW(), NOW())");
|
.execute("insert into notification_method (id, tenant_id, name, type, address, created_at, updated_at) values ('77778687', 'alarm-test', 'MyEmail', 'EMAIL', 'a@b', NOW(), NOW())");
|
||||||
mysqlDb.close(handle);
|
mysqlDb.close(handle);
|
||||||
|
|
||||||
repo = new AlarmDefinitionMySqlRepositoryImpl(mysqlDb);
|
repo = new AlarmDefinitionMySqlRepositoryImpl(mysqlDb);
|
||||||
|
@ -56,7 +56,7 @@ public class NotificationMethodIntegrationTest extends AbstractMonApiResourceTes
|
|||||||
Handle handle = db.open();
|
Handle handle = db.open();
|
||||||
handle.execute("truncate table notification_method");
|
handle.execute("truncate table notification_method");
|
||||||
handle
|
handle
|
||||||
.execute("insert into notification_method (id, tenant_id, name, type, address, created_at, updated_at) values ('29387234', 'notification-method-test', 'MySMS', 'SMS', '8675309', NOW(), NOW())");
|
.execute("insert into notification_method (id, tenant_id, name, type, address, created_at, updated_at) values ('29387234', 'notification-method-test', 'MyEmaila', 'EMAIL', 'a@b', NOW(), NOW())");
|
||||||
db.close(handle);
|
db.close(handle);
|
||||||
|
|
||||||
repo = new NotificationMethodMySqlRepositoryImpl(db);
|
repo = new NotificationMethodMySqlRepositoryImpl(db);
|
||||||
@ -76,7 +76,7 @@ public class NotificationMethodIntegrationTest extends AbstractMonApiResourceTes
|
|||||||
|
|
||||||
// Fixtures
|
// Fixtures
|
||||||
notificationMethod =
|
notificationMethod =
|
||||||
new NotificationMethod("123", "Joe's SMS", NotificationMethodType.SMS, "8675309");
|
new NotificationMethod("123", "Joe's Email", NotificationMethodType.EMAIL, "a@b");
|
||||||
}
|
}
|
||||||
|
|
||||||
public void shouldCreate() throws Exception {
|
public void shouldCreate() throws Exception {
|
||||||
@ -106,7 +106,7 @@ public class NotificationMethodIntegrationTest extends AbstractMonApiResourceTes
|
|||||||
.header("X-Tenant-Id", TENANT_ID)
|
.header("X-Tenant-Id", TENANT_ID)
|
||||||
.type(MediaType.APPLICATION_JSON)
|
.type(MediaType.APPLICATION_JSON)
|
||||||
.post(ClientResponse.class,
|
.post(ClientResponse.class,
|
||||||
new CreateNotificationMethodCommand("MySMS", NotificationMethodType.SMS, "8675309"));
|
new CreateNotificationMethodCommand("MyEmail", NotificationMethodType.EMAIL, "a@b"));
|
||||||
|
|
||||||
assertEquals(response.getStatus(), 409);
|
assertEquals(response.getStatus(), 409);
|
||||||
}
|
}
|
||||||
|
@ -43,14 +43,14 @@ public class NotificationMethodResourceTest extends AbstractMonApiResourceTest {
|
|||||||
protected void setupResources() throws Exception {
|
protected void setupResources() throws Exception {
|
||||||
super.setupResources();
|
super.setupResources();
|
||||||
notificationMethod =
|
notificationMethod =
|
||||||
new NotificationMethod("123", "Joe's SMS", NotificationMethodType.SMS, "8675309");
|
new NotificationMethod("123", "Joe's Email", NotificationMethodType.EMAIL, "a@b");
|
||||||
notificationMethodWebhook =
|
notificationMethodWebhook =
|
||||||
new NotificationMethod("1234", "MyWh", NotificationMethodType.WEBHOOK, "http://localhost");
|
new NotificationMethod("1234", "MyWh", NotificationMethodType.WEBHOOK, "http://localhost");
|
||||||
notificationMethodPagerduty =
|
notificationMethodPagerduty =
|
||||||
new NotificationMethod("12345", "MyPd", NotificationMethodType.PAGERDUTY, "nzH2LVRdMzun11HNC2oD");
|
new NotificationMethod("12345", "MyPd", NotificationMethodType.PAGERDUTY, "nzH2LVRdMzun11HNC2oD");
|
||||||
|
|
||||||
repo = mock(NotificationMethodRepository.class);
|
repo = mock(NotificationMethodRepository.class);
|
||||||
when(repo.create(eq("abc"), eq("MySMS"), eq(NotificationMethodType.SMS), anyString()))
|
when(repo.create(eq("abc"), eq("MyEmail"), eq(NotificationMethodType.EMAIL), anyString()))
|
||||||
.thenReturn(notificationMethod);
|
.thenReturn(notificationMethod);
|
||||||
when(repo.create(eq("abc"), eq("MyWh"), eq(NotificationMethodType.WEBHOOK), anyString()))
|
when(repo.create(eq("abc"), eq("MyWh"), eq(NotificationMethodType.WEBHOOK), anyString()))
|
||||||
.thenReturn(notificationMethodWebhook);
|
.thenReturn(notificationMethodWebhook);
|
||||||
@ -69,14 +69,14 @@ public class NotificationMethodResourceTest extends AbstractMonApiResourceTest {
|
|||||||
.header("X-Tenant-Id", "abc")
|
.header("X-Tenant-Id", "abc")
|
||||||
.header("Content-Type", MediaType.APPLICATION_JSON)
|
.header("Content-Type", MediaType.APPLICATION_JSON)
|
||||||
.post(ClientResponse.class,
|
.post(ClientResponse.class,
|
||||||
new CreateNotificationMethodCommand("MySMS", NotificationMethodType.SMS, "8675309"));
|
new CreateNotificationMethodCommand("MyEmail", NotificationMethodType.EMAIL, "a@a.com"));
|
||||||
|
|
||||||
NotificationMethod newNotificationMethod = response.getEntity(NotificationMethod.class);
|
NotificationMethod newNotificationMethod = response.getEntity(NotificationMethod.class);
|
||||||
String location = response.getHeaders().get("Location").get(0);
|
String location = response.getHeaders().get("Location").get(0);
|
||||||
assertEquals(response.getStatus(), 201);
|
assertEquals(response.getStatus(), 201);
|
||||||
assertEquals(location, "/v2.0/notification-methods/" + newNotificationMethod.getId());
|
assertEquals(location, "/v2.0/notification-methods/" + newNotificationMethod.getId());
|
||||||
assertEquals(newNotificationMethod, notificationMethod);
|
assertEquals(newNotificationMethod, notificationMethod);
|
||||||
verify(repo).create(eq("abc"), eq("MySMS"), eq(NotificationMethodType.SMS), anyString());
|
verify(repo).create(eq("abc"), eq("MyEmail"), eq(NotificationMethodType.EMAIL), anyString());
|
||||||
}
|
}
|
||||||
|
|
||||||
public void shouldUpdate() {
|
public void shouldUpdate() {
|
||||||
@ -103,7 +103,7 @@ public class NotificationMethodResourceTest extends AbstractMonApiResourceTest {
|
|||||||
.header("X-Tenant-Id", "abc")
|
.header("X-Tenant-Id", "abc")
|
||||||
.header("Content-Type", MediaType.APPLICATION_JSON)
|
.header("Content-Type", MediaType.APPLICATION_JSON)
|
||||||
.post(ClientResponse.class,
|
.post(ClientResponse.class,
|
||||||
new CreateNotificationMethodCommand("MySMS", null, "8675309"));
|
new CreateNotificationMethodCommand("MyEmail", null, "a@b"));
|
||||||
|
|
||||||
String e = response.getEntity(String.class);
|
String e = response.getEntity(String.class);
|
||||||
ErrorMessages.assertThat(e).matches("unprocessable_entity", 422,
|
ErrorMessages.assertThat(e).matches("unprocessable_entity", 422,
|
||||||
@ -117,7 +117,7 @@ public class NotificationMethodResourceTest extends AbstractMonApiResourceTest {
|
|||||||
.header("X-Tenant-Id", "abc")
|
.header("X-Tenant-Id", "abc")
|
||||||
.header("Content-Type", MediaType.APPLICATION_JSON)
|
.header("Content-Type", MediaType.APPLICATION_JSON)
|
||||||
.post(ClientResponse.class,
|
.post(ClientResponse.class,
|
||||||
new CreateNotificationMethodCommand("MySMS", NotificationMethodType.EMAIL, "a@"));
|
new CreateNotificationMethodCommand("MyEmail", NotificationMethodType.EMAIL, "a@"));
|
||||||
|
|
||||||
ErrorMessages.assertThat(response.getEntity(String.class)).matches("unprocessable_entity", 422,
|
ErrorMessages.assertThat(response.getEntity(String.class)).matches("unprocessable_entity", 422,
|
||||||
"Address a@ is not of correct format");
|
"Address a@ is not of correct format");
|
||||||
@ -130,7 +130,7 @@ public class NotificationMethodResourceTest extends AbstractMonApiResourceTest {
|
|||||||
.header("X-Tenant-Id", "abc")
|
.header("X-Tenant-Id", "abc")
|
||||||
.header("Content-Type", MediaType.APPLICATION_JSON)
|
.header("Content-Type", MediaType.APPLICATION_JSON)
|
||||||
.post(ClientResponse.class,
|
.post(ClientResponse.class,
|
||||||
new CreateNotificationMethodCommand("MySMS", NotificationMethodType.EMAIL, "a@f ,"));
|
new CreateNotificationMethodCommand("MyEmail", NotificationMethodType.EMAIL, "a@f ,"));
|
||||||
|
|
||||||
ErrorMessages.assertThat(response.getEntity(String.class)).matches("unprocessable_entity", 422,
|
ErrorMessages.assertThat(response.getEntity(String.class)).matches("unprocessable_entity", 422,
|
||||||
"Address a@f , is not of correct format");
|
"Address a@f , is not of correct format");
|
||||||
@ -143,7 +143,7 @@ public class NotificationMethodResourceTest extends AbstractMonApiResourceTest {
|
|||||||
.header("X-Tenant-Id", "abc")
|
.header("X-Tenant-Id", "abc")
|
||||||
.header("Content-Type", MediaType.APPLICATION_JSON)
|
.header("Content-Type", MediaType.APPLICATION_JSON)
|
||||||
.post(ClientResponse.class,
|
.post(ClientResponse.class,
|
||||||
new CreateNotificationMethodCommand("MySMS", NotificationMethodType.SMS, ""));
|
new CreateNotificationMethodCommand("MyEmail", NotificationMethodType.EMAIL, ""));
|
||||||
|
|
||||||
ErrorMessages.assertThat(response.getEntity(String.class)).matches("unprocessable_entity", 422,
|
ErrorMessages.assertThat(response.getEntity(String.class)).matches("unprocessable_entity", 422,
|
||||||
"[address may not be empty (was )");
|
"[address may not be empty (was )");
|
||||||
@ -161,7 +161,7 @@ public class NotificationMethodResourceTest extends AbstractMonApiResourceTest {
|
|||||||
"01234567889012345678890123456788901234567889012345678890123456788901234567889012345678890123456788901234567889"
|
"01234567889012345678890123456788901234567889012345678890123456788901234567889012345678890123456788901234567889"
|
||||||
+ "01234567889012345678890123456788901234567889012345678890123456788901234567889012345678890123456788901234567889"
|
+ "01234567889012345678890123456788901234567889012345678890123456788901234567889012345678890123456788901234567889"
|
||||||
+ "01234567889012345678890123456788901234567889012345678890123456788901234567889012345678890123456788901234567889",
|
+ "01234567889012345678890123456788901234567889012345678890123456788901234567889012345678890123456788901234567889",
|
||||||
NotificationMethodType.SMS, "a@b"));
|
NotificationMethodType.EMAIL, "a@b"));
|
||||||
|
|
||||||
ErrorMessages.assertThat(response.getEntity(String.class)).matches("unprocessable_entity", 422,
|
ErrorMessages.assertThat(response.getEntity(String.class)).matches("unprocessable_entity", 422,
|
||||||
"[name size must be between 1 and 250");
|
"[name size must be between 1 and 250");
|
||||||
@ -176,8 +176,8 @@ public class NotificationMethodResourceTest extends AbstractMonApiResourceTest {
|
|||||||
.post(
|
.post(
|
||||||
ClientResponse.class,
|
ClientResponse.class,
|
||||||
new CreateNotificationMethodCommand(
|
new CreateNotificationMethodCommand(
|
||||||
"MySMS",
|
"MyEmail",
|
||||||
NotificationMethodType.SMS,
|
NotificationMethodType.EMAIL,
|
||||||
"abcdefghi@0123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789"));
|
"abcdefghi@0123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789"));
|
||||||
|
|
||||||
String e = response.getEntity(String.class);
|
String e = response.getEntity(String.class);
|
||||||
|
@ -1 +1 @@
|
|||||||
{"name":"MySMS","type":"SMS","address":"9228675309"}
|
{"name":"MyEmail","type":"EMAIL","address":"a@b"}
|
||||||
|
@ -1 +1 @@
|
|||||||
{"name":"MySMS","type":"smsy","address":"9228675309"}
|
{"name":"MyEmail","type":"invalid_enum","address":"a@b"}
|
||||||
|
@ -1 +1 @@
|
|||||||
{"name":"MySMS","type":"sms","address":"9228675309"}
|
{"name":"MyEmail","type":"email","address":"a@b"}
|
||||||
|
@ -1 +1 @@
|
|||||||
{"id":"123","links":[{"rel":"self","href":"https://cloudsvc.example.com/v1.0"}],"name":"MySMS","type":"SMS","address":"9228675309"}
|
{"id":"123","links":[{"rel":"self","href":"https://cloudsvc.example.com/v1.0"}],"name":"MyEmail","type":"EMAIL","address":"a@b"}
|
||||||
|
@ -2,7 +2,7 @@ CREATE TABLE `notification_method` (
|
|||||||
`id` varchar(36) NOT NULL,
|
`id` varchar(36) NOT NULL,
|
||||||
`tenant_id` varchar(36) NOT NULL DEFAULT '',
|
`tenant_id` varchar(36) NOT NULL DEFAULT '',
|
||||||
`name` varchar(250) NOT NULL DEFAULT '',
|
`name` varchar(250) NOT NULL DEFAULT '',
|
||||||
`type` varchar(10) NOT NULL DEFAULT 'EMAIL' check type in ('EMAIL','SMS', 'WEBHOOK', 'PAGERDUTY'),
|
`type` varchar(10) NOT NULL DEFAULT 'EMAIL' check type in ('EMAIL', 'WEBHOOK', 'PAGERDUTY'),
|
||||||
`address` varchar(100) NOT NULL DEFAULT '',
|
`address` varchar(100) NOT NULL DEFAULT '',
|
||||||
`created_at` datetime NOT NULL,
|
`created_at` datetime NOT NULL,
|
||||||
`updated_at` datetime NOT NULL,
|
`updated_at` datetime NOT NULL,
|
||||||
|
Loading…
Reference in New Issue
Block a user