From Grupo6 Especoo
package sistemaordemservico;
import junit.framework.TestCase;
public class TesteAtenderChamados extends TestCase
{
public void testAtenderChamadosNOK1()
{
System.out.println("testAtenderChamadosNOK1()");
Atendente atendenteInserir = new Atendente();
atendenteInserir.setIdAtend(1235);
atendenteInserir.setNome("Atendente1");
Atendentes.getInstance().inserirAtendenteTeste(atendenteInserir);
Chamado chamadoInserir = new Chamado();
chamadoInserir.setNroChamado(4562);
chamadoInserir.setIdFunc(492563);
chamadoInserir.setDepartamento("RH");
chamadoInserir.setDescricao("Problema no mouse");
chamadoInserir.setAtendente(atendenteInserir);
chamadoInserir.setIdStatus(StatusChamado.AGUARDANDO_ATENDIMENTO);
Chamados.getInstance().inserirChamadoTeste(chamadoInserir);
Integer idAtend = new Integer("1236");
TMsgErro tMsgErro = new TMsgErro();
CtrlBuscaChamados ctrlBuscaChamados = new CtrlBuscaChamados();
ctrlBuscaChamados.addPropertyChangeListener(tMsgErro);
TelaBuscaChamados telaBuscaChamados = new TelaBuscaChamados(ctrlBuscaChamados);
telaBuscaChamados.inserirDadosAtendente(idAtend);
assertTrue("Ausencia de chamados por atendente".equals(tMsgErro.getMsgErro()));
}
public void testAtenderChamadosNOK2()
{
System.out.println("testAtenderChamadosNOK2()");
Atendente atendenteInserir = new Atendente();
atendenteInserir.setIdAtend(1236);
atendenteInserir.setNome("Atendente1");
Atendentes.getInstance().inserirAtendenteTeste(atendenteInserir);
Chamado chamadoInserir = new Chamado();
chamadoInserir.setNroChamado(4563);
chamadoInserir.setIdFunc(492563);
chamadoInserir.setDepartamento("RH");
chamadoInserir.setDescricao("Problema no mouse");
chamadoInserir.setAtendente(atendenteInserir);
chamadoInserir.setIdStatus(StatusChamado.AGUARDANDO_ATENDIMENTO);
Chamados.getInstance().inserirChamadoTeste(chamadoInserir);
Integer idAtend = new Integer("1236");
TMsgErro tMsgErro = new TMsgErro();
CtrlBuscaChamados ctrlBuscaChamados = new CtrlBuscaChamados();
ctrlBuscaChamados.addPropertyChangeListener(tMsgErro);
TelaBuscaChamados telaBuscaChamados = new TelaBuscaChamados(ctrlBuscaChamados);
telaBuscaChamados.inserirDadosAtendente(idAtend);
assertNull(tMsgErro.getMsgErro());
assertTrue("Tela de exibe chamados do atendente".equals(tMsgErro.getMsgTela()));
Chamado chamado = new Chamado();
chamado.setNroChamado(56);
CtrlExibeChamados ctrlExibeChamados = new CtrlExibeChamados();
ctrlExibeChamados.addPropertyChangeListener(tMsgErro);
TelaExibeChamados telaExibeChamados = new TelaExibeChamados(ctrlExibeChamados);
telaExibeChamados.alterarStatus(chamado);
assertTrue("Tela de alteracao de status".equals(tMsgErro.getMsgTela()));
CtrlAlteraStatus ctrlAlteraStatus = new CtrlAlteraStatus();
ctrlAlteraStatus.addPropertyChangeListener(tMsgErro);
TelaAlteraStatus telaAlteraStatus = new TelaAlteraStatus(ctrlAlteraStatus);
telaAlteraStatus.inserirStatusChamado(StatusChamado.EM_ATENDIMENTO, "trocar mouse");
assertTrue("Erro na atualizacao do status do chamado".equals(tMsgErro.getMsgErro()));
}
public void testAtenderChamadosOK()
{
System.out.println("testAtenderChamadosOK()");
Atendente atendenteInserir = new Atendente();
atendenteInserir.setIdAtend(1237);
atendenteInserir.setNome("Atendente1");
Atendentes.getInstance().inserirAtendenteTeste(atendenteInserir);
Chamado chamadoInserir = new Chamado();
chamadoInserir.setNroChamado(4564);
chamadoInserir.setIdFunc(492563);
chamadoInserir.setDepartamento("RH");
chamadoInserir.setDescricao("Problema na impressora");
chamadoInserir.setAtendente(atendenteInserir);
chamadoInserir.setIdStatus(StatusChamado.EM_ATENDIMENTO);
Chamados.getInstance().inserirChamadoTeste(chamadoInserir);
Integer idAtend = new Integer("1237");
TMsgErro tMsgErro = new TMsgErro();
CtrlBuscaChamados ctrlBuscaChamados = new CtrlBuscaChamados();
ctrlBuscaChamados.addPropertyChangeListener(tMsgErro);
TelaBuscaChamados telaBuscaChamados = new TelaBuscaChamados(ctrlBuscaChamados);
telaBuscaChamados.inserirDadosAtendente(idAtend);
assertNull(tMsgErro.getMsgErro());
assertTrue("Tela de exibe chamados do atendente".equals(tMsgErro.getMsgTela()));
Chamado chamado = new Chamado();
chamado.setNroChamado(4564);
CtrlExibeChamados ctrlExibeChamados = new CtrlExibeChamados();
ctrlExibeChamados.addPropertyChangeListener(tMsgErro);
TelaExibeChamados telaExibeChamados = new TelaExibeChamados(ctrlExibeChamados);
telaExibeChamados.alterarStatus(chamado);
assertNull(tMsgErro.getMsgErro());
assertTrue("Tela de alteracao de status".equals(tMsgErro.getMsgTela()));
CtrlAlteraStatus ctrlAlteraStatus = new CtrlAlteraStatus();
ctrlAlteraStatus.addPropertyChangeListener(tMsgErro);
TelaAlteraStatus telaAlteraStatus = new TelaAlteraStatus(ctrlAlteraStatus);
telaAlteraStatus.inserirStatusChamado(StatusChamado.FINALIZADO, "troca do toner");
assertNull(tMsgErro.getMsgErro());
assertTrue("Tela de confirmacao de alteracao de status de chamado".equals(tMsgErro.getMsgTela()));
}
}