@@ -0,0 +1,2458 @@
+/*%0A * Copyright 2016 JBoss by Red Hat.%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 */%0A%0Apackage org.drools.workbench.screens.drltext.backend.server;%0A%0Aimport static org.junit.Assert.fail;%0Aimport static org.mockito.Matchers.any;%0Aimport static org.mockito.Matchers.anyString;%0Aimport static org.mockito.Mockito.mock;%0Aimport static org.mockito.Mockito.never;%0Aimport static org.mockito.Mockito.verify;%0Aimport static org.mockito.Mockito.when;%0A%0Aimport java.net.URISyntaxException;%0A%0Aimport org.junit.runner.RunWith;%0Aimport org.junit.Test;%0Aimport org.kie.workbench.common.services.shared.project.KieProjectService;%0Aimport org.mockito.InjectMocks;%0Aimport org.mockito.runners.MockitoJUnitRunner;%0Aimport org.uberfire.io.IOService;%0Aimport org.uberfire.backend.vfs.Path;%0Aimport org.uberfire.backend.vfs.PathFactory;%0Aimport org.uberfire.java.nio.file.FileAlreadyExistsException;%0Aimport org.uberfire.java.nio.file.OpenOption;%0A%0A@RunWith(MockitoJUnitRunner.class)%0Apublic class DRLTextEditorServiceImplTest %7B%0A%0A    private IOService ioService = mock(IOService.class);%0A    private KieProjectService projectService = mock(KieProjectService.class);%0A%0A    @InjectMocks%0A    private DRLTextEditorServiceImpl drlService = new DRLTextEditorServiceImpl();%0A%0A    private String filename = %22test.drl%22;%0A    private Path path2 = PathFactory.newPath(%22contextpath%22, %22file:///contextpath%22);%0A%0A    @Test%0A    public void testCreateAlreadyExisting() throws URISyntaxException %7B%0A        when(ioService.exists(any(org.uberfire.java.nio.file.Path.class))).thenReturn(true);%0A%0A        try %7B%0A            drlService.create(path2, filename, %22%22, %22%22);%0A            fail(%22FileAlreadyExistsException was not thrown when expected!%22);%0A        %7D catch (FileAlreadyExistsException faee) %7B%0A            // this is correct behavior, anz other exception is a problem%0A        %7D%0A        verify(ioService, never()).write(any(org.uberfire.java.nio.file.Path.class), anyString(), any(OpenOption.class));%0A    %7D%0A%7D%0A

add test for BZ 1048265 (#179)