CalabashCapabilityMatcher implements CapabilityMatcher { @Override public boolean matches(Map<String, Object> nodeCapability, Map<String, Object> requestedCapability) { if (nodeCapability == null || requestedCapability == null) { return false; } for (String key : requestedCapability.keySet()) { if (toConsider.contains(key)) { if (requestedCapability.get(key) != null) { String value = requestedCapability.get(key).toString(); if (!requestedCapability.get(key).equals(nodeCapability.get(key))) { return false; } else { } } } } return true; } CalabashCapabilityMatcher(); @Override boolean matches(Map<String, Object> nodeCapability, Map<String, Object> requestedCapability);  }
@Test public void doesntMatchMinimumCapa() { CalabashCapabilities reqCapa = new CalabashCapabilities(); reqCapa.setAut(APP); reqCapa.setLocale(DEVICE_NAME); Assert.assertFalse(matcher.matches(nodeCapability.getRawCapabilities(), reqCapa.getRawCapabilities())); reqCapa = new CalabashCapabilities(); reqCapa.setAut(DEVICE_NAME); reqCapa.setLocale(LOCALE); Assert.assertFalse(matcher.matches(nodeCapability.getRawCapabilities(), reqCapa.getRawCapabilities())); }
@Test public void matchMinimumCapa() { CalabashCapabilities reqCapa = new CalabashCapabilities(); reqCapa.setAut(APP); reqCapa.setLocale(LOCALE); Assert.assertTrue(matcher.matches(nodeCapability.getRawCapabilities(), reqCapa.getRawCapabilities())); }
@Test public void onlyDefaultCapabilitiesAreConsidered() { CalabashCapabilities reqCapa = new CalabashCapabilities(); reqCapa.setAut(APP); reqCapa.setLocale(LOCALE); reqCapa.setSDKVersion(SDK_VERSION); reqCapa.setDeviceId(APP); Assert.assertTrue(matcher.matches(nodeCapability.getRawCapabilities(), reqCapa.getRawCapabilities())); }
@Test public void matchConsideredCapa() { CalabashCapabilities reqCapa = new CalabashCapabilities(); reqCapa.setAut(APP); reqCapa.setLocale(LOCALE); reqCapa.setSDKVersion(SDK_VERSION); Assert.assertTrue(matcher.matches(nodeCapability.getRawCapabilities(), reqCapa.getRawCapabilities())); }
@Test public void doesntMatchConsideredCapa() { CalabashCapabilities reqCapa = new CalabashCapabilities(); reqCapa.setAut(APP); reqCapa.setLocale(LOCALE); reqCapa.setSDKVersion(DEVICE_NAME); Assert.assertFalse(matcher.matches(nodeCapability.getRawCapabilities(), reqCapa.getRawCapabilities())); reqCapa.setAut(APP); reqCapa.setLocale(DEVICE_NAME); reqCapa.setSDKVersion(SDK_VERSION); Assert.assertFalse(matcher.matches(nodeCapability.getRawCapabilities(), reqCapa.getRawCapabilities())); }