void ribi::braw::qtbrainweaverconceptmapdialog_test::a_file_its_conceptmap_must_have_a_center_node()
{
  //If this dialog is fed with a file with only a focal question, it will create a one-node concept map
  try
  {
    const std::string question = "TESTQUESTION";
    File file;
    file.SetQuestion(question);
    QVERIFY(file.GetCluster().Empty());
    QVERIFY(!boost::num_vertices(file.GetConceptMap()));

    ribi::cmap::ConceptMap concept_map;
    add_custom_and_selectable_vertex(
      ribi::cmap::Node(ribi::cmap::Concept(question), true),false,concept_map);
    QVERIFY(boost::num_vertices(concept_map) > 0);
    file.SetConceptMap(concept_map);
    QVERIFY(file.GetQuestion() == question);
    QVERIFY(boost::num_vertices(file.GetConceptMap()));
    QVERIFY(!GetNodes(file.GetConceptMap()).empty());
    QVERIFY(HasCenterNode(file.GetConceptMap()));
    const QtConceptMapDialog d(file);
    assert(d.GetWidget());
    QVERIFY(boost::num_vertices(d.GetWidget()->GetConceptMap()) == 1);
  }
  catch (std::exception& e)
  {
    qDebug() << e.what();
    QVERIFY(!"Should not get here");
  }
}
ribi::braw::QtPrintRatingDialog::QtPrintRatingDialog(
    const File& file,
    QWidget *parent)
    : QtDialog(parent),
      ui(new Ui::QtPrintRatingDialog),
      m_file(file),
      m_widget(new cmap::QtConceptMap)
{
    if (boost::num_vertices(file.GetConceptMap()) == 0)
    {
        std::stringstream msg;
        msg << __func__ << ": must have at least one node";
        throw std::invalid_argument(msg.str());
    }

    ui->setupUi(this);
    setWindowFlags(windowFlags() & ~Qt::WindowContextHelpButtonHint); //Remove help

    m_widget->SetConceptMap(file.GetConceptMap());
    ui->label_focal_question->setText(
        ("FOCUSVRAAG: "
         + m_file.GetQuestion()).c_str()
    );
    ui->label_student_name->setText(
        ("VAN: "
         + m_file.GetStudentName()).c_str()
    );
    ui->label_assessor_name->setText(
        ("ASSESSOR: "
         + m_file.GetAssessorName()).c_str()
    );

    {
        assert(m_widget);
        assert(ui->frame_concept_map->layout());
        ui->frame_concept_map->layout()->addWidget(m_widget);
    }

    //Allow a QtConceptMapWidget to have no QtExamplesItem
    //This allows to omit showing these in the PDF versions used for printing (#205)
    HideExamplesItem(*m_widget);

    {
        std::time_t my_time;
        std::time( &my_time );
        const std::tm * const time_and_date = std::localtime(&my_time);
        const std::string s = std::asctime(time_and_date);
        ui->label_date->setText( ("Datum: " + s).c_str()
                               );
    }
}
void ribi::braw::qtbrainweaverclusterdialog_test
  ::button_next_clicked_with_concept_map()
{
  File file = FileFactory().Get5();
  assert(boost::num_vertices(file.GetConceptMap()));
  QtClusterDialog d(file);
  d.show();
  d.on_button_next_clicked();
}
void ribi::braw::qtbrainweaverclusterdialog_test
  ::cluster_dialog_must_be_enabled_if_there_is_no_concept_map()
{
  using namespace ribi::cmap;
  File file = FileFactory().Get0();

  const Cluster cluster = ClusterFactory().GetTest( {0,1,2} );
  file.SetCluster(cluster);

  QVERIFY(!file.GetCluster().Empty());
  QVERIFY(boost::num_vertices(file.GetConceptMap()) == 0);

  const QtClusterDialog d(file);
  const auto w = d.GetWidget();
  QVERIFY(w && w->isEnabled());
}
void ribi::braw::qtbrainweaverconceptmapdialog_test::a_file_with_cluster_only_will_create_a_concept_map()
{
  //using namespace cmap;
  const std::string question = "TESTQUESTION";
  File file;
  file.SetQuestion(question);
  Cluster cluster(
    {
      ribi::cmap::Concept("name 1"),
      ribi::cmap::Concept("name 2")
    }
  );
  file.SetCluster(cluster);

  QVERIFY(!boost::num_vertices(file.GetConceptMap()));

  const QtConceptMapDialog d(file);


  QVERIFY(boost::num_vertices(d.GetWidget()->GetConceptMap())
    == cluster.Get().size() + 1); //+1 because of focus question
}