Search in sources :

Example 41 with FacilitySoftwareConfig

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

the class MessageProcessingTest method testExecuteCustomerSendMessageJob1.

@Test
public void testExecuteCustomerSendMessageJob1() throws JobExecutionException {
    ListOperations<String, String> listOp = Mockito.mock(ListOperations.class);
    ValueOperations<String, String> valueOp = Mockito.mock(ValueOperations.class);
    when(template.opsForList()).thenReturn(listOp);
    when(listOp.leftPushAll(anyString(), anyString())).thenReturn(1L);
    when(template.hasKey(anyString())).thenReturn(false);
    when(template.opsForValue()).thenReturn(valueOp);
    when(valueOp.get(anyString())).thenReturn("19");
    FacilitySoftwareConfig fac1 = createFacilitySoftware();
    String unique_value1 = UUID.randomUUID().toString();
    fac1.setSubCategory("OtherDCIM_" + unique_value1);
    when(restClient.getFacilitySoftwareInternalByType(FacilitySoftwareConfig.SoftwareType.OtherDCIM)).thenReturn(getFacilitySoftwareByType(fac1));
    FacilitySoftwareConfig fac2 = createFacilitySoftware();
    fac2.setType(FacilitySoftwareConfig.SoftwareType.OtherCMDB);
    String unique_value2 = UUID.randomUUID().toString();
    fac2.setSubCategory("OtherCMDB_" + unique_value2);
    when(restClient.getFacilitySoftwareInternalByType(FacilitySoftwareConfig.SoftwareType.OtherCMDB)).thenReturn(getFacilitySoftwareByType(fac2));
    FacilityAdapter adapter = new FacilityAdapter();
    adapter.setSubCategory("OtherDCIM_" + unique_value1);
    AdapterJobCommand command1 = new AdapterJobCommand();
    command1.setCommand("syncmetadata");
    command1.setTriggerCycle(20);
    List<AdapterJobCommand> commands = new ArrayList<AdapterJobCommand>();
    commands.add(command1);
    adapter.setCommands(commands);
    adapter.setTopic(unique_value1);
    adapter.setQueueName(unique_value1 + ":joblist");
    FacilityAdapter adapter2 = new FacilityAdapter();
    adapter2.setSubCategory("OtherCMDB_" + unique_value2);
    AdapterJobCommand command2 = new AdapterJobCommand();
    command2.setCommand("syncmetadata");
    command2.setTriggerCycle(20);
    List<AdapterJobCommand> commands2 = new ArrayList<AdapterJobCommand>();
    commands2.add(command2);
    adapter2.setCommands(commands2);
    adapter2.setTopic(unique_value2);
    adapter2.setQueueName(unique_value2 + ":joblist");
    FacilityAdapter[] adapters = new FacilityAdapter[2];
    adapters[0] = adapter;
    adapters[1] = adapter2;
    when(restClient.getAllCustomerFacilityAdapters()).thenReturn(new ResponseEntity<FacilityAdapter[]>(adapters, HttpStatus.OK));
    customerAdapter.execute(null);
}
Also used : AdapterJobCommand(com.vmware.flowgate.common.model.AdapterJobCommand) ArrayList(java.util.ArrayList) FacilitySoftwareConfig(com.vmware.flowgate.common.model.FacilitySoftwareConfig) ArgumentMatchers.anyString(org.mockito.ArgumentMatchers.anyString) FacilityAdapter(com.vmware.flowgate.common.model.FacilityAdapter) SpringBootTest(org.springframework.boot.test.context.SpringBootTest) Test(org.junit.Test)

Example 42 with FacilitySoftwareConfig

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

the class SyncSensorMetaDataJobTest method getFacilitySoftwareByType.

public ResponseEntity<FacilitySoftwareConfig[]> getFacilitySoftwareByType(SoftwareType category) {
    FacilitySoftwareConfig[] configs = new FacilitySoftwareConfig[1];
    configs[0] = new FacilitySoftwareConfig();
    switch(category) {
        case PowerIQ:
            configs[0].setId("l9i8728d55368540fcba1692");
            break;
        case Nlyte:
            configs[0].setId("po09imkhdplbvf540fwusy67n");
        default:
            break;
    }
    configs[0].setType(category);
    return new ResponseEntity<FacilitySoftwareConfig[]>(configs, HttpStatus.OK);
}
Also used : ResponseEntity(org.springframework.http.ResponseEntity) FacilitySoftwareConfig(com.vmware.flowgate.common.model.FacilitySoftwareConfig)

