Package br.com.objectos.rio.config

Source Code of br.com.objectos.rio.config.ConfigCommandTest

/*
* Copyright 2013 Objectos, Fábrica de Software LTDA.
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
* use this file except in compliance with the License. You may obtain a copy of
* the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations under
* the License.
*/
package br.com.objectos.rio.config;

import static br.com.objectos.way.base.testing.WayMatchers.equalTo;
import static org.hamcrest.MatcherAssert.assertThat;

import org.testng.annotations.BeforeClass;
import org.testng.annotations.Guice;
import org.testng.annotations.Test;

import br.com.objectos.rio.FakeArgs;
import br.com.objectos.rio.RioDirs;
import br.com.objectos.rio.RioDirsUserSettings;
import br.com.objectos.rio.RioTestModule;
import br.com.objectos.rio.User;
import br.com.objectos.way.base.io.Directory;
import br.com.objectos.way.cli.Cli;
import br.com.objectos.way.etc.Etcs;

import com.google.inject.Inject;

/**
* @author marcio.endo@objectos.com.br (Marcio Endo)
*/
@Test
@Guice(modules = { RioTestModule.class })
public class ConfigCommandTest {

  @Inject
  private Cli cli;

  @Inject
  private RioDirs dirs;
  @Inject
  private Etcs etcs;

  @BeforeClass
  public void setUp() {
    RioDirsUserSettings user = dirs.userSettings();
    Directory core = user.core();
    core.deleteContents();
  }

  public void user_name_get() {
    String[] args = FakeArgs.of("config", "user.name", "xpto");

    cli.execute(args);

    args = FakeArgs.of("config", "user.name");

    cli.execute(args);

    // can't really test this...
  }

  public void user_name_set() {
    String[] args = FakeArgs.of("config", "user.name", "moe");

    cli.execute(args);

    User res = etcs.read(User.class);
    assertThat(res.getName(), equalTo("moe"));
  }

}
TOP

Related Classes of br.com.objectos.rio.config.ConfigCommandTest

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.