use of com.vmware.flowgate.common.model.FacilityAdapter in project flowgate by vmware.
the class FacilityAdapterControllerTest method createFacilityAdapterValidCommands.
@Test
public void createFacilityAdapterValidCommands() throws JsonProcessingException, Exception {
FacilityAdapter adapter = createAdapter();
adapter.setCommands(null);
expectedEx.expect(WormholeRequestException.class);
expectedEx.expectMessage("The Commands field is required.");
MvcResult result = this.mockMvc.perform(post("/v1/facilityadapter").contentType(MediaType.APPLICATION_JSON).content(objectMapper.writeValueAsString(adapter))).andExpect(status().is4xxClientError()).andReturn();
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 deleteFacilityAdapterExample.
@Test
public void deleteFacilityAdapterExample() throws Exception {
SetOperations<String, String> setop = Mockito.mock(SetOperations.class);
when(redis.opsForSet()).thenReturn(setop);
when(setop.isMember(anyString(), anyString())).thenReturn(true);
when(setop.remove(anyString(), anyString())).thenReturn(1l);
FacilityAdapter adapter = createAdapter();
facilityAdapterRepo.save(adapter);
this.mockMvc.perform(delete("/v1/facilityadapter/{Id}", adapter.getId())).andExpect(status().isOk()).andDo(document("facilityadapter-deleteById-example", pathParameters(parameterWithName("Id").description("The id of facility adapter,generated by flowgate.")))).andReturn();
}
use of com.vmware.flowgate.common.model.FacilityAdapter in project flowgate by vmware.
the class FacilityAdapterControllerTest method updateFacilityAdapterExample.
@Test
public void updateFacilityAdapterExample() throws JsonProcessingException, Exception {
FacilityAdapter adapter = createAdapter();
facilityAdapterRepo.save(adapter);
adapter.setDisplayName("displayNameForTestUpdate");
this.mockMvc.perform(put("/v1/facilityadapter").contentType(MediaType.APPLICATION_JSON).content(objectMapper.writeValueAsString(adapter))).andExpect(status().isOk()).andDo(document("facilityadapter-update-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();
facilityAdapterRepo.deleteById(adapter.getId());
}
use of com.vmware.flowgate.common.model.FacilityAdapter in project flowgate by vmware.
the class FacilityAdapterControllerTest method createFacilityAdapterValidDisplayName.
@Test
public void createFacilityAdapterValidDisplayName() throws JsonProcessingException, Exception {
FacilityAdapter adapter = createAdapter();
adapter.setDisplayName("Nlyte");
expectedEx.expect(WormholeRequestException.class);
expectedEx.expectMessage("Invalid value: 'Nlyte' for field: 'DisplayName' ");
MvcResult result = this.mockMvc.perform(post("/v1/facilityadapter").contentType(MediaType.APPLICATION_JSON).content(objectMapper.writeValueAsString(adapter))).andExpect(status().is4xxClientError()).andReturn();
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 FacilityAdapterService method deleteAdapter.
public void deleteAdapter(String id) {
FacilityAdapter adapter = findById(id);
int count = facilitySoftwareRepo.countFacilityBySubcategory(adapter.getSubCategory());
if (count > 0) {
throw new WormholeRequestException("Adapter deletion failed, there are some integration instances are using it");
} else {
facilityAdapterRepo.deleteById(id);
if (redis.opsForSet().isMember(FlowgateConstant.SERVICE_KEY_SET, adapter.getServiceKey())) {
redis.opsForSet().remove(FlowgateConstant.SERVICE_KEY_SET, adapter.getServiceKey());
}
}
}
Aggregations