@Test
public void testCheckViewVersions() {

  ViewRegistry registry = ViewRegistry.getInstance();
  ViewEntity viewEntity = createNiceMock(ViewEntity.class);
  ViewConfig config = createNiceMock(ViewConfig.class);
  expect(viewEntity.getConfiguration()).andReturn(config).anyTimes();
  // null, null
  expect(config.getMinAmbariVersion()).andReturn(null);
  expect(config.getMaxAmbariVersion()).andReturn(null);
  // 1.0.0, 3.0.0
  expect(config.getMinAmbariVersion()).andReturn("1.0.0");
  expect(config.getMaxAmbariVersion()).andReturn("3.0.0");
  // 1.0.0, 1.5
  expect(config.getMinAmbariVersion()).andReturn("1.0.0");
  expect(config.getMaxAmbariVersion()).andReturn("1.5");
  // 2.5
  expect(config.getMinAmbariVersion()).andReturn("2.5");
  // null, 3.0.0
  expect(config.getMinAmbariVersion()).andReturn(null);
  expect(config.getMaxAmbariVersion()).andReturn("3.0.0");
  // 1.0.0, null
  expect(config.getMinAmbariVersion()).andReturn("1.0.0");
  expect(config.getMaxAmbariVersion()).andReturn(null);
  // 1.0.0, *
  expect(config.getMinAmbariVersion()).andReturn("1.0.0");
  expect(config.getMaxAmbariVersion()).andReturn("*");
  // *, 3.0.0
  expect(config.getMinAmbariVersion()).andReturn("*");
  expect(config.getMaxAmbariVersion()).andReturn("3.0.0");
  // 1.0.0, 2.*
  expect(config.getMinAmbariVersion()).andReturn("1.0.0");
  expect(config.getMaxAmbariVersion()).andReturn("2.*");
  // 1.*, 3.0.0
  expect(config.getMinAmbariVersion()).andReturn("1.*");
  expect(config.getMaxAmbariVersion()).andReturn("3.0.0");
  // 1.0.0, 2.1.*
  expect(config.getMinAmbariVersion()).andReturn("1.0.0");
  expect(config.getMaxAmbariVersion()).andReturn("2.1.*");
  // 1.5.*, 3.0.0
  expect(config.getMinAmbariVersion()).andReturn("1.5.*");
  expect(config.getMaxAmbariVersion()).andReturn("3.0.0");
  // 1.0.0, 1.9.9.*
  expect(config.getMinAmbariVersion()).andReturn("1.0.0");
  expect(config.getMaxAmbariVersion()).andReturn("1.9.9.*");
  // 2.0.0.1.*, 3.0.0
  expect(config.getMinAmbariVersion()).andReturn("2.0.0.1.*");
  replay(viewEntity, config);
  // null, null
  Assert.assertTrue(registry.checkViewVersions(viewEntity, "2.0.0"));
  // 1.0.0, 3.0.0
  Assert.assertTrue(registry.checkViewVersions(viewEntity, "2.0.0"));
  // 1.0.0, 1.5
  Assert.assertFalse(registry.checkViewVersions(viewEntity, "2.0.0"));
  // 2.5, 3.0.0
  Assert.assertFalse(registry.checkViewVersions(viewEntity, "2.0.0"));
  // null, 3.0.0
  Assert.assertTrue(registry.checkViewVersions(viewEntity, "2.0.0"));
  // 1.0.0, null
  Assert.assertTrue(registry.checkViewVersions(viewEntity, "2.0.0"));
  // 1.0.0, *
  Assert.assertTrue(registry.checkViewVersions(viewEntity, "2.0.0"));
  // *, 3.0.0
  Assert.assertTrue(registry.checkViewVersions(viewEntity, "2.0.0"));
  // 1.0.0, 2.*
  Assert.assertTrue(registry.checkViewVersions(viewEntity, "2.0.0"));
  // 1.*, 3.0.0
  Assert.assertTrue(registry.checkViewVersions(viewEntity, "2.0.0"));
  // 1.0.0, 2.1.*
  Assert.assertTrue(registry.checkViewVersions(viewEntity, "2.0.0"));
  // 1.5.*, 3.0.0
  Assert.assertTrue(registry.checkViewVersions(viewEntity, "2.0.0"));
  // 1.0.0, 1.9.9.*
  Assert.assertFalse(registry.checkViewVersions(viewEntity, "2.0.0"));
  // 2.0.0.1.*, 3.0.0
  Assert.assertFalse(registry.checkViewVersions(viewEntity, "2.0.0"));
  verify(viewEntity, config);
}