CustomCapabilityMatcher extends DefaultCapabilityMatcher { @Override public boolean matches(Map<String, Object> nodeCapability, Map<String, Object> requestedCapability) { boolean basicChecks = super.matches(nodeCapability, requestedCapability); boolean customChecks = extensionCapabilityCheck(nodeCapability, requestedCapability); return basicChecks && customChecks; }  @Override boolean matches(Map<String, Object> nodeCapability, Map<String, Object> requestedCapability);  }
@Test public void shouldReturnTrueWithDefaultCapabilities() { Map<String, Object> nodeCapabilities = nodeCapabilities(); Map<String, Object> requestedCapabilities = requestedCapabilities(); assertTrue(capabilityMatcher.matches(nodeCapabilities, requestedCapabilities)); }
@Test public void shouldReturnFalseWithDefaultCapabilitiesNotMatch() { Map<String, Object> nodeCapabilities = nodeCapabilities(); Map<String, Object> requestedCapabilities = requestedCapabilities(); requestedCapabilities.put(CapabilityType.VERSION, 10); assertFalse(capabilityMatcher.matches(nodeCapabilities, requestedCapabilities)); }
@Test public void shouldReturnFalseWithDefaultCapabilitiesNotMatch_2() { Map<String, Object> nodeCapabilities = nodeCapabilities(); Map<String, Object> requestedCapabilities = requestedCapabilities(); requestedCapabilities.put(CapabilityType.PLATFORM, Platform.VISTA); assertFalse(capabilityMatcher.matches(nodeCapabilities, requestedCapabilities)); }
@Test public void shouldReturnFalseWhenExtensionCapabilitiesAreNotFound() { Map<String, Object> nodeCapabilities = nodeCapabilities(); Map<String, Object> requestedCapabilities = requestedCapabilities(); requestedCapabilities.putAll(extensionCapabilities()); assertFalse(capabilityMatcher.matches(nodeCapabilities, requestedCapabilities)); }
@Test public void shouldReturnFalseWhenExtensionCapabilitiesDoNotMatch() { Map<String, Object> nodeCapabilities = nodeCapabilities(); nodeCapabilities.put(Capabilities.EXTENSION_PREFIX + "sikuliCapability", false); Map<String, Object> requestedCapabilities = requestedCapabilities(); requestedCapabilities.put(Capabilities.EXTENSION_PREFIX + "sikuliCapability", true); assertFalse(capabilityMatcher.matches(nodeCapabilities, requestedCapabilities)); }
@Test public void shouldReturnFalseWhenOneExtensionCapabilityDoNotMatch() { Map<String, Object> nodeCapabilities = nodeCapabilities(); nodeCapabilities.put(Capabilities.EXTENSION_PREFIX + "sikuliCapability", false); nodeCapabilities.put(Capabilities.EXTENSION_PREFIX + "ccc", SomeEnum.A); Map<String, Object> requestedCapabilities = requestedCapabilities(); requestedCapabilities.put(Capabilities.EXTENSION_PREFIX + "sikuliCapability", true); requestedCapabilities.put(Capabilities.EXTENSION_PREFIX + "ccc", SomeEnum.B); assertFalse(capabilityMatcher.matches(nodeCapabilities, requestedCapabilities)); }
@Test public void shouldReturnTrueWhenNodeHasRequestedCapabilities() { Map<String, Object> nodeCapabilities = nodeCapabilities(); nodeCapabilities.putAll(extensionCapabilities()); Map<String, Object> requestedCapabilities = requestedCapabilities(); requestedCapabilities.put(Capabilities.EXTENSION_PREFIX + "sikuliCapability", true); assertTrue(capabilityMatcher.matches(nodeCapabilities, requestedCapabilities)); }
@Test public void shouldReturnTrueWhenDefaultCapabilitiesMatchAndNodeHasExtensionCapabilities() { Map<String, Object> nodeCapabilities = nodeCapabilities(); nodeCapabilities.putAll(extensionCapabilities()); Map<String, Object> requestedCapabilities = requestedCapabilities(); assertTrue(capabilityMatcher.matches(nodeCapabilities, requestedCapabilities)); }