Search in sources :

Example 6 with FacilitySoftwareConfig

use of com.vmware.flowgate.common.model.FacilitySoftwareConfig in project flowgate by vmware.

the class FacilitySoftwareControllerTest method syncFacilityServerDataExample1.

@Test
public void syncFacilityServerDataExample1() 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.setPassword(EncryptionGuard.encode(facilitySoftware.getPassword()));
    facilitySoftware = facilitySoftwareRepository.save(facilitySoftware);
    try {
        MvcResult result = this.mockMvc.perform(post("/v1/facilitysoftware/syncdatabyserverid/" + facilitySoftware.getId() + "")).andReturn();
        if (result.getResolvedException() != null) {
            throw result.getResolvedException();
        }
    } finally {
        facilitySoftwareRepository.deleteById(facilitySoftware.getId());
    }
}
Also used : FacilitySoftwareConfig(com.vmware.flowgate.common.model.FacilitySoftwareConfig) MvcResult(org.springframework.test.web.servlet.MvcResult) SpringBootTest(org.springframework.boot.test.context.SpringBootTest) Test(org.junit.Test)

Example 7 with FacilitySoftwareConfig

use of com.vmware.flowgate.common.model.FacilitySoftwareConfig in project flowgate by vmware.

the class FacilitySoftwareControllerTest method createOpenManageThrowNotFoundException.

@Test
public void createOpenManageThrowNotFoundException() throws JsonProcessingException, Exception {
    OpenManageAuth openmanageAuth = Mockito.mock(OpenManageAuth.class);
    Mockito.doThrow(new HttpClientErrorException(HttpStatus.NOT_FOUND, "Not Found")).when(openmanageAuth).auth(Mockito.any(FacilitySoftwareConfig.class));
    Mockito.doReturn(createuser()).when(tokenService).getCurrentUser(any());
    Mockito.doReturn(openmanageAuth).when(serverValidationService).createOpenManageAuth();
    expectedEx.expect(WormholeRequestException.class);
    expectedEx.expectMessage("Unknown Host.Please check your server IP.");
    FacilitySoftwareConfig facilitySoftware = createFacilitySoftware();
    facilitySoftware.setType(SoftwareType.OpenManage);
    facilitySoftware.setName("myOpenManage");
    MvcResult result = this.mockMvc.perform(post("/v1/facilitysoftware").contentType(MediaType.APPLICATION_JSON).content(objectMapper.writeValueAsString(facilitySoftware))).andExpect(status().is4xxClientError()).andReturn();
    if (result.getResolvedException() != null) {
        throw result.getResolvedException();
    } else {
        TestCase.fail();
    }
}
Also used : HttpClientErrorException(org.springframework.web.client.HttpClientErrorException) OpenManageAuth(com.vmware.flowgate.auth.OpenManageAuth) FacilitySoftwareConfig(com.vmware.flowgate.common.model.FacilitySoftwareConfig) MvcResult(org.springframework.test.web.servlet.MvcResult) SpringBootTest(org.springframework.boot.test.context.SpringBootTest) Test(org.junit.Test)

Example 8 with FacilitySoftwareConfig

use of com.vmware.flowgate.common.model.FacilitySoftwareConfig in project flowgate by vmware.

the class FacilitySoftwareControllerTest method createFacilitySoftware.

FacilitySoftwareConfig createFacilitySoftware() throws Exception {
    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");
    HashMap advanceSetting = new HashMap<AdvanceSettingType, String>();
    example.setAdvanceSetting(advanceSetting);
    IntegrationStatus integrationStatus = new IntegrationStatus();
    integrationStatus.setDetail("");
    integrationStatus.setRetryCounter(0);
    integrationStatus.setStatus(Status.ACTIVE);
    example.setIntegrationStatus(integrationStatus);
    return example;
}
Also used : HashMap(java.util.HashMap) IntegrationStatus(com.vmware.flowgate.common.model.IntegrationStatus) FacilitySoftwareConfig(com.vmware.flowgate.common.model.FacilitySoftwareConfig)

