Search in sources :

Example 1 with EventMessage

use of com.vmware.flowgate.common.model.redis.message.EventMessage in project flowgate by vmware.

the class InfobloxServiceTest method testExecuteAsyncNotFindIP.

@Test
public void testExecuteAsyncNotFindIP() {
    EventMessage eventMessage = EventMessageUtil.createEventMessage(EventType.InfoBlox, null, "10.161.71.154");
    ResponseEntity<FacilitySoftwareConfig[]> infobloxFacilitySoftware = this.getInfobloxFacilitySoftware();
    Mockito.doReturn(infobloxFacilitySoftware).when(wormholeAPIClient).getFacilitySoftwareInternalByType(FacilitySoftwareConfig.SoftwareType.InfoBlox);
    Mockito.doReturn(new ArrayList<>()).when(infobloxClient).queryHostRecordByIP(Mockito.anyString());
    Mockito.doReturn(null).when(infobloxClient).queryIpv4addressByIP(Mockito.anyString());
    infoBloxService.executeAsync(eventMessage);
    TestCase.assertEquals(IntegrationStatus.Status.ACTIVE, Objects.requireNonNull(infobloxFacilitySoftware.getBody())[0].getIntegrationStatus().getStatus());
}
Also used : EventMessage(com.vmware.flowgate.common.model.redis.message.EventMessage) Test(org.junit.Test) SpringBootTest(org.springframework.boot.test.context.SpringBootTest)

Example 2 with EventMessage

use of com.vmware.flowgate.common.model.redis.message.EventMessage in project flowgate by vmware.

the class EventMessageUtil method createEventMessage.

public static EventMessage createEventMessage(EventType type, String targetCommand, String message) {
    EventUser targetUser = new EventUserImpl(targetCommand);
    Set<EventUser> users = new HashSet<EventUser>();
    users.add(targetUser);
    EventTarget target = new EventTargetImpl(users);
    EventMessage newMessage = new EventMessageImpl(type, null, null, target, new Date().getTime(), message);
    return newMessage;
}
Also used : EventMessage(com.vmware.flowgate.common.model.redis.message.EventMessage) EventUser(com.vmware.flowgate.common.model.redis.message.EventUser) EventTarget(com.vmware.flowgate.common.model.redis.message.EventTarget) Date(java.util.Date) HashSet(java.util.HashSet)

Example 3 with EventMessage

use of com.vmware.flowgate.common.model.redis.message.EventMessage in project flowgate by vmware.

the class EventMessageUtil method generateFacilityNotifyMessage.

public static String generateFacilityNotifyMessage(EventType type) throws IOException {
    String command = typeAndCommandIdMap.get(type);
    if (command == null) {
        return null;
    }
    EventMessage message = EventMessageUtil.createEventMessage(type, command, "");
    ;
    return EventMessageUtil.convertEventMessageAsString(message);
}
Also used : EventMessage(com.vmware.flowgate.common.model.redis.message.EventMessage)

Example 4 with EventMessage

use of com.vmware.flowgate.common.model.redis.message.EventMessage in project flowgate by vmware.

the class RedisMessageReceiver method receiveMessage.

@Override
public void receiveMessage(String message) {
    try {
        EventMessage eventMessage = mapper.readValue(message, EventMessageImpl.class);
        asyncService.executeAsync(eventMessage);
    } catch (IOException e) {
        logger.error(String.format("Failed prase message:%s ", message), e);
    }
}
Also used : EventMessage(com.vmware.flowgate.common.model.redis.message.EventMessage) IOException(java.io.IOException)

Example 5 with EventMessage

use of com.vmware.flowgate.common.model.redis.message.EventMessage in project flowgate by vmware.

the class RedisMessageReceiver method receiveMessage.

@Override
public void receiveMessage(String message) {
    try {
        EventMessage eventMessage = mapper.readValue(message, EventMessageImpl.class);
        asyncService.executeAsync(eventMessage);
    } catch (IOException e) {
        logger.info(String.format("Failed prase message %s", message));
    }
}
Also used : EventMessage(com.vmware.flowgate.common.model.redis.message.EventMessage) IOException(java.io.IOException)

Aggregations

EventMessage (com.vmware.flowgate.common.model.redis.message.EventMessage)33 IOException (java.io.IOException)24 EventUser (com.vmware.flowgate.common.model.redis.message.EventUser)8 EventMessageImpl (com.vmware.flowgate.common.model.redis.message.impl.EventMessageImpl)8 FacilitySoftwareConfig (com.vmware.flowgate.common.model.FacilitySoftwareConfig)7 Test (org.junit.Test)6 SDDCSoftwareConfig (com.vmware.flowgate.common.model.SDDCSoftwareConfig)5 SpringBootTest (org.springframework.boot.test.context.SpringBootTest)5 Asset (com.vmware.flowgate.common.model.Asset)4 WormholeRequestException (com.vmware.flowgate.exception.WormholeRequestException)4 RequestMapping (org.springframework.web.bind.annotation.RequestMapping)4 ResponseStatus (org.springframework.web.bind.annotation.ResponseStatus)4 ArrayList (java.util.ArrayList)3 ArgumentMatchers.anyString (org.mockito.ArgumentMatchers.anyString)3 Async (org.springframework.scheduling.annotation.Async)3 ObjectMapper (com.fasterxml.jackson.databind.ObjectMapper)2 AssetIPMapping (com.vmware.flowgate.common.model.AssetIPMapping)2 Date (java.util.Date)2 AdapterJobCommand (com.vmware.flowgate.common.model.AdapterJobCommand)1 IntegrationStatus (com.vmware.flowgate.common.model.IntegrationStatus)1