### Question:
UIf implements UStatement, IfTree { public static UIf create( UExpression condition, UStatement thenStatement, UStatement elseStatement) { return new AutoValue_UIf(condition, thenStatement, elseStatement); }  static UIf create(
      UExpression condition, UStatement thenStatement, UStatement elseStatement); @Override abstract UExpression getCondition(); @Override abstract UStatement getThenStatement(); @Override @Nullable abstract UStatement getElseStatement(); @Override R accept(TreeVisitor<R, D> visitor, D data); @Override Kind getKind(); @Override @Nullable Choice<UnifierWithUnconsumedStatements> apply(UnifierWithUnconsumedStatements state); @Override List<JCStatement> inlineStatements(Inliner inliner);  }### Answer:
@Test public void equality() { new EqualsTester() .addEqualityGroup( UIf.create( UFreeIdent.create("cond"), UBlock.create( UExpressionStatement.create( UAssign.create(UFreeIdent.create("x"), UFreeIdent.create("y")))), UBlock.create( UExpressionStatement.create( UAssign.create(UFreeIdent.create("x"), UFreeIdent.create("z")))))) .addEqualityGroup( UIf.create( UFreeIdent.create("cond"), UBlock.create( UExpressionStatement.create( UAssign.create(UFreeIdent.create("x"), UFreeIdent.create("y")))), null)) .addEqualityGroup( UIf.create( ULiteral.booleanLit(true), UBlock.create( UExpressionStatement.create( UAssign.create(UFreeIdent.create("x"), UFreeIdent.create("y")))), UBlock.create( UExpressionStatement.create( UAssign.create(UFreeIdent.create("x"), UFreeIdent.create("z")))))) .testEquals(); }
@Test public void serialization() { SerializableTester.reserializeAndAssert( UIf.create( UFreeIdent.create("cond"), UBlock.create( UExpressionStatement.create( UAssign.create(UFreeIdent.create("x"), UFreeIdent.create("y")))), UBlock.create( UExpressionStatement.create( UAssign.create(UFreeIdent.create("x"), UFreeIdent.create("z")))))); }
@Test public void inlineWithElse() { UIf ifTree = UIf.create( UFreeIdent.create("cond"), UBlock.create( UExpressionStatement.create( UAssign.create(UFreeIdent.create("x"), UFreeIdent.create("y")))), UBlock.create( UExpressionStatement.create( UAssign.create(UFreeIdent.create("x"), UFreeIdent.create("z"))))); bind(new UFreeIdent.Key("cond"), parseExpression("true")); bind(new UFreeIdent.Key("x"), parseExpression("x")); bind(new UFreeIdent.Key("y"), parseExpression("\"foo\"")); bind(new UFreeIdent.Key("z"), parseExpression("\"bar\"")); assertInlines( Joiner.on(System.lineSeparator()) .join( "if (true) {", " x = \"foo\";", "} else {", " x = \"bar\";", "}"), ifTree); }
@Test public void inlineWithoutElse() { UIf ifTree = UIf.create( UFreeIdent.create("cond"), UBlock.create( UExpressionStatement.create( UAssign.create(UFreeIdent.create("x"), UFreeIdent.create("y")))), null); bind(new UFreeIdent.Key("cond"), parseExpression("true")); bind(new UFreeIdent.Key("x"), parseExpression("x")); bind(new UFreeIdent.Key("y"), parseExpression("\"foo\"")); assertInlines( Joiner.on(System.lineSeparator()) .join( "if (true) {", " x = \"foo\";", "}"), ifTree); }