Example 9 with FacilitySoftwareConfig

use of com.vmware.flowgate.common.model.FacilitySoftwareConfig in project flowgate by vmware.

the class SystemSummaryTest method createFacility.

FacilitySoftwareConfig createFacility() {
    FacilitySoftwareConfig facility = new FacilitySoftwareConfig();
    facility.setId(UUID.randomUUID().toString());
    return facility;
}
Also used : FacilitySoftwareConfig(com.vmware.flowgate.common.model.FacilitySoftwareConfig)

Example 10 with FacilitySoftwareConfig

use of com.vmware.flowgate.common.model.FacilitySoftwareConfig in project flowgate by vmware.

the class InfobloxServiceTest method getInfobloxFacilitySoftware.

private ResponseEntity<FacilitySoftwareConfig[]> getInfobloxFacilitySoftware() {
    FacilitySoftwareConfig[] facilitySoftwareConfigs = new FacilitySoftwareConfig[1];
    FacilitySoftwareConfig facilitySoftwareConfig = new FacilitySoftwareConfig();
    facilitySoftwareConfig.setPassword("O75xginpkAD748w=Lc20CrTzd1lEpvDTdJqH5IXBZTb5gYp7P8awDAs19F0=");
    facilitySoftwareConfig.setServerURL("https://10.161.71.133");
    facilitySoftwareConfig.setName("infoblox-1");
    facilitySoftwareConfig.setVerifyCert(false);
    IntegrationStatus integrationStatus = new IntegrationStatus();
    integrationStatus.setRetryCounter(0);
    integrationStatus.setDetail("");
    integrationStatus.setStatus(IntegrationStatus.Status.ACTIVE);
    facilitySoftwareConfig.setIntegrationStatus(integrationStatus);
    facilitySoftwareConfig.setUserName("admin");
    facilitySoftwareConfig.setType(FacilitySoftwareConfig.SoftwareType.InfoBlox);
    facilitySoftwareConfig.setUserId("e1edfv8953002379827896a1aaiqoose");
    facilitySoftwareConfigs[0] = facilitySoftwareConfig;
    return new ResponseEntity<>(facilitySoftwareConfigs, HttpStatus.OK);
}
Also used : ResponseEntity(org.springframework.http.ResponseEntity) IntegrationStatus(com.vmware.flowgate.common.model.IntegrationStatus) FacilitySoftwareConfig(com.vmware.flowgate.common.model.FacilitySoftwareConfig)

Aggregations

FacilitySoftwareConfig (com.vmware.flowgate.common.model.FacilitySoftwareConfig)60 Test (org.junit.Test)29 SpringBootTest (org.springframework.boot.test.context.SpringBootTest)29 ArrayList (java.util.ArrayList)13 Asset (com.vmware.flowgate.common.model.Asset)8 IntegrationStatus (com.vmware.flowgate.common.model.IntegrationStatus)8 MvcResult (org.springframework.test.web.servlet.MvcResult)8 EventMessage (com.vmware.flowgate.common.model.redis.message.EventMessage)7 IOException (java.io.IOException)7 ArgumentMatchers.anyString (org.mockito.ArgumentMatchers.anyString)7 RequestMapping (org.springframework.web.bind.annotation.RequestMapping)7 FacilityAdapter (com.vmware.flowgate.common.model.FacilityAdapter)6 AdapterJobCommand (com.vmware.flowgate.common.model.AdapterJobCommand)5 EventUser (com.vmware.flowgate.common.model.redis.message.EventUser)5 EventMessageImpl (com.vmware.flowgate.common.model.redis.message.impl.EventMessageImpl)5 HashMap (java.util.HashMap)5 ResponseEntity (org.springframework.http.ResponseEntity)5 RealTimeData (com.vmware.flowgate.common.model.RealTimeData)4 WormholeUser (com.vmware.flowgate.common.model.WormholeUser)4 WormholeUserDetails (com.vmware.flowgate.util.WormholeUserDetails)4