### Question:
ImmutableElectricObject { public int searchVar(Variable.Key key) { if (key == null) { throw new NullPointerException("key"); } return searchVar(vars, key); } ImmutableElectricObject(Variable[] vars, int flags); Variable getVar(Variable.Key key); T getVarValue(Variable.Key key, Class type); Iterator<Variable> getVariables(); Variable[] toVariableArray(); int getNumVariables(); Variable getVar(int varIndex); int searchVar(Variable.Key key); abstract int hashCodeExceptVariables(); abstract boolean equalsExceptVariables(ImmutableElectricObject o); boolean equalsVariables(ImmutableElectricObject o); final int flags; }### Answer:
@Test public void testSearchVar() { System.out.println("searchVar"); assertEquals(0, obj_Aa.searchVar(Variable.newKey("ATTR_A"))); assertEquals(1, obj_Aa.searchVar(Variable.newKey("a"))); assertEquals(-1, obj_Aa.searchVar(Variable.newKey("0"))); assertEquals(-2, obj_Aa.searchVar(Variable.newKey("B"))); assertEquals(-3, obj_Aa.searchVar(Variable.newKey("s"))); }
@Test(expected = NullPointerException.class) public void testSearchVarNull() { System.out.println("searchVar"); obj0.searchVar(null); }