@Test
public void testGetGridRectangle() throws IOException {

    final Variable variable = mock(Variable.class);
    when(variable.getRank()).thenReturn(2);
    final Dimension y_dim = mock(Dimension.class);
    when(y_dim.getLength()).thenReturn(10);
    final Dimension x_dim = mock(Dimension.class);
    when(x_dim.getLength()).thenReturn(20);
    when(variable.getDimension(0)).thenReturn(y_dim);
    when(variable.getDimension(1)).thenReturn(x_dim);
    final GridDef gridDef = GridDef.createGlobal(20, 10);
    final Rectangle gridRectangle = NcTools.getGridRectangle(netcdfFile, variable, gridDef);
    assertNotNull(gridRectangle);
    assertEquals(0, gridRectangle.getX(), 1e-8);
    assertEquals(0, gridRectangle.getY(), 1e-8);
    assertEquals(20, gridRectangle.getWidth(), 1e-8);
    assertEquals(10, gridRectangle.getHeight(), 1e-8);
    verify(variable, times(1)).getRank();
    verify(variable, times(1)).getDimension(0);
    verify(variable, times(1)).getDimension(1);
    verifyNoMoreInteractions(netcdfFile);
}