package com.mooo.aimmac23.hub.proxy;

import java.util.Map;

import org.openqa.grid.internal.utils.CapabilityMatcher;

public class ReliableCapabilityMatcher implements CapabilityMatcher {
	
	private CapabilityMatcher innerMatcher;
	private ReliableProxy proxy;

	public ReliableCapabilityMatcher(ReliableProxy proxy, CapabilityMatcher innerMatcher) {
		this.proxy = proxy;
		this.innerMatcher = innerMatcher;
	}
	
	@Override
	public boolean matches(Map<String, Object> currentCapability,
			Map<String, Object> requestedCapability) {
		
		// to allow the node to be tested
		if(requestedCapability.containsKey("proxyId")) {
			return innerMatcher.matches(currentCapability, requestedCapability);
		}
		
		// check to see if we're allowed to use that config
		if(!proxy.isCapabilityWorking(currentCapability)) {
			return false;
		}
		
		// otherwise, match on the capabilities
		return innerMatcher.matches(currentCapability, requestedCapability);
	}
}

@@ -236,25 +236,33 @@
 ivate Reliab
-l
+ilityAwar
 eProxy proxy
@@ -304,17 +304,25 @@
 r(Reliab
-l
+ilityAwar
 eProxy p
@@ -582,16 +582,115 @@
 e tested
+ - we're calling enough internal%0A%09%09// methods to ensure that we're calling this on the correct node
 %0A%09%09if(re

Use the interface for this