use of org.thingsboard.server.common.data.widget.WidgetType in project thingsboard by thingsboard.
the class BaseWidgetTypeControllerTest method testUpdateWidgetTypeAlias.
@Test
public void testUpdateWidgetTypeAlias() throws Exception {
WidgetType widgetType = new WidgetType();
widgetType.setBundleAlias(savedWidgetsBundle.getAlias());
widgetType.setName("Widget Type");
widgetType.setDescriptor(new ObjectMapper().readValue("{ \"someKey\": \"someValue\" }", JsonNode.class));
WidgetType savedWidgetType = doPost("/api/widgetType", widgetType, WidgetType.class);
savedWidgetType.setAlias("some_alias");
doPost("/api/widgetType", savedWidgetType).andExpect(status().isBadRequest()).andExpect(statusReason(containsString("Update of widget type alias is prohibited")));
}
use of org.thingsboard.server.common.data.widget.WidgetType in project thingsboard by thingsboard.
the class BaseWidgetTypeControllerTest method testGetWidgetType.
@Test
public void testGetWidgetType() throws Exception {
WidgetType widgetType = new WidgetType();
widgetType.setBundleAlias(savedWidgetsBundle.getAlias());
widgetType.setName("Widget Type");
widgetType.setDescriptor(new ObjectMapper().readValue("{ \"someKey\": \"someValue\" }", JsonNode.class));
WidgetType savedWidgetType = doPost("/api/widgetType", widgetType, WidgetType.class);
WidgetType foundWidgetType = doGet("/api/widgetType?isSystem={isSystem}&bundleAlias={bundleAlias}&alias={alias}", WidgetType.class, false, savedWidgetsBundle.getAlias(), savedWidgetType.getAlias());
Assert.assertNotNull(foundWidgetType);
Assert.assertEquals(savedWidgetType, foundWidgetType);
}
use of org.thingsboard.server.common.data.widget.WidgetType in project thingsboard by thingsboard.
the class BaseWidgetTypeControllerTest method testSaveWidgetTypeWithEmptyName.
@Test
public void testSaveWidgetTypeWithEmptyName() throws Exception {
WidgetType widgetType = new WidgetType();
widgetType.setBundleAlias(savedWidgetsBundle.getAlias());
widgetType.setDescriptor(new ObjectMapper().readValue("{ \"someKey\": \"someValue\" }", JsonNode.class));
doPost("/api/widgetType", widgetType).andExpect(status().isBadRequest()).andExpect(statusReason(containsString("Widgets type name should be specified")));
}
use of org.thingsboard.server.common.data.widget.WidgetType in project thingsboard by thingsboard.
the class BaseWidgetTypeControllerTest method testDeleteWidgetType.
@Test
public void testDeleteWidgetType() throws Exception {
WidgetType widgetType = new WidgetType();
widgetType.setBundleAlias(savedWidgetsBundle.getAlias());
widgetType.setName("Widget Type");
widgetType.setDescriptor(new ObjectMapper().readValue("{ \"someKey\": \"someValue\" }", JsonNode.class));
WidgetType savedWidgetType = doPost("/api/widgetType", widgetType, WidgetType.class);
doDelete("/api/widgetType/" + savedWidgetType.getId().getId().toString()).andExpect(status().isOk());
doGet("/api/widgetType/" + savedWidgetType.getId().getId().toString()).andExpect(status().isNotFound());
}
use of org.thingsboard.server.common.data.widget.WidgetType in project thingsboard by thingsboard.
the class BaseWidgetTypeServiceTest method testSaveWidgetTypeWithEmptyDescriptor.
@Test(expected = DataValidationException.class)
public void testSaveWidgetTypeWithEmptyDescriptor() throws IOException {
WidgetsBundle widgetsBundle = new WidgetsBundle();
widgetsBundle.setTenantId(tenantId);
widgetsBundle.setTitle("Widgets bundle");
WidgetsBundle savedWidgetsBundle = widgetsBundleService.saveWidgetsBundle(widgetsBundle);
WidgetType widgetType = new WidgetType();
widgetType.setTenantId(tenantId);
widgetType.setName("Widget Type");
widgetType.setBundleAlias(savedWidgetsBundle.getAlias());
widgetType.setDescriptor(new ObjectMapper().readValue("{}", JsonNode.class));
try {
widgetTypeService.saveWidgetType(widgetType);
} finally {
widgetsBundleService.deleteWidgetsBundle(savedWidgetsBundle.getId());
}
}
Aggregations