use of com.vmware.flowgate.common.model.FacilityAdapter in project flowgate by vmware.
the class FacilityAdapterControllerTest method updateFacilityAdapterValidCommandsExample.
@Test
public void updateFacilityAdapterValidCommandsExample() throws JsonProcessingException, Exception {
FacilityAdapter adapter = createAdapter();
facilityAdapterRepo.save(adapter);
adapter.setCommands(null);
expectedEx.expect(WormholeRequestException.class);
expectedEx.expectMessage("The Commands field is required.");
MvcResult result = this.mockMvc.perform(put("/v1/facilityadapter").contentType(MediaType.APPLICATION_JSON).content(objectMapper.writeValueAsString(adapter))).andExpect(status().is4xxClientError()).andReturn();
facilityAdapterRepo.deleteById(adapter.getId());
if (result.getResolvedException() != null) {
throw result.getResolvedException();
} else {
TestCase.fail();
}
}
use of com.vmware.flowgate.common.model.FacilityAdapter in project flowgate by vmware.
the class FacilityAdapterControllerTest method createFacilityAdapterExample.
@Test
public void createFacilityAdapterExample() throws JsonProcessingException, Exception {
SetOperations<String, String> setop = Mockito.mock(SetOperations.class);
when(redis.opsForSet()).thenReturn(setop);
when(setop.add(anyString(), anyString())).thenReturn(1l);
FacilityAdapter adapter = createAdapter();
this.mockMvc.perform(post("/v1/facilityadapter").contentType(MediaType.APPLICATION_JSON).content(objectMapper.writeValueAsString(adapter))).andExpect(status().isCreated()).andExpect(header().string("Location", notNullValue())).andDo(document("facilityadapter-create-example", requestFields(fieldWithPath("id").description("ID of the facility adapter, created by flowgate"), fieldWithPath("displayName").description("Display name of the facility adapter, created by user"), fieldWithPath("type").description("Type of the facility adapter"), fieldWithPath("description").description("Description of the facility adapter"), fieldWithPath("topic").description("Topic of the facility adapter,created by flowgate"), fieldWithPath("subCategory").description("Subcategory of the facility adapter,created by flowgate"), fieldWithPath("queueName").description("Queue name of the facility adapter,created by flowgate"), fieldWithPath("serviceKey").description("Value for auth,created by flowgate"), fieldWithPath("createTime").description("Create time of the facility adapter,created by flowgate"), subsectionWithPath("commands").description("Job commands of the facility adapter,it should be not null")))).andReturn().getResponse().getHeader("Location");
facilityAdapterRepo.deleteById(adapter.getId());
}
use of com.vmware.flowgate.common.model.FacilityAdapter in project flowgate by vmware.
the class FacilityAdapterControllerTest method deleteFacilityAdapterThrowExceptionExample.
@Test
public void deleteFacilityAdapterThrowExceptionExample() throws Exception {
FacilityAdapter adapter = createAdapter();
String subcategory = "OtherDCIM_" + UUID.randomUUID().toString();
adapter.setSubCategory(subcategory);
facilityAdapterRepo.save(adapter);
FacilitySoftwareConfig example = new FacilitySoftwareConfig();
example.setId(UUID.randomUUID().toString());
example.setName("Nlyte");
example.setUserName("administrator@vsphere.local");
example.setPassword("Admin!23");
example.setServerURL("https://10.160.30.134");
example.setType(FacilitySoftwareConfig.SoftwareType.Nlyte);
example.setUserId("1");
example.setVerifyCert(false);
example.setDescription("description");
example.setSubCategory(subcategory);
facilitySoftwareRepo.save(example);
expectedEx.expect(WormholeRequestException.class);
expectedEx.expectMessage("Adapter deletion failed, there are some integration instances are using it");
MvcResult result = this.mockMvc.perform(delete("/v1/facilityadapter/" + adapter.getId() + "").content("{\"id\":\"" + adapter.getId() + "\"}")).andReturn();
if (result.getResolvedException() != null) {
facilityAdapterRepo.deleteById(adapter.getId());
facilitySoftwareRepo.deleteById(example.getId());
throw result.getResolvedException();
} else {
TestCase.fail();
}
}
Aggregations