source: class ConfigManagerTest {
  
      @Test
      public void testWrite() throws Exception {
  
target:         Configuration config = new Configuration();
          config.setSubsystem(new Subsystem());
          config.setDiagnostics(new Diagnostics());
          config.setStorageAdapter(new StorageAdapter());
          config.setPlatform(new Platform());
  
          // SECURITY REALMS
          SecurityRealm[] securityRealms = new SecurityRealm[1];
          config.setSecurityRealms(securityRealms);
          securityRealms[0] = new SecurityRealm();
          securityRealms[0].setName("first security realm");
          securityRealms[0].setKeystorePath("/first/security/realm.truststore");
          securityRealms[0].setKeystorePassword("first password");
  
          // DMR
  
          DMRMetricSet[] dmrMetricSets = new DMRMetricSet[2];
          config.setDmrMetricSets(dmrMetricSets);
          dmrMetricSets[0] = new DMRMetricSet();
          dmrMetricSets[0].setName("dmr metric set 0");
          dmrMetricSets[0].setDmrMetrics(new DMRMetric[2]);
          dmrMetricSets[0].getDmrMetrics()[0] = new DMRMetric();
          dmrMetricSets[0].getDmrMetrics()[0].setName("dmr metric 0");
          dmrMetricSets[0].getDmrMetrics()[1] = new DMRMetric();
          dmrMetricSets[0].getDmrMetrics()[1].setName("dmr metric 1");
          dmrMetricSets[1] = new DMRMetricSet();
          dmrMetricSets[1].setName("dmr metric set 1");
          dmrMetricSets[1].setDmrMetrics(new DMRMetric[2]);
          dmrMetricSets[1].getDmrMetrics()[0] = new DMRMetric();
          dmrMetricSets[1].getDmrMetrics()[0].setName("dmr metric 2");
          dmrMetricSets[1].getDmrMetrics()[1] = new DMRMetric();
          dmrMetricSets[1].getDmrMetrics()[1].setName("dmr metric 3");
  
          DMRResourceTypeSet[] dmrResourceTypeSets = new DMRResourceTypeSet[2];
          config.setDmrResourceTypeSets(dmrResourceTypeSets);
          dmrResourceTypeSets[0] = new DMRResourceTypeSet();
          dmrResourceTypeSets[0].setName("dmr resource type set 0");
          dmrResourceTypeSets[0].setDmrResourceTypes(new DMRResourceType[2]);
          dmrResourceTypeSets[0].getDmrResourceTypes()[0] = new DMRResourceType();
          dmrResourceTypeSets[0].getDmrResourceTypes()[0].setName("dmr resource type 0");
          dmrResourceTypeSets[0].getDmrResourceTypes()[0].setDmrResourceConfigs(new DMRResourceConfig[1]);
          dmrResourceTypeSets[0].getDmrResourceTypes()[0].getDmrResourceConfigs()[0] = new DMRResourceConfig();
          dmrResourceTypeSets[0].getDmrResourceTypes()[0].getDmrResourceConfigs()[0].setName("dmr res config 0");
          dmrResourceTypeSets[0].getDmrResourceTypes()[1] = new DMRResourceType();
          dmrResourceTypeSets[0].getDmrResourceTypes()[1].setName("dmr resource type 1");
          dmrResourceTypeSets[0].getDmrResourceTypes()[1].setDmrResourceConfigs(new DMRResourceConfig[1]);
          dmrResourceTypeSets[0].getDmrResourceTypes()[1].getDmrResourceConfigs()[0] = new DMRResourceConfig();
          dmrResourceTypeSets[0].getDmrResourceTypes()[1].getDmrResourceConfigs()[0].setName("dmr res config 1");
          dmrResourceTypeSets[1] = new DMRResourceTypeSet();
          dmrResourceTypeSets[1].setName("dmr resource type set 1");
          dmrResourceTypeSets[1].setDmrResourceTypes(new DMRResourceType[2]);
          dmrResourceTypeSets[1].getDmrResourceTypes()[0] = new DMRResourceType();
          dmrResourceTypeSets[1].getDmrResourceTypes()[0].setName("dmr resource type 2");
          dmrResourceTypeSets[1].getDmrResourceTypes()[1] = new DMRResourceType();
          dmrResourceTypeSets[1].getDmrResourceTypes()[1].setName("dmr resource type 3");
  
          // JMX
  
          JMXMetricSet[] jmxMetricSets = new JMXMetricSet[2];
          config.setJmxMetricSets(jmxMetricSets);
          jmxMetricSets[0] = new JMXMetricSet();
          jmxMetricSets[0].setName("jmx metric set 0");
          jmxMetricSets[0].setJmxMetrics(new JMXMetric[2]);
          jmxMetricSets[0].getJmxMetrics()[0] = new JMXMetric();
          jmxMetricSets[0].getJmxMetrics()[0].setName("jmx metric 0");
          jmxMetricSets[0].getJmxMetrics()[1] = new JMXMetric();
          jmxMetricSets[0].getJmxMetrics()[1].setName("jmx metric 1");
          jmxMetricSets[1] = new JMXMetricSet();
          jmxMetricSets[1].setName("jmx metric set 1");
          jmxMetricSets[1].setJmxMetrics(new JMXMetric[2]);
          jmxMetricSets[1].getJmxMetrics()[0] = new JMXMetric();
          jmxMetricSets[1].getJmxMetrics()[0].setName("jmx metric 2");
          jmxMetricSets[1].getJmxMetrics()[1] = new JMXMetric();
          jmxMetricSets[1].getJmxMetrics()[1].setName("jmx metric 3");
  
          JMXResourceTypeSet[] jmxResourceTypeSets = new JMXResourceTypeSet[2];
          config.setJmxResourceTypeSets(jmxResourceTypeSets);
          jmxResourceTypeSets[0] = new JMXResourceTypeSet();
          jmxResourceTypeSets[0].setName("jmx resource type set 0");
          jmxResourceTypeSets[0].setJmxResourceTypes(new JMXResourceType[2]);
          jmxResourceTypeSets[0].getJmxResourceTypes()[0] = new JMXResourceType();
          jmxResourceTypeSets[0].getJmxResourceTypes()[0].setName("jmx resource type 0");
          jmxResourceTypeSets[0].getJmxResourceTypes()[0].setJmxResourceConfigs(new JMXResourceConfig[1]);
          jmxResourceTypeSets[0].getJmxResourceTypes()[0].getJmxResourceConfigs()[0] = new JMXResourceConfig();
          jmxResourceTypeSets[0].getJmxResourceTypes()[0].getJmxResourceConfigs()[0].setName("jmx res config 0");
          jmxResourceTypeSets[0].getJmxResourceTypes()[1] = new JMXResourceType();
          jmxResourceTypeSets[0].getJmxResourceTypes()[1].setName("jmx resource type 1");
          jmxResourceTypeSets[0].getJmxResourceTypes()[1].setJmxResourceConfigs(new JMXResourceConfig[1]);
          jmxResourceTypeSets[0].getJmxResourceTypes()[1].getJmxResourceConfigs()[0] = new JMXResourceConfig();
          jmxResourceTypeSets[0].getJmxResourceTypes()[1].getJmxResourceConfigs()[0].setName("jmx res config 1");
          jmxResourceTypeSets[1] = new JMXResourceTypeSet();
          jmxResourceTypeSets[1].setName("jmx resource type set 1");
          jmxResourceTypeSets[1].setJmxResourceTypes(new JMXResourceType[2]);
          jmxResourceTypeSets[1].getJmxResourceTypes()[0] = new JMXResourceType();
          jmxResourceTypeSets[1].getJmxResourceTypes()[0].setName("jmx resource type 2");
          jmxResourceTypeSets[1].getJmxResourceTypes()[1] = new JMXResourceType();
          jmxResourceTypeSets[1].getJmxResourceTypes()[1].setName("jmx resource type 3");
  
          config.setManagedServers(new ManagedServers());
          config.getManagedServers().setLocalDmr(new LocalDMR());
          config.getManagedServers().getLocalDmr().setName("Local DMR");
          config.getManagedServers().getLocalDmr().setResourceTypeSets(new String[] { "dmr resource type set 0",
                  "dmr resource type set 1" });
          config.getManagedServers().setLocalJmx(new LocalJMX());
          config.getManagedServers().getLocalJmx().setName("Local JMX");
          config.getManagedServers().getLocalJmx().setResourceTypeSets(new String[] { "jmx resource type set 0",
                  "jmx resource type set 1" });
          config.getManagedServers().setRemoteDmrs(new RemoteDMR[1]);
          config.getManagedServers().getRemoteDmrs()[0] = new RemoteDMR();
          config.getManagedServers().getRemoteDmrs()[0].setName("Remote DMR");
          config.getManagedServers().getRemoteDmrs()[0].setResourceTypeSets(new String[] { "dmr resource type set 0",
                  "dmr resource type set 1" });
          config.getManagedServers().setRemoteJmxs(new RemoteJMX[1]);
          config.getManagedServers().getRemoteJmxs()[0] = new RemoteJMX();
          config.getManagedServers().getRemoteJmxs()[0].setName("Remote JMX");
          config.getManagedServers().getRemoteJmxs()[0].setResourceTypeSets(new String[] { "jmx resource type set 0",
                  "jmx resource type set 1" });
  
          // write the config out
          File file = new File("/tmp/org.hawkular.agent.javaagent.config.ConfigManagerTest.yaml");
          ConfigManager configManager = new ConfigManager(file);
          configManager.updateConfiguration(config, false);
      }
  
  }