Example usage for java.lang System System

List of usage examples for java.lang System System

Introduction

In this page you can find the example usage for java.lang System System.

Prototype

private System() 

Source Link

Document

Don't let anyone instantiate this class

Usage

From source file:com.greglturnquist.embeddablesdr.Application.java

public static void main(String[] args) {
    ApplicationContext ctx = SpringApplication.run(Application.class, args);

    SystemRepository repository = ctx.getBean(SystemRepository.class);

    System system1 = new System();
    system1.setName("router101");
    system1 = repository.save(system1);/*w  ww. jav a  2s  . c o  m*/

    System system2 = new System();
    system2.setName("switch405");
    system2 = repository.save(system2);

    SystemDependency dep1 = new SystemDependency();
    dep1.setDescription("WLAN");
    dep1.setTarget(system1);

    SystemDependency dep2 = new SystemDependency();
    dep2.setDescription("UPS");
    dep2.setTarget(system1);

    ArrayList<SystemDependency> dependencies1 = new ArrayList<>();
    dependencies1.add(dep1);
    dependencies1.add(dep2);
    system1.setDependencies(dependencies1);

    system1 = repository.save(system1);

    SystemDependency dep3 = new SystemDependency();
    dep3.setDescription("MUX");
    dep3.setTarget(system1);

    SystemDependency dep4 = new SystemDependency();
    dep4.setDescription("Backup Battery");
    dep4.setTarget(system2);

    ArrayList<SystemDependency> dependencies2 = new ArrayList<>();
    dependencies2.add(dep3);
    dependencies2.add(dep4);
    system2.setDependencies(dependencies2);

    system2 = repository.save(system2);

}

From source file:com.greglturnquist.embeddablesdr.SystemDependencySerializerTests.java

@Test
public void testSerializer() throws JsonProcessingException {

    System system = new System();
    system.setName("router101");
    system.setId(1L);//from  www  . jav  a2  s  .c  o m
    system.setDependencies(new ArrayList<SystemDependency>());

    SystemDependency dependency = new SystemDependency();
    dependency.setDescription("router");
    dependency.setTarget(system);

    system.getDependencies().add(dependency);

    system = repository.save(system);

    module.addSerializer(serializer);
    mapper.registerModule(module);

    String doc = mapper.writeValueAsString(system);

    log.info(doc);

    assertThat((String) JsonPath.read(doc, "$.name"), equalTo("router101"));
    assertThat((String) JsonPath.read(doc, "$.dependencies[0]._links.target.href"), equalTo("/path/to/1"));
}