use of org.thingsboard.server.common.data.widget.WidgetTypeDetails in project thingsboard by thingsboard.
the class BaseWidgetTypeControllerTest method testSaveWidgetTypeWithEmptyDescriptor.
@Test
public void testSaveWidgetTypeWithEmptyDescriptor() throws Exception {
WidgetTypeDetails widgetType = new WidgetTypeDetails();
widgetType.setBundleAlias(savedWidgetsBundle.getAlias());
widgetType.setName("Widget Type");
widgetType.setDescriptor(new ObjectMapper().readValue("{}", JsonNode.class));
doPost("/api/widgetType", widgetType).andExpect(status().isBadRequest()).andExpect(statusReason(containsString("Widgets type descriptor can't be empty")));
}
use of org.thingsboard.server.common.data.widget.WidgetTypeDetails in project thingsboard by thingsboard.
the class BaseWidgetTypeControllerTest method testSaveWidgetTypeWithEmptyName.
@Test
public void testSaveWidgetTypeWithEmptyName() throws Exception {
WidgetTypeDetails widgetType = new WidgetTypeDetails();
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.WidgetTypeDetails in project thingsboard by thingsboard.
the class BaseWidgetTypeControllerTest method testDeleteWidgetType.
@Test
public void testDeleteWidgetType() throws Exception {
WidgetTypeDetails widgetType = new WidgetTypeDetails();
widgetType.setBundleAlias(savedWidgetsBundle.getAlias());
widgetType.setName("Widget Type");
widgetType.setDescriptor(new ObjectMapper().readValue("{ \"someKey\": \"someValue\" }", JsonNode.class));
WidgetTypeDetails savedWidgetType = doPost("/api/widgetType", widgetType, WidgetTypeDetails.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.WidgetTypeDetails in project thingsboard by thingsboard.
the class BaseWidgetTypeControllerTest method testUpdateWidgetTypeFromDifferentTenant.
@Test
public void testUpdateWidgetTypeFromDifferentTenant() throws Exception {
WidgetTypeDetails widgetType = new WidgetTypeDetails();
widgetType.setBundleAlias(savedWidgetsBundle.getAlias());
widgetType.setName("Widget Type");
widgetType.setDescriptor(new ObjectMapper().readValue("{ \"someKey\": \"someValue\" }", JsonNode.class));
WidgetTypeDetails savedWidgetType = doPost("/api/widgetType", widgetType, WidgetTypeDetails.class);
loginDifferentTenant();
doPost("/api/widgetType", savedWidgetType, WidgetTypeDetails.class, status().isForbidden());
deleteDifferentTenant();
}
use of org.thingsboard.server.common.data.widget.WidgetTypeDetails in project thingsboard by thingsboard.
the class BaseWidgetTypeControllerTest method testGetWidgetType.
@Test
public void testGetWidgetType() throws Exception {
WidgetTypeDetails widgetType = new WidgetTypeDetails();
widgetType.setBundleAlias(savedWidgetsBundle.getAlias());
widgetType.setName("Widget Type");
widgetType.setDescriptor(new ObjectMapper().readValue("{ \"someKey\": \"someValue\" }", JsonNode.class));
WidgetTypeDetails savedWidgetType = doPost("/api/widgetType", widgetType, WidgetTypeDetails.class);
WidgetType foundWidgetType = doGet("/api/widgetType?isSystem={isSystem}&bundleAlias={bundleAlias}&alias={alias}", WidgetType.class, false, savedWidgetsBundle.getAlias(), savedWidgetType.getAlias());
Assert.assertNotNull(foundWidgetType);
Assert.assertEquals(new WidgetType(savedWidgetType), foundWidgetType);
}
Aggregations