@Test
public void testEnsureExtractedArchiveDirectory() throws Exception {

  ResourceTypeEntity resourceTypeEntity = new ResourceTypeEntity();
  resourceTypeEntity.setId(10);
  resourceTypeEntity.setName("MY_VIEW{1.0.0}");
  ViewEntity viewDefinition = ViewEntityTest.getViewEntity();
  viewDefinition.setResourceType(resourceTypeEntity);
  expect(extractedArchiveDir.exists()).andReturn(true);
  replay(extractedArchiveDir, viewArchive, archiveDir, entryFile, classesDir, libDir, metaInfDir, viewJarFile,
      jarEntry, fos, configuration, viewDir, fileEntry, viewDAO);
  ViewExtractor viewExtractor = getViewExtractor(viewDefinition);
  if (System.getProperty("os.name").contains("Windows")) {
    Assert.assertTrue(viewExtractor.ensureExtractedArchiveDirectory("\\var\\lib\\ambari-server\\resources\\views\\work"));
  }
  else {
    Assert.assertTrue(viewExtractor.ensureExtractedArchiveDirectory("/var/lib/ambari-server/resources/views/work"));
  }
  verify(extractedArchiveDir, viewArchive, archiveDir, entryFile, classesDir, libDir, metaInfDir, viewJarFile,
      jarEntry, fos, configuration, viewDir, fileEntry, viewDAO);
  reset(extractedArchiveDir);
  expect(extractedArchiveDir.exists()).andReturn(false);
  expect(extractedArchiveDir.mkdir()).andReturn(true);
  replay(extractedArchiveDir);
  viewExtractor = getViewExtractor(viewDefinition);
  if (System.getProperty("os.name").contains("Windows")) {
    Assert.assertTrue(viewExtractor.ensureExtractedArchiveDirectory("\\var\\lib\\ambari-server\\resources\\views\\work"));
  }
  else {
    Assert.assertTrue(viewExtractor.ensureExtractedArchiveDirectory("/var/lib/ambari-server/resources/views/work"));
  }
  verify(extractedArchiveDir);
  reset(extractedArchiveDir);
  expect(extractedArchiveDir.exists()).andReturn(false);
  expect(extractedArchiveDir.mkdir()).andReturn(false);
  replay(extractedArchiveDir);
  viewExtractor = getViewExtractor(viewDefinition);
  if (System.getProperty("os.name").contains("Windows")) {
    Assert.assertFalse(viewExtractor.ensureExtractedArchiveDirectory("\\var\\lib\\ambari-server\\resources\\views\\work"));
  }
  else {
    Assert.assertFalse(viewExtractor.ensureExtractedArchiveDirectory("/var/lib/ambari-server/resources/views/work"));
  }
  verify(extractedArchiveDir);
}