@Test
public void testSetGlobalAttributes() throws IOException {

    final File file = new File(targetDirectory, "something.nc");
    SlstrNFileWritable netcdfWriteable = new SlstrNFileWritable(file.getAbsolutePath());
    List<Attribute>[] attributeLists = new List[2];
    attributeLists[0] = new ArrayList<>();
    attributeLists[0].add(new Attribute("xyz", "yz"));
    attributeLists[0].add(new Attribute("abc", "23"));
    final ArrayByte someArray = new ArrayByte(new int[]{2}, true);
    someArray.setByte(0, (byte) 5);
    someArray.setByte(0, (byte) 5);
    attributeLists[0].add(new Attribute("def", someArray));
    attributeLists[1] = new ArrayList<>();
    attributeLists[1].add(new Attribute("xyz", "yz"));
    attributeLists[1].add(new Attribute("abc", "44"));
    attributeLists[1].add(new Attribute("defg", someArray));
    final DateFormatConverter globalAttributesDateFormatConverter =
            new DateFormatConverter(new SimpleDateFormat("yyyy'-'MM'-'dd'T'HH':'mm':'ss'Z'"));
    final String someTimeAsString = globalAttributesDateFormatConverter.format(new GregorianCalendar(2013, 6, 7, 15, 32, 52).getTime());
    attributeLists[1].add(new Attribute("creation_time", someTimeAsString));
    final Date now = Calendar.getInstance().getTime();
    final String nowAsString = globalAttributesDateFormatConverter.format(now);
    NcFileStitcher.setGlobalAttributes(netcdfWriteable, attributeLists, targetDirectory.getName(), now);
    netcdfWriteable.create();
    netcdfWriteable.close();
    netcdfFile = NetcdfFileOpener.open(file);
    assertNotNull(netcdfFile);
    final List<Attribute> globalAttributes = netcdfFile.getGlobalAttributes();
    assertEquals(7, globalAttributes.size());
    assertEquals("xyz", globalAttributes.get(0).getFullName());
    assertEquals("yz", globalAttributes.get(0).getStringValue());
    assertEquals("abc_1", globalAttributes.get(1).getFullName());
    assertEquals("44", globalAttributes.get(1).getStringValue());
    assertEquals("abc", globalAttributes.get(2).getFullName());
    assertEquals("23", globalAttributes.get(2).getStringValue());
    assertEquals("def", globalAttributes.get(3).getFullName());
    assertEquals(someArray.toString(), globalAttributes.get(3).getStringValue());
    assertEquals("defg", globalAttributes.get(4).getFullName());
    assertEquals(someArray.toString(), globalAttributes.get(4).getStringValue());
    assertEquals("creation_time", globalAttributes.get(5).getFullName());
    assertEquals(nowAsString, globalAttributes.get(5).getStringValue());
}