use of com.vmware.flowgate.common.model.SDDCSoftwareConfig in project flowgate by vmware.
the class VCDataServiceTest method testGetVaildServerMapping.
@Test
public void testGetVaildServerMapping() {
SDDCSoftwareConfig vc = Mockito.mock(SDDCSoftwareConfig.class);
String serviceKey = "serviceKey";
when(serviceKeyConfig.getServiceKey()).thenReturn(serviceKey);
doNothing().when(restClient).setServiceKey(serviceKey);
when(vc.getId()).thenReturn("id");
ServerMapping mapping1 = new ServerMapping();
mapping1.setVcMobID("vc1");
mapping1.setAsset("asset1");
ServerMapping mapping2 = new ServerMapping();
mapping2.setVcMobID("vc2");
mapping2.setAsset("asset2");
ServerMapping[] mappings = { mapping1, mapping2 };
ResponseEntity<ServerMapping[]> serverMappings = new ResponseEntity<ServerMapping[]>(mappings, HttpStatus.OK);
when(restClient.getServerMappingsByVC(anyString())).thenReturn(serverMappings);
Map<String, ServerMapping> mobIdDictionary = service.getVaildServerMapping(vc);
TestCase.assertEquals(mapping1, mobIdDictionary.get(mapping1.getVcMobID()));
TestCase.assertEquals(mapping2, mobIdDictionary.get(mapping2.getVcMobID()));
}
use of com.vmware.flowgate.common.model.SDDCSoftwareConfig in project flowgate by vmware.
the class SDDCSoftwareControllerTest method testGetInternalServerConfigsByType.
@Test
public void testGetInternalServerConfigsByType() throws Exception {
SDDCSoftwareConfig sddc1Create = createSDDCSoftwareConfig(SoftwareType.VCENTER);
sddc1Create.setType(SoftwareType.VCENTER);
sddc1Create.setName("flowgate");
sddc1Create.setDescription("flowgate cluster");
SDDCSoftwareConfig sddc2Create = createSDDCSoftwareConfig(SoftwareType.VCENTER);
sddc2Create.setType(SoftwareType.VCENTER);
sddc1Create.setPassword(EncryptionGuard.encode(sddc1Create.getPassword()));
sddc2Create.setPassword(EncryptionGuard.encode(sddc2Create.getPassword()));
sddcRepository.save(sddc1Create);
sddcRepository.save(sddc2Create);
MvcResult result = this.mockMvc.perform(get("/v1/sddc/internal/type/" + SoftwareType.VCENTER)).andExpect(status().isOk()).andReturn();
String res = result.getResponse().getContentAsString();
ObjectMapper mapper = new ObjectMapper();
SDDCSoftwareConfig[] sddcs = mapper.readValue(res, SDDCSoftwareConfig[].class);
for (SDDCSoftwareConfig sddc : sddcs) {
if (sddc.getName().equals("flowgate")) {
TestCase.assertEquals("flowgate cluster", sddc.getDescription());
}
}
sddcRepository.deleteById(sddc1Create.getId());
sddcRepository.deleteById(sddc2Create.getId());
}
use of com.vmware.flowgate.common.model.SDDCSoftwareConfig in project flowgate by vmware.
the class SDDCSoftwareControllerTest method createSDDCSoftwareConfig.
SDDCSoftwareConfig createSDDCSoftwareConfig(SoftwareType type) {
SDDCSoftwareConfig example = new SDDCSoftwareConfig();
example.setId(UUID.randomUUID().toString());
example.setName("test server");
example.setServerURL("10.160.30.134");
example.setType(type);
example.setUserName("administrator@vsphere.local");
example.setPassword("Admin!23");
example.setUserId("1001");
example.setVerifyCert(false);
example.setDescription("description");
IntegrationStatus integrationStatus = new IntegrationStatus();
example.setIntegrationStatus(integrationStatus);
return example;
}
use of com.vmware.flowgate.common.model.SDDCSoftwareConfig in project flowgate by vmware.
the class SDDCSoftwareControllerTest method sDDCSoftwareDeleteVroAndVropsMpExample.
@Test
public void sDDCSoftwareDeleteVroAndVropsMpExample() throws Exception {
SDDCSoftwareConfig sddc = createSDDCSoftwareConfig(SoftwareType.VRO);
sddcRepository.save(sddc);
ServerMapping serverMapping1 = createServerMapping(SoftwareType.VRO, sddc.getId());
serverMappingRepository.save(serverMapping1);
ServerMapping serverMapping2 = createServerMapping(SoftwareType.VRO, sddc.getId());
serverMappingRepository.save(serverMapping2);
this.mockMvc.perform(delete("/v1/sddc/" + sddc.getId())).andExpect(status().isOk());
Optional<ServerMapping> serverMappingOptional1 = serverMappingRepository.findById(serverMapping1.getId());
TestCase.assertEquals(false, serverMappingOptional1.isPresent());
Optional<ServerMapping> serverMappingOptional2 = serverMappingRepository.findById(serverMapping2.getId());
TestCase.assertEquals(false, serverMappingOptional2.isPresent());
Optional<SDDCSoftwareConfig> sddcOptional = sddcRepository.findById(sddc.getId());
TestCase.assertEquals(false, sddcOptional.isPresent());
}
use of com.vmware.flowgate.common.model.SDDCSoftwareConfig in project flowgate by vmware.
the class SDDCSoftwareControllerTest method sDDCSoftwareDeleteVcenterExample.
@Test
public void sDDCSoftwareDeleteVcenterExample() throws Exception {
SDDCSoftwareConfig sddc = createSDDCSoftwareConfig(SoftwareType.VCENTER);
sddcRepository.save(sddc);
ServerMapping serverMapping1 = createServerMapping(SoftwareType.VCENTER, sddc.getId());
serverMappingRepository.save(serverMapping1);
ServerMapping serverMapping2 = createServerMapping(SoftwareType.VCENTER, sddc.getId());
serverMappingRepository.save(serverMapping2);
this.mockMvc.perform(delete("/v1/sddc/{Id}", sddc.getId())).andExpect(status().isOk()).andDo(document("SDDCSoftware-delete-example", pathParameters(parameterWithName("Id").description("The id of SDDCSoftwareConfig, generated by flowgate."))));
Optional<ServerMapping> serverMappingOptional1 = serverMappingRepository.findById(serverMapping1.getId());
TestCase.assertEquals(false, serverMappingOptional1.isPresent());
Optional<ServerMapping> serverMappingOptional2 = serverMappingRepository.findById(serverMapping2.getId());
TestCase.assertEquals(false, serverMappingOptional2.isPresent());
Optional<SDDCSoftwareConfig> sddcOptional = sddcRepository.findById(sddc.getId());
TestCase.assertEquals(false, sddcOptional.isPresent());
}
Aggregations