use of com.vmware.flowgate.common.model.FacilitySoftwareConfig 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();
}
}
use of com.vmware.flowgate.common.model.FacilitySoftwareConfig in project flowgate by vmware.
the class FacilitySoftwareControllerTest method facilitySoftwareQueryByPageAndTypeExample.
// facilitySoftwareConfigsByType
@Test
public void facilitySoftwareQueryByPageAndTypeExample() throws Exception {
WormholeUserDetails userDeails = createuser();
userDeails.setUserId("5b7d208d55368540fcba1692");
Mockito.doReturn(userDeails).when(tokenService).getCurrentUser(any());
WormholeUser user = new WormholeUser();
user.setId("5b7d208d55368540fcba1692");
List<String> roles = new ArrayList<String>();
roles.add("admin");
user.setRoleNames(roles);
userRepository.save(user);
// userId of the facilitySoftware is not '5b7d208d55368540fcba1692'
FacilitySoftwareConfig facilitySoftware = createFacilitySoftware();
facilitySoftware.setPassword(EncryptionGuard.encode(facilitySoftware.getPassword()));
facilitySoftwareRepository.save(facilitySoftware);
int pageNumber = 1;
int pageSize = 5;
try {
this.mockMvc.perform(get("/v1/facilitysoftware/page/{pageNumber}/pagesize/{pageSize}", pageNumber, pageSize).param("softwaretypes", "Nlyte")).andExpect(status().isOk()).andExpect(jsonPath("$..content[0].name").value(facilitySoftware.getName())).andExpect(jsonPath("$..content[0].userId").value(facilitySoftware.getUserId())).andExpect(jsonPath("$..content[0].type").value(facilitySoftware.getType().name())).andDo(document("facilitySoftware-queryByTypeAndPage-example", pathParameters(parameterWithName("pageNumber").description("Get datas for this page number."), parameterWithName("pageSize").description("The number of facilitysoftwares you want to get by every request.Default value: 20")), requestParameters(parameterWithName("softwaretypes").description("A list of software, maybe contain Nlyte/PowerIQ/InfoBlox/OpenManage/Labsdb"))));
} finally {
facilitySoftwareRepository.deleteById(facilitySoftware.getId());
userRepository.deleteById(user.getId());
}
}
use of com.vmware.flowgate.common.model.FacilitySoftwareConfig in project flowgate by vmware.
the class FacilitySoftwareControllerTest method facilitySoftwareQueryByPageExample.
// admin can find all facilitySoftwareConfigs
@Test
public void facilitySoftwareQueryByPageExample() throws Exception {
WormholeUserDetails userDeails = createuser();
userDeails.setUserId("5b7d208d55368540fcba1692");
Mockito.doReturn(userDeails).when(tokenService).getCurrentUser(any());
WormholeUser user = new WormholeUser();
user.setId("5b7d208d55368540fcba1692");
List<String> roles = new ArrayList<String>();
roles.add("admin");
user.setRoleNames(roles);
userRepository.save(user);
// userId of the facilitySoftware is not '5b7d208d55368540fcba1692'
FacilitySoftwareConfig facilitySoftware = createFacilitySoftware();
facilitySoftware.setPassword(EncryptionGuard.encode(facilitySoftware.getPassword()));
facilitySoftwareRepository.save(facilitySoftware);
int pageNumber = 1;
int pageSize = 5;
try {
this.mockMvc.perform(get("/v1/facilitysoftware/page/{pageNumber}/pagesize/{pageSize}", pageNumber, pageSize)).andExpect(status().isOk()).andExpect(jsonPath("$..content[0].name").value(facilitySoftware.getName())).andExpect(jsonPath("$..content[0].userId").value(facilitySoftware.getUserId())).andDo(document("facilitySoftware-queryByPage-example", pathParameters(parameterWithName("pageNumber").description("Get datas for this page number."), parameterWithName("pageSize").description("The number of facilitysoftwares you want to get by every request.Default value: 20"))));
} finally {
facilitySoftwareRepository.deleteById(facilitySoftware.getId());
userRepository.deleteById(user.getId());
}
}
use of com.vmware.flowgate.common.model.FacilitySoftwareConfig in project flowgate by vmware.
the class FacilitySoftwareControllerTest method getInternalFacilitySoftwareConfigByIDExample.
@Test
public void getInternalFacilitySoftwareConfigByIDExample() throws Exception {
Mockito.doReturn(createuser()).when(tokenService).getCurrentUser(any());
FacilitySoftwareConfig facilitySoftware1 = createFacilitySoftware();
facilitySoftware1.setName("1");
facilitySoftware1.setPassword(EncryptionGuard.encode(facilitySoftware1.getPassword()));
facilitySoftwareRepository.save(facilitySoftware1);
try {
this.mockMvc.perform(get("/v1/facilitysoftware/internal/" + facilitySoftware1.getId())).andExpect(status().isOk());
} finally {
facilitySoftwareRepository.deleteById(facilitySoftware1.getId());
}
}
use of com.vmware.flowgate.common.model.FacilitySoftwareConfig in project flowgate by vmware.
the class FacilitySoftwareControllerTest method syncDataForOpenmanageExample.
@Test
public void syncDataForOpenmanageExample() throws JsonProcessingException, Exception {
ListOperations<String, String> listOperations = Mockito.mock(ListOperations.class);
Mockito.doReturn(0L).when(listOperations).leftPush(Mockito.anyString(), Mockito.anyString());
Mockito.doReturn(listOperations).when(template).opsForList();
Mockito.doNothing().when(publisher).publish(Mockito.anyString(), Mockito.anyString());
FacilitySoftwareConfig facilitySoftware = createFacilitySoftware();
facilitySoftware.setType(FacilitySoftwareConfig.SoftwareType.OpenManage);
facilitySoftware.setPassword(EncryptionGuard.encode(facilitySoftware.getPassword()));
facilitySoftware = facilitySoftwareRepository.save(facilitySoftware);
try {
MvcResult result = this.mockMvc.perform(post("/v1/facilitysoftware/syncdatabyserverid/" + facilitySoftware.getId() + "")).andDo(document("facilitySoftware-syncFacilityServerData-example")).andReturn();
if (result.getResolvedException() != null) {
throw result.getResolvedException();
}
} finally {
facilitySoftwareRepository.deleteById(facilitySoftware.getId());
}
}
Aggregations