use of com.vmware.flowgate.common.model.FacilityAdapter in project flowgate by vmware.
the class FacilityAdapterControllerTest method findAllFacilityAdapterExample.
@Test
public void findAllFacilityAdapterExample() throws JsonProcessingException, Exception {
FacilityAdapter adapter = createAdapter();
adapter.setDisplayName("displayNameForTestfindall");
facilityAdapterRepo.save(adapter);
FieldDescriptor[] fieldpath = new FieldDescriptor[] { 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") };
this.mockMvc.perform(get("/v1/facilityadapter")).andExpect(status().isOk()).andExpect(jsonPath("$[0].displayName").value("displayNameForTestfindall")).andDo(document("facilityadapter-findAll-example", responseFields(fieldWithPath("[]").description("An array of facility adapters")).andWithPrefix("[].", fieldpath)));
facilityAdapterRepo.deleteById(adapter.getId());
}
use of com.vmware.flowgate.common.model.FacilityAdapter in project flowgate by vmware.
the class FacilityAdapterControllerTest method findAllFacilityAdapterByPageExample.
@Test
public void findAllFacilityAdapterByPageExample() throws JsonProcessingException, Exception {
FacilityAdapter adapter = createAdapter();
adapter.setDisplayName("displayNameForTestfindallByPage");
facilityAdapterRepo.save(adapter);
this.mockMvc.perform(get("/v1/facilityadapter/pagenumber/{pageNumber}/pagesize/{pageSize}", 1, 5)).andExpect(status().isOk()).andExpect(jsonPath("$..content[0].displayName").value("displayNameForTestfindallByPage")).andDo(document("facilityadapter-findByPage-example", pathParameters(parameterWithName("pageNumber").description("The page you want to get"), parameterWithName("pageSize").description("The number of facilityadapters you want to get by every request.Default value: 20")), responseFields(subsectionWithPath("content").description("FacilityAdapter's array."), fieldWithPath("totalPages").description("content's total pages."), fieldWithPath("totalElements").description("content's total elements."), fieldWithPath("last").description("Is the last."), fieldWithPath("number").description("The page number."), fieldWithPath("size").description("The page size."), fieldWithPath("sort").description("The sort."), fieldWithPath("numberOfElements").description("The number of Elements."), fieldWithPath("first").description("Is the first."), subsectionWithPath("pageable").description("pageable.").ignored(), subsectionWithPath("sort").description("sorted.").ignored(), fieldWithPath("empty").description("Is empty.").ignored())));
facilityAdapterRepo.deleteById(adapter.getId());
}
use of com.vmware.flowgate.common.model.FacilityAdapter in project flowgate by vmware.
the class FacilityAdapterControllerTest method createAdapter.
FacilityAdapter createAdapter() {
FacilityAdapter adapter = new FacilityAdapter();
adapter.setId(UUID.randomUUID().toString());
adapter.setDisplayName("defaultAdapter");
adapter.setType(SoftwareType.OtherCMDB);
adapter.setDescription("Default adapter for test");
List<AdapterJobCommand> commands = new ArrayList<AdapterJobCommand>();
AdapterJobCommand command = new AdapterJobCommand();
command.setCommand("syncmetadata");
command.setTriggerCycle(1440);
command.setDescription("sync metadata job");
commands.add(command);
AdapterJobCommand metricsCommand = new AdapterJobCommand();
metricsCommand.setCommand("syncmetricsdata");
metricsCommand.setTriggerCycle(5);
metricsCommand.setDescription("sync metrics data job");
commands.add(metricsCommand);
adapter.setCommands(commands);
return adapter;
}
use of com.vmware.flowgate.common.model.FacilityAdapter in project flowgate by vmware.
the class FacilityAdapterControllerTest method updateFacilityAdapterValidExistedExample.
@Test
public void updateFacilityAdapterValidExistedExample() throws JsonProcessingException, Exception {
FacilityAdapter adapter = createAdapter();
expectedEx.expect(WormholeRequestException.class);
expectedEx.expectMessage("Failed to find FacilityAdapter with field: id and value: " + adapter.getId() + "");
MvcResult result = this.mockMvc.perform(put("/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 createFacilityAdapterValidDisplayName1.
@Test
public void createFacilityAdapterValidDisplayName1() throws JsonProcessingException, Exception {
FacilityAdapter adapter = createAdapter();
adapter.setDisplayName("testdisplayName");
facilityAdapterRepo.save(adapter);
FacilityAdapter adapter1 = createAdapter();
adapter1.setDisplayName(adapter.getDisplayName());
expectedEx.expect(WormholeRequestException.class);
expectedEx.expectMessage("Adapter with dispalyName : testdisplayName is existed");
MvcResult result = this.mockMvc.perform(post("/v1/facilityadapter").contentType(MediaType.APPLICATION_JSON).content(objectMapper.writeValueAsString(adapter1))).andExpect(status().is4xxClientError()).andReturn();
facilityAdapterRepo.deleteById(adapter.getId());
if (result.getResolvedException() != null) {
throw result.getResolvedException();
} else {
TestCase.fail();
}
}
Aggregations