@@ -0,0 +1,2977 @@
+/*%0A * Zed Attack Proxy (ZAP) and its related class files.%0A *%0A * ZAP is an HTTP/HTTPS proxy for assessing web application security.%0A *%0A * Copyright 2019 The ZAP Development Team%0A *%0A * Licensed under the Apache License, Version 2.0 (the %22License%22);%0A * you may not use this file except in compliance with the License.%0A * You may obtain a copy of the License at%0A *%0A *     http://www.apache.org/licenses/LICENSE-2.0%0A *%0A * Unless required by applicable law or agreed to in writing, software%0A * distributed under the License is distributed on an %22AS IS%22 BASIS,%0A * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.%0A * See the License for the specific language governing permissions and%0A * limitations under the License.%0A */%0Apackage org.zaproxy.zap.extension.websocket.alerts;%0A%0Aimport static org.junit.Assert.*;%0Aimport static org.mockito.Mockito.mock;%0A%0Aimport org.junit.Before;%0Aimport org.junit.Test;%0Aimport org.parosproxy.paros.core.scanner.Alert;%0Aimport org.zaproxy.zap.extension.websocket.WebSocketChannelDTO;%0Aimport org.zaproxy.zap.extension.websocket.WebSocketMessageDTO;%0Aimport org.zaproxy.zap.testutils.WebSocketTestUtils;%0A%0Apublic class WebSocketAlertRaiserUnitTest extends WebSocketTestUtils %7B%0A%0A    @Before%0A    public void setUp() throws Exception %7B%0A        super.setUpZap();%0A    %7D%0A%0A    @Test%0A    public void shouldBuildAlert() %7B%0A        // Given%0A        WebSocketAlertThread webSocketAlertThread = mock(WebSocketAlertThread.class);%0A        WebSocketMessageDTO message = mock(WebSocketMessageDTO.class);%0A        message.channel = mock(WebSocketChannelDTO.class);%0A        WebSocketAlertRaiser alertRaiser =%0A                new WebSocketAlertRaiser(webSocketAlertThread, 0, message);%0A%0A        // When%0A        alertRaiser.setName(%22Name%22);%0A        alertRaiser.setDescription(%22Description%22);%0A        alertRaiser.setSource(Alert.Source.MANUAL);%0A        WebSocketAlertWrapper alertWrapper = alertRaiser.raise();%0A%0A        // Then%0A        assertEquals(0, alertWrapper.getAlert().getPluginId());%0A        assertEquals(Alert.Source.MANUAL, alertWrapper.getSource());%0A        assertEquals(%22Name%22, alertWrapper.getName());%0A        assertEquals(%22Description%22, alertWrapper.getDescription());%0A    %7D%0A%0A    @Test%0A    public void shouldNotBuildAlertWhenMissingNameAndSource() %7B%0A        // Given%0A        WebSocketAlertThread webSocketAlertThread = mock(WebSocketAlertThread.class);%0A        WebSocketMessageDTO message = mock(WebSocketMessageDTO.class);%0A        message.channel = mock(WebSocketChannelDTO.class);%0A        WebSocketAlertRaiser alertRaiser =%0A                new WebSocketAlertRaiser(webSocketAlertThread, 0, message);%0A        try %7B%0A            // When%0A            alertRaiser.raise();%0A            // Then%0A            fail(%22Expected an IllegalStateException to be thrown%22);%0A        %7D catch (IllegalStateException e) %7B%0A            assertTrue(e.getMessage().contains(%22Alert Name%22));%0A            assertTrue(e.getMessage().contains(%22Alert Source%22));%0A        %7D%0A    %7D%0A%7D%0A

Add Unit Test for WebSocketAlertRaiser