Example 43 with FacilitySoftwareConfig

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

the class AssetControllerTest method readAssetsByPage.

@Test
public void readAssetsByPage() throws Exception {
    Asset asset1 = createAsset();
    asset1.setAssetName("assetname");
    asset1.setAssetNumber(18);
    asset1.setAssetSource(null);
    assetRepository.save(asset1);
    Asset asset2 = createAsset();
    asset2.setAssetName("assetname2");
    asset2.setAssetNumber(17);
    asset2.setAssetSource(null);
    assetRepository.save(asset2);
    FacilitySoftwareConfig facility = createFacilitySoftware();
    facilitySoftwareRepository.save(facility);
    int pageNumber = 1;
    int pageSize = 1;
    try {
        this.mockMvc.perform(get("/v1/assets/page/{pageNumber}/pagesize/{pageSize}", pageNumber, pageSize)).andExpect(status().isOk()).andDo(document("assets-getAssetsByPage-example", pathParameters(parameterWithName("pageNumber").description("The number of page you want to get."), parameterWithName("pageSize").description("The number of assets you want to get by every request.Default value:20")), responseFields(subsectionWithPath("content").description("An assets 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())));
    } finally {
        assetRepository.deleteById(asset1.getId());
        assetRepository.deleteById(asset2.getId());
        facilitySoftwareRepository.deleteById(facility.getId());
    }
}
Also used : Asset(com.vmware.flowgate.common.model.Asset) FacilitySoftwareConfig(com.vmware.flowgate.common.model.FacilitySoftwareConfig) SpringBootTest(org.springframework.boot.test.context.SpringBootTest) Test(org.junit.Test)

Example 44 with FacilitySoftwareConfig

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

the class AssetControllerTest method readAssetsByAssetNameAndTagLikAndKeywordsExample.

@Test
public void readAssetsByAssetNameAndTagLikAndKeywordsExample() throws Exception {
    Asset asset1 = createAsset();
    asset1.setAssetName("assetname");
    asset1.setAssetNumber(18);
    assetRepository.save(asset1);
    Asset asset2 = createAsset();
    asset2.setAssetName("assetname2");
    asset2.setAssetNumber(17);
    assetRepository.save(asset2);
    int pageNumber = 1;
    int pageSize = 1;
    String keywords = "keyword";
    FacilitySoftwareConfig facility = createFacilitySoftware();
    facilitySoftwareRepository.save(facility);
    try {
        this.mockMvc.perform(get("/v1/assets/page/{pageNumber}/pagesize/{pageSize}/keywords/{keywords}", pageNumber, pageSize, keywords)).andExpect(status().isOk()).andDo(document("assets-getByAssetNameAndTagLikAndKeywords-example", pathParameters(parameterWithName("pageNumber").description("The number of page you want to get."), parameterWithName("pageSize").description("The number of assets you want to get by every request.Default value:20"), parameterWithName("keywords").description("A part of asset name of asset tag.")), responseFields(subsectionWithPath("content").description("An assets 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())));
    } finally {
        assetRepository.deleteById(asset1.getId());
        assetRepository.deleteById(asset2.getId());
        facilitySoftwareRepository.deleteById(facility.getId());
    }
}
Also used : Asset(com.vmware.flowgate.common.model.Asset) FacilitySoftwareConfig(com.vmware.flowgate.common.model.FacilitySoftwareConfig) ArgumentMatchers.anyString(org.mockito.ArgumentMatchers.anyString) SpringBootTest(org.springframework.boot.test.context.SpringBootTest) Test(org.junit.Test)

Example 45 with FacilitySoftwareConfig

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

the class AssetControllerTest method createFacilitySoftware.

FacilitySoftwareConfig createFacilitySoftware() {
    FacilitySoftwareConfig example = new FacilitySoftwareConfig();
    example.setId("5b7d208d55368540fcba1692");
    example.setName("Nlyte");
    example.setType(FacilitySoftwareConfig.SoftwareType.Nlyte);
    example.setVerifyCert(false);
    return example;
}
Also used : 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