@Test
public void testGetGridRectangle_incorrectDimensions() {

    final Variable mockVariable = mock(Variable.class);
    when(mockVariable.getRank()).thenReturn(2);
    final Dimension y_dim = mock(Dimension.class);
    when(y_dim.getLength()).thenReturn(11);
    final Dimension x_dim = mock(Dimension.class);
    when(x_dim.getLength()).thenReturn(19);
    when(mockVariable.getDimension(0)).thenReturn(y_dim);
    when(mockVariable.getDimension(1)).thenReturn(x_dim);
    final GridDef gridDef = GridDef.createGlobal(20, 10);
    try {
        NcTools.getGridRectangle(netcdfFile, mockVariable, gridDef);
        fail("IOException expected");
    } catch (IOException expected) {
    }
    verify(mockVariable, times(1)).getRank();
    verify(mockVariable, times(1)).getDimension(0);
    verify(mockVariable, times(1)).getDimension(1);
    verify(netcdfFile, times(1)).getLocation();
    verifyNoMoreInteractions(netcdfFile);
}