@Test
public void testPublishTemplate_NewTemplateInRepo_NoOverwriteRequired() throws Exception {

    ExportTemplate template = new ExportTemplate("testFile", "testTemplate", "testDesc", false, new byte[0]);
    when(templateExporter.exportTemplate(anyString())).thenReturn(template);
    FilesystemRepositoryService spy = PowerMockito.spy(filesystemRepositoryService);
    doReturn(repository).when(spy, "getRepositoryByNameAndType", anyString(), anyString());
    doReturn(new ArrayList<TemplateMetadata>()).when(spy, "listTemplatesByRepository", repository);
    PowerMockito.when(FilenameUtils.getBaseName(anyString())).thenReturn("testName");
    Path pathMock = mock(Path.class);
    PowerMockito.when(Paths.get(anyString())).thenReturn(pathMock);
    Mockito.when(pathMock.toFile()).thenReturn(mock(File.class));
    Mockito.doNothing().when(mapper).writeValue(any(File.class), any());
    TemplateMetadataWrapper newTemplate = spy.publishTemplate("test", "test", "test", false);
    assertNotNull(newTemplate);
    assertTrue(newTemplate.getTemplateName().equals("testTemplate"));
}