-
-
Save lfryc/8820686 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@Override | |
public boolean canEnhance(InstanceOrCallableInstance instance, Class<?> droneType, Class<? extends Annotation> qualifier) { | |
if (RemoteWebDriver.class == droneType || ReusableRemoteWebDriver.class == droneType) { | |
return true; | |
} | |
Class<?> realInstanceClass = instance.asInstance(droneType).getClass(); | |
if (RemoteWebDriver.class == realInstanceClass || ReusableRemoteWebDriver.class == realInstanceClass) | |
|| DroneAugmented.class.isAssignableFrom(realInstanceClass)) { | |
return true; | |
} | |
return false; | |
} | |
@Test | |
public void testCanEnhance() { | |
RemoteWebDriver driver = mock(RemoteWebDriver.class); | |
ReusableRemoteWebDriver reusableDriver = mock(ReusableRemoteWebDriver.class); | |
InstanceOrCallableInstance instance = mock(InstanceOrCallableInstance.class); | |
doReturn(driver).when(instance).asInstance(RemoteWebDriver.class); | |
doReturn(driver).when(instance).asInstance(WebDriver.class); | |
doReturn(driver).when(instance).asInstance(driver.getClass()); | |
doReturn(reusableDriver).when(instance).asInstance(ReusableRemoteWebDriver.class); | |
System.out.println(driver.getClass()); | |
assertTrue(enhancer.canEnhance(instance, RemoteWebDriver.class, Default.class)); | |
assertTrue(enhancer.canEnhance(instance, ReusableRemoteWebDriver.class, Default.class)); | |
assertTrue(enhancer.canEnhance(instance, WebDriver.class, Default.class)); | |
assertTrue(enhancer.canEnhance(instance, driver.getClass(), Default.class)) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment