Ejemplo n.º 1
0
  @Test
  public void testSingleImportModel() {
    final String expectedDrl = "import java.lang.String;\n\n";

    final HasImports model =
        new HasImports() {

          private Imports imports = new Imports();

          {
            imports.addImport(new Import("java.lang.String"));
          }

          @Override
          public Imports getImports() {
            return imports;
          }

          @Override
          public void setImports(final Imports imports) {
            // Nothing to do here
          }
        };

    final StringBuilder sb = new StringBuilder();
    ImportsWriter.write(sb, model);

    final String drl = sb.toString();
    assertNotNull(drl);

    assertEquals(expectedDrl, drl);
  }
Ejemplo n.º 2
0
  @Test
  public void testEmptyModel() {
    final HasImports model =
        new HasImports() {

          private Imports imports = new Imports();

          @Override
          public Imports getImports() {
            return imports;
          }

          @Override
          public void setImports(final Imports imports) {
            // Nothing to do here
          }
        };

    final StringBuilder sb = new StringBuilder();
    ImportsWriter.write(sb, model);

    final String drl = sb.toString();
    assertNotNull(drl);

    assertTrue(drl.isEmpty());
  }