@Test
public void rotateRectangle() {

    PDRectangle in = new PDRectangle(0, 0, 396, 612);
    PDRectangle mediaBox = new PDRectangle(0, 0, 792, 612);
    assertThat(RectangleUtils.rotate(-90, in, mediaBox), is(new PDRectangle(0, 0, 612, 396)));
    assertThat(RectangleUtils.rotate(270, in, mediaBox), is(RectangleUtils.rotate(-90, in, mediaBox)));
    assertThat(RectangleUtils.rotate(90, in, mediaBox), is(new PDRectangle(0, 396, 612, 396)));
    assertThat(RectangleUtils.rotate(180, in, mediaBox), is(new PDRectangle(396, 0, 396, 612)));
}