@Test
public void testSetDimensions() throws IOException, PDUStitchingException {

    List<Dimension>[] dimensionLists = new ArrayList[2];
    List<Variable>[] variableLists = new ArrayList[2];
    final File inputFile1 = new File(targetDirectory, "input_1.nc");
    SlstrNFileWritable inputWriteable1 = new SlstrNFileWritable(inputFile1.getAbsolutePath());
    inputWriteable1.addDimension("rows", 5);
    inputWriteable1.addDimension("columns", 7);
    inputWriteable1.addDimension("the_twilight_zone", 12);
    final SlstrN4Variable abVariable1 = inputWriteable1.addVariable("ab", DataType.BYTE, true, "rows columns");
    final SlstrN4Variable cdVariable1 = inputWriteable1.addVariable("cd", DataType.LONG, false, "columns the_twilight_zone");
    inputWriteable1.create();
    abVariable1.writeFullyInSections(new ArrayByte(new int[]{5, 7}, false));
    cdVariable1.writeFullyInSections(new ArrayLong(new int[]{7, 12}, false));
    inputWriteable1.close();
    final NetcdfFile inputnc1 = NetcdfFileOpener.open(inputFile1);
    assertNotNull(inputnc1);
    dimensionLists[0] = inputnc1.getDimensions();
    variableLists[0] = inputnc1.getVariables();
    inputnc1.close();
    final File inputFile2 = new File(targetDirectory, "input_2.nc");
    final NFileWriteable inputWriteable2 = NWritableFactory.create(inputFile2.getAbsolutePath(), "netcdf4");
    inputWriteable2.addDimension("rows", 5);
    inputWriteable2.addDimension("columns", 7);
    inputWriteable2.addDimension("outer_limits", 25);
    final NVariable abVariable2 = inputWriteable2.addVariable("ab", DataType.BYTE, true, null, "rows columns");
    final NVariable cdVariable2 = inputWriteable2.addVariable("ef", DataType.LONG, false, null, "columns outer_limits");
    inputWriteable2.create();
    abVariable2.writeFully(new ArrayByte(new int[]{5, 7}, false));
    cdVariable2.writeFully(new ArrayLong(new int[]{7, 25}, false));
    inputWriteable2.close();
    final NetcdfFile inputnc2 = NetcdfFileOpener.open(inputFile2);
    assertNotNull(inputnc2);
    dimensionLists[1] = inputnc2.getDimensions();
    variableLists[1] = inputnc2.getVariables();
    inputnc2.close();
    final File file = new File(targetDirectory, "something.nc");
    SlstrNFileWritable netcdfWriteable = new SlstrNFileWritable(file.getAbsolutePath());
    ImageSize targetImageSize = new ImageSize("id", 10, 20, 10, 20);
    NcFileStitcher.setDimensions(netcdfWriteable, dimensionLists, targetImageSize, variableLists);
    netcdfWriteable.create();
    netcdfWriteable.close();
    netcdfFile = NetcdfFileOpener.open(file);
    assertNotNull(netcdfFile);
    final List<Dimension> dimensions = netcdfFile.getDimensions();
    assertEquals(4, dimensions.size());
    Map<String, Integer> expectedDimensions = new HashMap<>();
    expectedDimensions.put("rows", 10);
    expectedDimensions.put("columns", 20);
    expectedDimensions.put("the_twilight_zone", 12);
    expectedDimensions.put("outer_limits", 25);
    for (Dimension dimension : dimensions) {
        assertTrue(expectedDimensions.containsKey(dimension.getFullName()));
        assertEquals(expectedDimensions.get(dimension.getFullName()).intValue(), dimension.getLength());
    }
}