<commit_before>#!/usr/bin/perl

use strict;
use warnings;

use Test::More tests => 2;
use Test::Exception;

use InterMine::Model;
use InterMine::PathQuery qw(AND OR);

#use Exception::Warning '%SIG' => 'die';

my $model = new InterMine::Model(file => '../objectstore/model/testmodel/testmodel_model.xml');

my $path_query = new InterMine::PathQuery($model);

$path_query->add_view('Department.name');
$path_query->add_view('Department.company.name');

my $depname_c = $path_query->add_constraint('Department.name != "Music department"');
my $not_null_c = $path_query->add_constraint('Department.name IS NOT NULL');
my $comp_name_c = $path_query->add_constraint('Department.company.name = Woolworths');

my $expected_xml = q[<query name="" model="testmodel" view="Department.name Department.company.name" sortOrder="Department.name" constraintLogic="">
   <node path="Department.company.name" type="String">
      <constraint op="=" value="Woolworths" code="C"></constraint>
   </node>
   <node path="Department.name" type="String">
      <constraint op="!=" value="Music department" code="A"></constraint>
      <constraint op="IS NOT NULL" code="B"></constraint>
   </node>
</query>];

is ($path_query->to_xml_string(), $expected_xml, 'xml output');

$path_query->logic(AND($depname_c, OR($not_null_c, $comp_name_c)));

$expected_xml = q[<query name="" model="testmodel" view="Department.name Department.company.name" sortOrder="Department.name" constraintLogic="A and (B or C)">
   <node path="Department.company.name" type="String">
      <constraint op="=" value="Woolworths" code="C"></constraint>
   </node>
   <node path="Department.name" type="String">
      <constraint op="!=" value="Music department" code="A"></constraint>
      <constraint op="IS NOT NULL" code="B"></constraint>
   </node>
</query>];

is ($path_query->to_xml_string(), $expected_xml, 'xml output');
<commit_msg>Changed test to not expect empty logic strings<commit_after>#!/usr/bin/perl

use strict;
use warnings;

use Test::More tests => 2;
use Test::Exception;

use InterMine::Model;
use InterMine::PathQuery qw(AND OR);

#use Exception::Warning '%SIG' => 'die';

my $model = new InterMine::Model(file => '../objectstore/model/testmodel/testmodel_model.xml');

my $path_query = new InterMine::PathQuery($model);

$path_query->add_view('Department.name');
$path_query->add_view('Department.company.name');

my $depname_c = $path_query->add_constraint('Department.name != "Music department"');
my $not_null_c = $path_query->add_constraint('Department.name IS NOT NULL');
my $comp_name_c = $path_query->add_constraint('Department.company.name = Woolworths');

my $expected_xml = q[<query name="" model="testmodel" view="Department.name Department.company.name" sortOrder="Department.name">
   <node path="Department.company.name" type="String">
      <constraint op="=" value="Woolworths" code="C"></constraint>
   </node>
   <node path="Department.name" type="String">
      <constraint op="!=" value="Music department" code="A"></constraint>
      <constraint op="IS NOT NULL" code="B"></constraint>
   </node>
</query>];

is ($path_query->to_xml_string(), $expected_xml, 'xml output');

$path_query->logic(AND($depname_c, OR($not_null_c, $comp_name_c)));

$expected_xml = q[<query name="" model="testmodel" view="Department.name Department.company.name" sortOrder="Department.name" constraintLogic="A and (B or C)">
   <node path="Department.company.name" type="String">
      <constraint op="=" value="Woolworths" code="C"></constraint>
   </node>
   <node path="Department.name" type="String">
      <constraint op="!=" value="Music department" code="A"></constraint>
      <constraint op="IS NOT NULL" code="B"></constraint>
   </node>
</query>];

is ($path_query->to_xml_string(), $expected_xml, 'xml output');

{'fraction_non_alphanumeric': 0.18667719852553977, 'fraction_numerical': 0.000526592943654555, 'mean_word_length': 6.127579737335835, 'pattern_counts': {'":': 0, '<': 51, '<?xml version=': 0, '>': 73, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 18}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5437508', 'n_tokens_mistral': 1245, 'n_tokens_neox': 1209, 'n_words': 260}