How to use generic class

Best Atoum code snippet using generic

GenericSparqlTest.php

Source:GenericSparqlTest.php Github

copy

Full Screen

1<?php2class GenericSparqlTest extends PHPUnit\Framework\TestCase3{4 private $model;5 private $graph;6 private $sparql;7 private $vocab;8 private $params;9 protected function setUp() {10 putenv("LC_ALL=en_GB.utf8");11 setlocale(LC_ALL, 'en_GB.utf8');12 $this->model = new Model(new GlobalConfig('/../tests/testconfig.inc'));13 $this->vocab = $this->model->getVocabulary('test');14 $this->graph = $this->vocab->getGraph();15 $this->params = $this->getMockBuilder('ConceptSearchParameters')->disableOriginalConstructor()->getMock();16 $this->sparql = new GenericSparql('http://localhost:3030/ds/sparql', $this->graph, $this->model);17 }18 /**19 * @covers GenericSparql::__construct20 */21 public function testConstructor() {22 $gs = new GenericSparql('http://localhost:3030/ds/sparql', $this->graph, $this->model);23 $this->assertInstanceOf('GenericSparql', $gs);24 }25 /**26 * @covers GenericSparql::getGraph27 */28 public function testGetGraph() {29 $gs = new GenericSparql('http://localhost:3030/ds/sparql', $this->graph, $this->model);30 $this->assertEquals($this->graph, $gs->getGraph());31 }32 /**33 * @covers GenericSparql::countConcepts34 * @covers GenericSparql::generateCountConceptsQuery35 * @covers GenericSparql::transformCountConceptsResults36 */37 public function testCountConcepts() {38 $actual = $this->sparql->countConcepts();39 $this->assertEquals(16, $actual['http://www.w3.org/2004/02/skos/core#Concept']['count']);40 }41 /**42 * @covers GenericSparql::countLangConcepts43 * @covers GenericSparql::generateCountLangConceptsQuery44 * @covers GenericSparql::transformCountLangConceptsResults45 */46 public function testCountLangConceptsOneLang() {47 $actual = $this->sparql->countLangConcepts(array('en'));48 $this->assertEquals(11, $actual['en']['skos:prefLabel']);49 $this->assertEquals(1, $actual['en']['skos:altLabel']);50 }51 /**52 * @covers GenericSparql::countLangConcepts53 * @covers GenericSparql::generateCountLangConceptsQuery54 * @covers GenericSparql::transformCountLangConceptsResults55 */56 public function testCountLangConceptsMultipleLangs() {57 $actual = $this->sparql->countLangConcepts(array('en','fi'));58 $this->assertEquals(11, $actual['en']['skos:prefLabel']);59 $this->assertEquals(1, $actual['en']['skos:altLabel']);60 $this->assertEquals(2, $actual['fi']['skos:prefLabel']);61 }62 /**63 * @covers GenericSparql::queryFirstCharacters64 * @covers GenericSparql::generateFirstCharactersQuery65 * @covers GenericSparql::transformFirstCharactersResults66 */67 public function testQueryFirstCharacters() {68 $actual = $this->sparql->queryFirstCharacters('en');69 sort($actual);70 $this->assertEquals(array("-","3","B","C","E","F","M","T"), $actual);71 }72 /**73 * @covers GenericSparql::queryLabel74 */75 public function testQueryLabelWhenConceptNotFound() {76 $actual = $this->sparql->queryLabel('http://notfound', null);77 $this->assertEquals(null, $actual);78 }79 /**80 * @covers GenericSparql::queryLabel81 */82 public function testQueryLabelWhenLabelNotFound() {83 $actual = $this->sparql->queryLabel('http://www.skosmos.skos/test/ta120', null);84 $this->assertEquals(array(), $actual);85 }86 /**87 * @covers GenericSparql::queryConceptsAlphabetical88 * @covers GenericSparql::generateAlphabeticalListQuery89 * @covers GenericSparql::formatFilterConditions90 * @covers GenericSparql::transformAlphabeticalListResults91 */92 public function testQueryConceptsAlphabetical() {93 $actual = $this->sparql->queryConceptsAlphabetical('b', 'en');94 $expected = array (95 0 => array (96 'uri' => 'http://www.skosmos.skos/test/ta116',97 'localname' => 'ta116',98 'prefLabel' => 'Bass',99 'lang' => 'en',100 ),101 1 => array (102 'uri' => 'http://www.skosmos.skos/test/ta122',103 'localname' => 'ta122',104 'prefLabel' => 'Black sea bass',105 'lang' => 'en',106 ),107 2 => array (108 'uri' => 'http://www.skosmos.skos/test/ta114',109 'localname' => 'ta114',110 'prefLabel' => 'Buri',111 'lang' => 'en',112 ),113 );114 $this->assertEquals($expected, $actual);115 }116 /**117 * @covers GenericSparql::queryConceptsAlphabetical118 * @covers GenericSparql::generateAlphabeticalListQuery119 * @covers GenericSparql::formatFilterConditions120 * @covers GenericSparql::formatLimitAndOffset121 * @covers GenericSparql::transformAlphabeticalListResults122 */123 public function testQueryConceptsAlphabeticalLimit() {124 $actual = $this->sparql->queryConceptsAlphabetical('b', 'en', 2);125 $expected = array (126 0 => array (127 'uri' => 'http://www.skosmos.skos/test/ta116',128 'localname' => 'ta116',129 'prefLabel' => 'Bass',130 'lang' => 'en',131 ),132 1 => array (133 'uri' => 'http://www.skosmos.skos/test/ta122',134 'localname' => 'ta122',135 'prefLabel' => 'Black sea bass',136 'lang' => 'en',137 ),138 );139 $this->assertEquals($expected, $actual);140 }141 /**142 * @covers GenericSparql::queryConceptsAlphabetical143 * @covers GenericSparql::generateAlphabeticalListQuery144 * @covers GenericSparql::formatFilterConditions145 * @covers GenericSparql::formatLimitAndOffset146 * @covers GenericSparql::transformAlphabeticalListResults147 */148 public function testQueryConceptsAlphabeticalLimitAndOffset() {149 $actual = $this->sparql->queryConceptsAlphabetical('b', 'en', 2, 1);150 $expected = array (151 0 => array (152 'uri' => 'http://www.skosmos.skos/test/ta122',153 'localname' => 'ta122',154 'prefLabel' => 'Black sea bass',155 'lang' => 'en',156 ),157 1 => array (158 'uri' => 'http://www.skosmos.skos/test/ta114',159 'localname' => 'ta114',160 'prefLabel' => 'Buri',161 'lang' => 'en',162 ),163 );164 $this->assertEquals($expected, $actual);165 }166 /**167 * @covers GenericSparql::queryConceptsAlphabetical168 * @covers GenericSparql::generateAlphabeticalListQuery169 * @covers GenericSparql::formatFilterConditions170 * @covers GenericSparql::transformAlphabeticalListResults171 */172 public function testQueryConceptsAlphabeticalNoResults() {173 $actual = $this->sparql->queryConceptsAlphabetical('x', 'en');174 $expected = array();175 $this->assertEquals($expected, $actual);176 }177 /**178 * @covers GenericSparql::queryConceptsAlphabetical179 * @covers GenericSparql::generateAlphabeticalListQuery180 * @covers GenericSparql::formatFilterConditions181 * @covers GenericSparql::transformAlphabeticalListResults182 */183 public function testQueryConceptsAlphabeticalSpecialChars() {184 $actual = $this->sparql->queryConceptsAlphabetical('!*', 'en');185 $this->assertEquals(1, sizeof($actual));186 $this->assertEquals('-"special" character \\example\\', $actual[0]['prefLabel']);187 }188 /**189 * @covers GenericSparql::queryConceptsAlphabetical190 * @covers GenericSparql::generateAlphabeticalListQuery191 * @covers GenericSparql::formatFilterConditions192 * @covers GenericSparql::transformAlphabeticalListResults193 */194 public function testQueryConceptsAlphabeticalNumbers() {195 $actual = $this->sparql->queryConceptsAlphabetical('0-9', 'en');196 $this->assertEquals(1, sizeof($actual));197 $this->assertContains("3D", $actual[0]['prefLabel']);198 }199 /**200 * @covers GenericSparql::queryConceptsAlphabetical201 * @covers GenericSparql::generateAlphabeticalListQuery202 * @covers GenericSparql::formatFilterConditions203 * @covers GenericSparql::transformAlphabeticalListResults204 */205 public function testQueryConceptsAlphabeticalFull() {206 $actual = $this->sparql->queryConceptsAlphabetical('*', 'en');207 $this->assertEquals(11, sizeof($actual));208 }209 /**210 * @covers GenericSparql::queryConceptInfo211 * @covers GenericSparql::queryConceptInfoGraph212 * @covers GenericSparql::generateConceptInfoQuery213 * @covers GenericSparql::transformConceptInfoResults214 * @covers GenericSparql::filterDuplicateVocabs215 * @covers GenericSparql::getVocabGraphs216 * @covers GenericSparql::formatValuesGraph217 */218 public function testQueryConceptInfoWithMultipleVocabs()219 {220 $this->sparql = new GenericSparql('http://localhost:3030/ds/sparql', '?graph', $this->model);221 $voc2 = $this->model->getVocabulary('test');222 $voc3 = $this->model->getVocabulary('dates');223 $voc4 = $this->model->getVocabulary('groups');224 $actual = $this->sparql->queryConceptInfo(array('http://www.skosmos.skos/test/ta121', 'http://www.skosmos.skos/groups/ta111'), null, array($voc2, $voc3, $voc4), 'en');225 $this->assertInstanceOf('Concept', $actual[0]);226 $this->assertEquals('http://www.skosmos.skos/test/ta121', $actual[0]->getUri());227 $this->assertEquals('http://www.skosmos.skos/groups/ta111', $actual[1]->getUri());228 $this->assertEquals(2, sizeof($actual));229 }230 /**231 * @covers GenericSparql::queryConceptInfo232 * @covers GenericSparql::queryConceptInfoGraph233 * @covers GenericSparql::generateConceptInfoQuery234 * @covers GenericSparql::transformConceptInfoResults235 * @covers GenericSparql::filterDuplicateVocabs236 * @covers GenericSparql::getVocabGraphs237 * @covers GenericSparql::formatValuesGraph238 */239 public function testQueryConceptInfoWithAllVocabs()240 {241 $this->sparql = new GenericSparql('http://localhost:3030/ds/sparql', '?graph', $this->model);242 $actual = $this->sparql->queryConceptInfo(array('http://www.skosmos.skos/test/ta121', 'http://www.skosmos.skos/groups/ta111'), null, null, 'en');243 $this->assertInstanceOf('Concept', $actual[0]);244 $this->assertEquals('http://www.skosmos.skos/test/ta121', $actual[0]->getUri());245 $this->assertEquals('http://www.skosmos.skos/groups/ta111', $actual[1]->getUri());246 $this->assertEquals(2, sizeof($actual));247 }248 /**249 * @covers GenericSparql::queryConceptInfo250 * @covers GenericSparql::queryConceptInfoGraph251 * @covers GenericSparql::generateConceptInfoQuery252 * @covers GenericSparql::transformConceptInfoResults253 * @covers GenericSparql::filterDuplicateVocabs254 */255 public function testQueryConceptInfoWithMultipleSameVocabs()256 {257 $actual = $this->sparql->queryConceptInfo(array('http://www.skosmos.skos/test/ta123'), null, array($this->vocab, $this->vocab, $this->vocab, $this->vocab, $this->vocab), 'en');258 $this->assertInstanceOf('Concept', $actual[0]);259 $this->assertEquals('http://www.skosmos.skos/test/ta123', $actual[0]->getUri());260 $this->assertEquals(1, sizeof($actual));261 }262 /**263 * @covers GenericSparql::queryConceptInfo264 * @covers GenericSparql::queryConceptInfoGraph265 * @covers GenericSparql::generateConceptInfoQuery266 * @covers GenericSparql::transformConceptInfoResults267 * @covers GenericSparql::formatValues268 */269 public function testQueryConceptInfoWithOneURI()270 {271 $actual = $this->sparql->queryConceptInfo(array('http://www.skosmos.skos/test/ta123'), null, array($this->vocab), 'en');272 $this->assertInstanceOf('Concept', $actual[0]);273 $this->assertEquals('http://www.skosmos.skos/test/ta123', $actual[0]->getUri());274 }275 /**276 * @covers GenericSparql::queryConceptInfo277 * @covers GenericSparql::queryConceptInfoGraph278 * @covers GenericSparql::generateConceptInfoQuery279 * @covers GenericSparql::transformConceptInfoResults280 * @covers GenericSparql::formatValues281 */282 public function testQueryConceptInfoWithOneURINotInArray()283 {284 $actual = $this->sparql->queryConceptInfo('http://www.skosmos.skos/test/ta123', null, array($this->vocab), 'en');285 $this->assertInstanceOf('Concept', $actual[0]);286 $this->assertEquals('http://www.skosmos.skos/test/ta123', $actual[0]->getUri());287 }288 /**289 * @covers GenericSparql::queryTypes290 * @covers GenericSparql::generateQueryTypesQuery291 * @covers GenericSparql::transformQueryTypesResults292 */293 public function testQueryTypes()294 {295 $actual = $this->sparql->queryTypes('en');296 $expected = array(297 'http://www.w3.org/2004/02/skos/core#Concept' => array(),298 'http://www.skosmos.skos/test-meta/TestClass' => array(299 'superclass' => 'http://www.w3.org/2004/02/skos/core#Concept',300 'label' => 'Test class'301 )302 );303 $this->assertEquals($expected, $actual);304 }305 /**306 * @covers GenericSparql::queryConceptScheme307 * @covers GenericSparql::generateQueryConceptSchemeQuery308 */309 public function testQueryConceptScheme()310 {311 $actual = $this->sparql->queryConceptScheme('http://www.skosmos.skos/test/conceptscheme');312 $this->assertInstanceOf('EasyRdf\Graph', $actual);313 $this->assertEquals('http://localhost:3030/ds/sparql', $actual->getUri());314 }315 /**316 * @covers GenericSparql::queryConceptSchemes317 * @covers GenericSparql::generateQueryConceptSchemesQuery318 * @covers GenericSparql::transformQueryConceptSchemesResults319 */320 public function testQueryConceptSchemes()321 {322 $actual = $this->sparql->queryConceptSchemes('en');323 foreach($actual as $scheme=>$label) {324 $this->assertEquals('http://www.skosmos.skos/test/conceptscheme', $scheme);325 $this->assertEquals('Test conceptscheme', $label['label']);326 }327 }328 /**329 * @covers GenericSparql::queryConceptSchemes330 * @covers GenericSparql::generateQueryConceptSchemesQuery331 * @covers GenericSparql::transformQueryConceptSchemesResults332 */333 public function testQueryConceptSchemesSubject()334 {335 $sparql = new GenericSparql('http://localhost:3030/ds/sparql', 'http://www.skosmos.skos/test-concept-schemes/', $this->model);336 $actual = $sparql->queryConceptSchemes('en');337 $expected = array(338 'http://exemple.fr/domains' => array(339 'prefLabel' => 'Special Domains Concept Scheme'340 ),341 'http://exemple.fr/mt1' => array(342 'prefLabel' => 'Micro-Thesaurus 1',343 'subject' => array(344 'uri' => 'http://exemple.fr/d1',345 'prefLabel' => 'Domain 1'346 )347 ),348 'http://exemple.fr/mt2' => array(349 'prefLabel' => 'Micro-Thesaurus 2',350 'subject' => array(351 'uri' => 'http://exemple.fr/d1',352 'prefLabel' => 'Domain 1'353 )354 ),355 'http://exemple.fr/mt3' => array(356 'prefLabel' => 'Micro-Thesaurus 3',357 'subject' => array(358 'uri' => 'http://exemple.fr/d2',359 'prefLabel' => 'Domain 2'360 )361 ),362 'http://exemple.fr/thesaurus' => array(363 'prefLabel' => 'The Thesaurus'364 ),365 );366 $this->assertEquals($expected, $actual);367 }368 /**369 * @covers GenericSparql::queryConcepts370 * @covers GenericSparql::generateConceptSearchQueryCondition371 * @covers GenericSparql::generateConceptSearchQueryInner372 * @covers GenericSparql::generateConceptSearchQuery373 * @covers GenericSparql::formatFilterGraph374 * @covers GenericSparql::transformConceptSearchResults375 * @covers GenericSparql::transformConceptSearchResult376 * @covers GenericSparql::shortenUri377 */378 public function testQueryConceptsMultipleVocabs()379 {380 $voc = $this->model->getVocabulary('test');381 $voc2 = $this->model->getVocabulary('groups');382 $this->params->method('getSearchTerm')->will($this->returnValue('Carp'));383 $this->params->method('getVocabs')->will($this->returnValue(array($voc, $voc2)));384 $sparql = new GenericSparql('http://localhost:3030/ds/sparql', '?graph', $this->model);385 $actual = $sparql->queryConcepts(array($voc, $voc2), null, null, $this->params);386 $this->assertEquals(2, sizeof($actual));387 $this->assertEquals('http://www.skosmos.skos/groups/ta112', $actual[0]['uri']);388 $this->assertEquals('http://www.skosmos.skos/test/ta112', $actual[1]['uri']);389 }390 /**391 * @covers GenericSparql::queryConcepts392 * @covers GenericSparql::generateConceptSearchQueryCondition393 * @covers GenericSparql::generateConceptSearchQueryInner394 * @covers GenericSparql::generateConceptSearchQuery395 * @covers GenericSparql::formatFilterGraph396 * @covers GenericSparql::transformConceptSearchResults397 * @covers GenericSparql::transformConceptSearchResult398 * @covers GenericSparql::shortenUri399 */400 public function testQueryConceptsMultipleSchemes()401 {402 $voc = $this->model->getVocabulary('multiple-schemes');403 // returns 3 concepts without the scheme limit, and only 2 with the scheme limit below404 $this->params->method('getSearchTerm')->will($this->returnValue('concept*'));405 $this->params->method('getSchemeLimit')->will($this->returnValue(array('http://www.skosmos.skos/multiple-schemes/cs1', 'http://www.skosmos.skos/multiple-schemes/cs2')));406 $sparql = new GenericSparql('http://localhost:3030/ds/sparql', 'http://www.skosmos.skos/multiple-schemes/', $this->model);407 $actual = $sparql->queryConcepts(array($voc), null, null, $this->params);408 $this->assertEquals(2, sizeof($actual));409 $this->assertEquals('http://www.skosmos.skos/multiple-schemes/c1-in-cs1', $actual[0]['uri']);410 $this->assertEquals('http://www.skosmos.skos/multiple-schemes/c2-in-cs2', $actual[1]['uri']);411 }412 /**413 * @covers GenericSparql::queryConcepts414 * @covers GenericSparql::generateConceptSearchQueryCondition415 * @covers GenericSparql::generateConceptSearchQueryInner416 * @covers GenericSparql::generateConceptSearchQuery417 * @covers GenericSparql::formatFilterGraph418 * @covers GenericSparql::transformConceptSearchResults419 * @covers GenericSparql::transformConceptSearchResult420 * @covers GenericSparql::shortenUri421 */422 public function testQueryConcepts()423 {424 $voc = $this->model->getVocabulary('test');425 $this->params->method('getSearchTerm')->will($this->returnValue('bass*'));426 $this->params->method('getVocabIds')->will($this->returnValue(array('test')));427 $actual = $this->sparql->queryConcepts(array($voc), null, null, $this->params);428 $this->assertEquals(1, sizeof($actual));429 $this->assertEquals('Bass', $actual[0]['prefLabel']);430 }431 /**432 * @covers GenericSparql::queryConcepts433 * @covers GenericSparql::generateConceptSearchQueryCondition434 * @covers GenericSparql::generateConceptSearchQueryInner435 * @covers GenericSparql::generateConceptSearchQuery436 * @covers GenericSparql::formatFilterGraph437 * @covers GenericSparql::transformConceptSearchResults438 * @covers GenericSparql::transformConceptSearchResult439 * @covers GenericSparql::shortenUri440 */441 public function testQueryConceptsMatchAltLabel()442 {443 $voc = $this->model->getVocabulary('test');444 $this->params->method('getSearchTerm')->will($this->returnValue('Golden*'));445 $this->params->method('getVocabIds')->will($this->returnValue(array('test')));446 $actual = $this->sparql->queryConcepts(array($voc), null, null, $this->params);447 $this->assertEquals(1, sizeof($actual));448 $this->assertEquals('Carp', $actual[0]['prefLabel']);449 }450 /**451 * @covers GenericSparql::queryConcepts452 * @covers GenericSparql::generateConceptSearchQueryCondition453 * @covers GenericSparql::generateConceptSearchQueryInner454 * @covers GenericSparql::generateConceptSearchQuery455 * @covers GenericSparql::formatFilterGraph456 * @covers GenericSparql::transformConceptSearchResults457 * @covers GenericSparql::transformConceptSearchResult458 * @covers GenericSparql::shortenUri459 */460 public function testQueryConceptsMatchHiddenLabel()461 {462 $voc = $this->model->getVocabulary('test');463 $this->params->method('getSearchTerm')->will($this->returnValue('Karpit*'));464 $this->params->method('getVocabIds')->will($this->returnValue(array('test')));465 $this->params->method('getHidden')->will($this->returnValue(true));466 $actual = $this->sparql->queryConcepts(array($voc), null, null, $this->params);467 $this->assertEquals(1, sizeof($actual));468 $this->assertEquals('Karppi', $actual[0]['prefLabel']);469 }470 /**471 * @covers GenericSparql::queryConcepts472 * @covers GenericSparql::generateConceptSearchQueryCondition473 * @covers GenericSparql::generateConceptSearchQueryInner474 * @covers GenericSparql::generateConceptSearchQuery475 * @covers GenericSparql::formatFilterGraph476 * @covers GenericSparql::transformConceptSearchResults477 * @covers GenericSparql::transformConceptSearchResult478 * @covers GenericSparql::shortenUri479 */480 public function testQueryConceptsMatchNotation()481 {482 $voc = $this->model->getVocabulary('test');483 $this->params->method('getSearchTerm')->will($this->returnValue('665*'));484 $this->params->method('getVocabIds')->will($this->returnValue(array('test')));485 $actual = $this->sparql->queryConcepts(array($voc), null, null, $this->params);486 $this->assertEquals(1, sizeof($actual));487 $this->assertEquals('http://www.skosmos.skos/test/ta112', $actual[0]['uri']);488 }489 /**490 * @covers GenericSparql::queryConcepts491 * @covers GenericSparql::generateConceptSearchQueryCondition492 * @covers GenericSparql::generateConceptSearchQueryInner493 * @covers GenericSparql::generateConceptSearchQuery494 * @covers GenericSparql::formatFilterGraph495 */496 public function testQueryConceptsAdditionalFields()497 {498 $voc = $this->model->getVocabulary('test');499 $this->params->method('getSearchTerm')->will($this->returnValue('bass*'));500 $this->params->method('getVocabIds')->will($this->returnValue(array('test')));501 $actual = $this->sparql->queryConcepts(array($voc), array('broader'), null, $this->params);502 $this->assertEquals(1, sizeof($actual));503 $this->assertEquals('Bass', $actual[0]['prefLabel']);504 $this->assertEquals('http://www.skosmos.skos/test/ta1', $actual[0]['skos:broader'][0]['uri']);505 }506 /**507 * @covers GenericSparql::queryConcepts508 * @covers GenericSparql::generateConceptSearchQueryCondition509 * @covers GenericSparql::generateConceptSearchQueryInner510 * @covers GenericSparql::generateConceptSearchQuery511 * @covers GenericSparql::transformConceptSearchResults512 * @covers GenericSparql::transformConceptSearchResult513 * @covers GenericSparql::shortenUri514 */515 public function testQueryConceptsExactTerm()516 {517 $voc = $this->model->getVocabulary('test');518 $this->params->method('getSearchTerm')->will($this->returnValue('bass'));519 $this->params->method('getVocabIds')->will($this->returnValue(array('test')));520 $actual = $this->sparql->queryConcepts(array($voc), null, null, $this->params);521 $this->assertEquals(1, sizeof($actual));522 $this->assertEquals('Bass', $actual[0]['prefLabel']);523 }524 /**525 * @covers GenericSparql::queryConcepts526 * @covers GenericSparql::generateConceptSearchQueryCondition527 * @covers GenericSparql::generateConceptSearchQueryInner528 * @covers GenericSparql::generateConceptSearchQuery529 * @covers GenericSparql::transformConceptSearchResults530 * @covers GenericSparql::transformConceptSearchResult531 * @covers GenericSparql::shortenUri532 */533 public function testQueryConceptsAsteriskBeforeTerm()534 {535 $voc = $this->model->getVocabulary('test');536 $this->params->method('getSearchTerm')->will($this->returnValue('*bass'));537 $actual = $this->sparql->queryConcepts(array($voc), null, null, $this->params);538 $this->assertEquals(3, sizeof($actual));539 foreach($actual as $match)540 $this->assertContains('bass', $match['prefLabel'], '',true);541 }542 /**543 * @covers GenericSparql::queryConcepts544 * @covers GenericSparql::generateConceptSearchQueryCondition545 * @covers GenericSparql::generateConceptSearchQueryInner546 * @covers GenericSparql::generateConceptSearchQuery547 * @covers GenericSparql::transformConceptSearchResults548 * @covers GenericSparql::transformConceptSearchResult549 * @covers GenericSparql::shortenUri550 */551 public function testQueryConceptsAsteriskBeforeAndAfterTerm()552 {553 $voc = $this->model->getVocabulary('test');554 $this->params->method('getSearchTerm')->will($this->returnValue('*bass*'));555 $actual = $this->sparql->queryConcepts(array($voc), null, null, $this->params);556 $this->assertEquals(3, sizeof($actual));557 foreach($actual as $match)558 $this->assertContains('bass', $match['prefLabel'], '',true);559 }560 /**561 * @covers GenericSparql::queryLabel562 * @covers GenericSparql::generateLabelQuery563 */564 public function testQueryLabelNotExistingConcept()565 {566 $actual = $this->sparql->queryLabel('http://notfound', 'en');567 $this->assertEquals(null, $actual);568 }569 /**570 * @covers GenericSparql::queryLabel571 * @covers GenericSparql::generateLabelQuery572 */573 public function testQueryLabel()574 {575 $actual = $this->sparql->queryLabel('http://www.skosmos.skos/test/ta112', 'en');576 $expected = array('en' => 'Carp');577 $this->assertEquals($expected, $actual);578 }579 /**580 * @covers GenericSparql::queryLabel581 * @covers GenericSparql::generateLabelQuery582 */583 public function testQueryLabelWithoutLangParamGiven()584 {585 $actual = $this->sparql->queryLabel('http://www.skosmos.skos/test/ta112', null);586 $expected = array('en' => 'Carp', 'fi' => 'Karppi');587 $this->assertEquals($expected, $actual);588 }589 /**590 * @covers GenericSparql::queryProperty591 * @covers GenericSparql::transformPropertyQueryResults592 * @covers GenericSparql::generatePropertyQuery593 */594 public function testQueryPropertyForBroaderThatExists()595 {596 $actual = $this->sparql->queryProperty('http://www.skosmos.skos/test/ta116', 'skos:broader', 'en');597 $expected = array('http://www.skosmos.skos/test/ta1' => array('label' => 'Fish'));598 $this->assertEquals($expected, $actual);599 }600 /**601 * @covers GenericSparql::queryProperty602 * @covers GenericSparql::transformPropertyQueryResults603 * @covers GenericSparql::generatePropertyQuery604 */605 public function testQueryPropertyForNarrowerThatDoesntExist()606 {607 $actual = $this->sparql->queryProperty('http://www.skosmos.skos/test/ta116', 'skos:narrower', 'en');608 $expected = array();609 $this->assertEquals($expected, $actual);610 }611 /**612 * @covers GenericSparql::queryProperty613 * @covers GenericSparql::transformPropertyQueryResults614 * @covers GenericSparql::generatePropertyQuery615 */616 public function testQueryPropertyForNonexistentConcept()617 {618 $actual = $this->sparql->queryProperty('http://notfound', 'skos:narrower', 'en');619 $this->assertEquals(null, $actual);620 }621 /**622 * @covers GenericSparql::queryTransitiveProperty623 * @covers GenericSparql::generateTransitivePropertyQuery624 * @covers GenericSparql::transformTransitivePropertyResults625 */626 public function testQueryTransitiveProperty()627 {628 $actual = $this->sparql->queryTransitiveProperty('http://www.skosmos.skos/test/ta111', array('skos:broader'), 'en', '10');629 $expected = array(630 'http://www.skosmos.skos/test/ta111' =>631 array(632 'label' => 'Tuna',633 'direct' =>634 array (635 0 => 'http://www.skosmos.skos/test/ta1',636 ),637 ),638 'http://www.skosmos.skos/test/ta1' =>639 array (640 'label' => 'Fish',641 )642 );643 $this->assertEquals($expected, $actual);644 }645 /**646 * @covers GenericSparql::queryTransitiveProperty647 * @covers GenericSparql::generateTransitivePropertyQuery648 * @covers GenericSparql::transformTransitivePropertyResults649 */650 public function testQueryTransitivePropertyLongerPath()651 {652 $actual = $this->sparql->queryTransitiveProperty('http://www.skosmos.skos/test/ta122', array('skos:broader'), 'en', '10');653 $expected = array(654 'http://www.skosmos.skos/test/ta122' =>655 array (656 'label' => 'Black sea bass',657 'direct' =>658 array (659 0 => 'http://www.skosmos.skos/test/ta116',660 ),661 ),662 'http://www.skosmos.skos/test/ta1' =>663 array (664 'label' => 'Fish',665 ),666 'http://www.skosmos.skos/test/ta116' =>667 array (668 'label' => 'Bass',669 'direct' =>670 array (671 0 => 'http://www.skosmos.skos/test/ta1',672 ),673 ),674 );675 $this->assertEquals($expected, $actual);676 }677 /**678 * @covers GenericSparql::queryChildren679 * @covers GenericSparql::generateChildQuery680 * @covers GenericSparql::transformNarrowerResults681 */682 public function testQueryChildren()683 {684 $actual = $this->sparql->queryChildren('http://www.skosmos.skos/test/ta1', 'en', 'en', array('skos:broader'));685 $actual_uris = array();686 foreach ($actual as $child)687 $actual_uris[$child['uri']] = $child['uri'];688 $expected = array ('http://www.skosmos.skos/test/ta111','http://www.skosmos.skos/test/ta112','http://www.skosmos.skos/test/ta114','http://www.skosmos.skos/test/ta115','http://www.skosmos.skos/test/ta116','http://www.skosmos.skos/test/ta117','http://www.skosmos.skos/test/ta119','http://www.skosmos.skos/test/ta120');689 foreach ($expected as $uri)690 $this->assertArrayHasKey($uri, $actual_uris);691 }692 /**693 * @covers GenericSparql::queryChildren694 * @covers GenericSparql::generateChildQuery695 * @covers GenericSparql::transformNarrowerResults696 */697 public function testQueryChildrenOfNonExistentConcept()698 {699 $actual = $this->sparql->queryChildren('http://notfound', 'en', 'en', array('skos:broader'));700 $this->assertEquals(null, $actual);701 }702 /**703 * @covers GenericSparql::queryTopConcepts704 */705 public function testQueryTopConcepts()706 {707 $actual = $this->sparql->queryTopConcepts('http://www.skosmos.skos/test/conceptscheme', 'en', 'en');708 $this->assertEquals(array (0 => array ('uri' => 'http://www.skosmos.skos/test/ta1','label' => 'Fish','hasChildren' => true, 'topConceptOf' => 'http://www.skosmos.skos/test/conceptscheme')), $actual);709 }710 /**711 * @covers GenericSparql::queryTopConcepts712 */713 public function testQueryTopConceptsFallbackLanguage()714 {715 $actual = $this->sparql->queryTopConcepts('http://www.skosmos.skos/test/conceptscheme', 'fi', 'en');716 $this->assertEquals(array (0 => array ('uri' => 'http://www.skosmos.skos/test/ta1','label' => 'Fish (en)','hasChildren' => true, 'topConceptOf' => 'http://www.skosmos.skos/test/conceptscheme')), $actual);717 }718 /**719 * @covers GenericSparql::queryTopConcepts720 */721 public function testQueryTopConceptsOtherLanguage()722 {723 $actual = $this->sparql->queryTopConcepts('http://www.skosmos.skos/test/conceptscheme', 'fi', 'fi');724 $this->assertEquals(array (0 => array ('uri' => 'http://www.skosmos.skos/test/ta1','label' => 'Fish (en)','hasChildren' => true, 'topConceptOf' => 'http://www.skosmos.skos/test/conceptscheme')), $actual);725 }726 /**727 * @covers GenericSparql::queryParentList728 * @covers GenericSparql::generateParentListQuery729 * @covers GenericSparql::transformParentListResults730 */731 public function testQueryParentList()732 {733 $actual = $this->sparql->queryParentList('http://www.skosmos.skos/test/ta122', 'en', 'en', array('skos:broader'));734 $expected = array(735 'http://www.skosmos.skos/test/ta116' => array (736 'uri' => 'http://www.skosmos.skos/test/ta116',737 'prefLabel' => 'Bass',738 'broader' =>739 array (740 0 => 'http://www.skosmos.skos/test/ta1',741 ),742 ),743 'http://www.skosmos.skos/test/ta122' => array (744 'uri' => 'http://www.skosmos.skos/test/ta122',745 'prefLabel' => 'Black sea bass',746 'broader' =>747 array (748 0 => 'http://www.skosmos.skos/test/ta116',749 ),750 ),751 );752 $props = array (753 'uri' => 'http://www.skosmos.skos/test/ta1',754 'tops' => array('http://www.skosmos.skos/test/conceptscheme'),755 'prefLabel' => 'Fish',756 );757 $narrowers = array (758 0 => array (759 'uri' => 'http://www.skosmos.skos/test/ta112',760 'label' => 'Carp',761 'hasChildren' => true,762 'notation' => '665'763 ),764 1 => array (765 'uri' => 'http://www.skosmos.skos/test/ta117',766 'label' => '3D Bass',767 'hasChildren' => false,768 ),769 2 => array (770 'uri' => 'http://www.skosmos.skos/test/ta119',771 'label' => 'Hauki (fi)',772 'hasChildren' => false,773 ),774 3 => array (775 'uri' => 'http://www.skosmos.skos/test/ta115',776 'label' => 'Eel',777 'hasChildren' => false,778 ),779 4 => array (780 'uri' => 'http://www.skosmos.skos/test/ta120',781 'label' => NULL,782 'hasChildren' => false,783 ),784 5 => array (785 'uri' => 'http://www.skosmos.skos/test/ta111',786 'label' => 'Tuna',787 'hasChildren' => false,788 ),789 6 => array (790 'uri' => 'http://www.skosmos.skos/test/ta116',791 'label' => 'Bass',792 'hasChildren' => false,793 ),794 7 => array (795 'uri' => 'http://www.skosmos.skos/test/ta113',796 'label' => NULL,797 'hasChildren' => false,798 ),799 8 => array (800 'uri' => 'http://www.skosmos.skos/test/ta114',801 'label' => 'Buri',802 'hasChildren' => false,803 ),804 );805 foreach ($narrowers as $narrower) {806 $this->assertContains($narrower, $actual['http://www.skosmos.skos/test/ta1']['narrower']);807 }808 foreach ($expected as $concept) {809 $this->assertContains($concept, $actual);810 }811 foreach ($props as $property) {812 $this->assertContains($property, $actual['http://www.skosmos.skos/test/ta1']);813 }814 }815 /**816 * @covers GenericSparql::listConceptGroups817 * @covers GenericSparql::generateConceptGroupsQuery818 * @covers GenericSparql::transformConceptGroupsResults819 */820 public function testListConceptGroups()821 {822 $voc = $this->model->getVocabulary('groups');823 $graph = $voc->getGraph();824 $sparql = new GenericSparql('http://localhost:3030/ds/sparql', $graph, $this->model);825 $actual = $sparql->ListConceptGroups('http://www.w3.org/2004/02/skos/core#Collection', 'en', false);826 $expected = array (0 => array ('prefLabel' => 'Fish', 'uri' => 'http://www.skosmos.skos/groups/fish', 'hasMembers' => true, 'childGroups' => array('http://www.skosmos.skos/groups/sub')), 1 => array ('prefLabel' => 'Freshwater fish', 'uri' => 'http://www.skosmos.skos/groups/fresh', 'hasMembers' => true), 2 => array ('prefLabel' => 'Saltwater fish', 'uri' => 'http://www.skosmos.skos/groups/salt', 'hasMembers' => true),3 => array ('prefLabel' => 'Submarine-like fish', 'uri' => 'http://www.skosmos.skos/groups/sub', 'hasMembers' => true));827 $this->assertEquals($expected, $actual);828 }829 /**830 * @covers GenericSparql::listConceptGroupContents831 * @covers GenericSparql::generateConceptGroupContentsQuery832 * @covers GenericSparql::transformConceptGroupContentsResults833 */834 public function testListConceptGroupContentsExcludingDeprecatedConcept()835 {836 $voc = $this->model->getVocabulary('groups');837 $graph = $voc->getGraph();838 $sparql = new GenericSparql('http://localhost:3030/ds/sparql', $graph, $this->model);839 $actual = $sparql->ListConceptGroupContents('http://www.w3.org/2004/02/skos/core#Collection', 'http://www.skosmos.skos/groups/salt', 'en');840 $this->assertEquals('http://www.skosmos.skos/groups/ta113', $actual[0]['uri']);841 $this->assertEquals(1, sizeof($actual));842 }843 /**844 * @covers GenericSparql::listConceptGroupContents845 * @covers GenericSparql::generateConceptGroupContentsQuery846 * @covers GenericSparql::transformConceptGroupContentsResults847 */848 public function testListConceptGroupContentsIncludingDeprecatedConcept()849 {850 $voc = $this->model->getVocabulary('showDeprecated');851 $graph = $voc->getGraph();852 $sparql = new GenericSparql('http://localhost:3030/ds/sparql', $graph, $this->model);853 $actual = $sparql->ListConceptGroupContents('http://www.w3.org/2004/02/skos/core#Collection', 'http://www.skosmos.skos/groups/salt', 'en', $voc->getConfig()->getShowDeprecated());854 $expected = array (855 0 => array (856 'uri' => 'http://www.skosmos.skos/groups/ta113',857 'isSuper' => false,858 'hasMembers' => false,859 'type' => array('skos:Concept'),860 'prefLabel' => 'Flatfish'861 ),862 1 => array (863 'uri' => 'http://www.skosmos.skos/groups/ta111',864 'isSuper' => false,865 'hasMembers' => false,866 'type' => array('skos:Concept'),867 'prefLabel' => 'Tuna'868 )869 );870 $this->assertEquals($expected, $actual);871 $this->assertEquals(2, sizeof($actual));872 }873 /**874 * @covers GenericSparql::queryChangeList875 * @covers GenericSparql::generateChangeListQuery876 * @covers GenericSparql::transFormChangeListResults877 */878 public function testQueryChangeList()879 {880 $voc = $this->model->getVocabulary('changes');881 $graph = $voc->getGraph();882 $sparql = new GenericSparql('http://localhost:3030/ds/sparql', $graph, $this->model);883 $actual = $sparql->queryChangeList('en', 0, 'dc11:created');884 $order = array();885 foreach($actual as $concept) {886 array_push($order, $concept['prefLabel']);887 }888 $this->assertEquals(4, sizeof($actual));889 $this->assertEquals(array('Fourth date', 'Hurr Durr', 'Second date', 'A date'), $order);890 }891 /**892 * @covers GenericSparql::formatTypes893 * @covers GenericSparql::queryConcepts894 */895 public function testLimitSearchToType()896 {897 $voc = $this->model->getVocabulary('test');898 $graph = $voc->getGraph();899 $sparql = new GenericSparql('http://localhost:3030/ds/sparql', $graph, $this->model);900 $this->params->method('getSearchTerm')->will($this->returnValue('*'));901 $this->params->method('getTypeLimit')->will($this->returnValue(array('mads:Topic')));902 $actual = $this->sparql->queryConcepts(array($voc), null, true, $this->params);903 $this->assertEquals(1, sizeof($actual));904 }905 /**906 * @covers GenericSparql::queryConcepts907 * @covers GenericSparql::generateConceptSearchQueryCondition908 * @covers GenericSparql::generateConceptSearchQueryInner909 * @covers GenericSparql::generateConceptSearchQuery910 * @covers GenericSparql::formatFilterGraph911 * @covers GenericSparql::transformConceptSearchResults912 * @covers GenericSparql::transformConceptSearchResult913 * @covers GenericSparql::shortenUri914 * @covers GenericSparql::formatExtraFields915 * @covers GenericSparql::formatPropertyCsvClause916 * @covers GenericSparql::formatPrefLabelCsvClause917 */918 public function testQueryConceptsWithExtraFields()919 {920 $voc = $this->model->getVocabulary('test');921 $this->params->method('getSearchTerm')->will($this->returnValue('bass*'));922 $this->params->method('getVocabIds')->will($this->returnValue(array('test')));923 $actual = $this->sparql->queryConcepts(array($voc), array('broader', 'prefLabel'), null, $this->params);924 $this->assertEquals(1, sizeof($actual));925 $expected = array('uri' => 'http://www.skosmos.skos/test/ta116', 'type' => array (0 => 'skos:Concept',926 1 => 'meta:TestClass',927 ),928);929 $this->assertEquals(array('en' => 'Bass'), $actual[0]['prefLabels']);930 $this->assertEquals(array(0 => array('uri' => 'http://www.skosmos.skos/test/ta1')), $actual[0]['skos:broader']);931 }932 /**933 * @covers GenericSparql::querySuperProperties934 */935 public function testQuerySuperProperties()936 {937 $this->sparql = new GenericSparql('http://localhost:3030/ds/sparql', '?graph', $this->model);938 $actual = $this->sparql->querySuperProperties('http://example.com/myns#property');939 $this->assertEquals(1, sizeof($actual));940 $expected = array('http://example.com/myns#superProperty');941 $this->assertEquals($actual, $expected);942 }943}...

Full Screen

Full Screen

GenericAttributeServiceImpl.java

Source:GenericAttributeServiceImpl.java Github

copy

Full Screen

...18@Service19public class GenericAttributeServiceImpl implements GenericAttributeService {20 private final RedisService redisService;21 private final RedisKeyService redisKeyService;22 private final GenericAttributeMapper genericAttributeMapper;23 public GenericAttributeServiceImpl(RedisService redisService,24 RedisKeyService redisKeyService,25 GenericAttributeMapper genericAttributeMapper){26 this.redisKeyService = redisKeyService;27 this.redisService = redisService;28 this.genericAttributeMapper = genericAttributeMapper;29 }30 @Override31 public List<GenericAttribute> listAttributeMap(String keyGroup, Long entityId) {32 throw new IllegalStateException("not supported");33 }34 @Override35 public GenericAttribute getAttribute(String keyGroup, Long entityId, String key) {36 throw new IllegalStateException("not supported");37 }38 @Override39 public GenericAttribute addOrUpdateAttribute(AddOrUpdateAttributeAO addOrUpdateAttributeAO) {40 GenericAttributeQuery genericAttributeQuery = GenericAttributeQuery.builder()41 .key(addOrUpdateAttributeAO.getKey())42 .keyGroup(addOrUpdateAttributeAO.getKeyGroup())43 .entityId(addOrUpdateAttributeAO.getEntityId())44 .suggestionType(addOrUpdateAttributeAO.getSuggestionType())45 .build();46 GenericAttribute genericAttribute = getBy(genericAttributeQuery);47 if (genericAttribute == null){48 genericAttribute = BeanUtil.prepare(addOrUpdateAttributeAO, GenericAttribute.class);49 }50 genericAttribute.setValue(addOrUpdateAttributeAO.getValue());51 genericAttribute.setSuggestionType(addOrUpdateAttributeAO.getSuggestionType());52 addOrUpdate(genericAttribute);53 return genericAttribute;54 }55 @Override56 public GenericAttribute addOrUpdateDraftAttribute(String keyGroup, Long entityId, String key, String value) {57 return addOrUpdateAttribute(AddOrUpdateAttributeAO.builder().key(key).keyGroup(keyGroup).value(value).entityId(entityId).suggestionType(SuggestionTypeEnum.REVIEW.getValue()).build());58 }59 @Override60 public void deleteDraftAttribute(String keyGroup, Long entityId, String key) {61 final GenericAttribute genericAttribute = getBy(GenericAttributeQuery.builder().keyGroup(keyGroup).key(key).entityId(entityId).suggestionType(SuggestionTypeEnum.REVIEW.getValue()).build());62 if (genericAttribute != null){63 genericAttributeMapper.deleteById(genericAttribute.getId());64 }65 }66 @Override67 public List<GenericAttribute> listAttributeMap(String keyGroup, List<Long> entityIdList) {68 return genericAttributeMapper.selectList(buildQuery(GenericAttributeQuery.builder().keyGroup(keyGroup).entityIdList(entityIdList).build()));69 }70 public void addOrUpdate(GenericAttribute genericAttribute){71 if (genericAttribute.getId() != null){72 genericAttributeMapper.updateById(genericAttribute);73 return;74 }75 genericAttributeMapper.insert(genericAttribute);76 }77 private Map<Long, Map<String, String>> prepare(List<GenericAttribute> source){78 if (source.isEmpty()){79 return new HashMap<>();80 }81 Map<Long, Map<String, String>> result = new HashMap<>();82 source.stream().forEach(item -> {83 if (!result.containsKey(item.getEntityId())){84 result.put(item.getEntityId(), new HashMap<>());85 }86 result.get(item.getEntityId()).put(item.getKey(), item.getValue());87 });88 return result;89 }90 private void save(String keyGroup, Long entityId, String key, String value){91 GenericAttribute genericAttribute = getBy(keyGroup, entityId, key);92 if (genericAttribute == null){93 genericAttribute = GenericAttribute.builder().entityId(entityId).key(key).keyGroup(keyGroup).value(value).build();94 }95 genericAttribute.setValue(value);96 if (genericAttribute.getId() > 0){97 genericAttributeMapper.updateById(genericAttribute);98 }99 else{100 genericAttributeMapper.insert(genericAttribute);101 }102 }103 private GenericAttribute getBy(String keyGroup, Long entityId, String key){104 return genericAttributeMapper.selectOne(buildQuery(GenericAttributeQuery.builder().keyGroup(keyGroup).entityId(entityId).key(key).build()));105 }106 private GenericAttribute getBy(GenericAttributeQuery genericAttributeQuery){107 return genericAttributeMapper.selectOne(buildQuery(genericAttributeQuery));108 }109 private LambdaQueryWrapper<GenericAttribute> buildQuery(GenericAttributeQuery genericAttributeQuery){110 LambdaQueryWrapper<GenericAttribute> result = new LambdaQueryWrapper<>();111 if (!StringUtils.isEmpty(genericAttributeQuery.getKeyGroup())){112 result.eq(GenericAttribute::getKeyGroup, genericAttributeQuery.getKeyGroup());113 }114 if (genericAttributeQuery.getEntityId() != null){115 result.eq(GenericAttribute::getEntityId, genericAttributeQuery.getEntityId());116 }117 if (!CollectionUtils.isEmpty(genericAttributeQuery.getEntityIdList())){118 result.in(GenericAttribute::getEntityId, genericAttributeQuery.getEntityIdList());119 }120 if (!StringUtils.isEmpty(genericAttributeQuery.getKey())){121 result.eq(GenericAttribute::getKey, genericAttributeQuery.getKey());122 }123 return result;124 }125}...

Full Screen

Full Screen

Genericname_management.php

Source:Genericname_management.php Github

copy

Full Screen

...8 var $table;9 var $session;10 function __construct() {11 session()->set("link_id", "index");12 session()->set("linkSub", "genericname_management");13 session()->set("linkTitle", "Generic Name Management");14 $this->db = \Config\Database::connect();15 $this->table = new \CodeIgniter\View\Table();16 $this->session = \Config\Services::session();17 }18 public function index() {19 $this->listing();20 }21 public function listing() {22 $access_level = session()->get('user_indicator');23 $data = array();24 $generics = Generic_Name::getAllHydrated($access_level);25 $tmpl = array('table_open' => '<table class="setting_table table table-bordered table-striped">');26 $this->table->setTemplate($tmpl);27 $this->table->setHeading('Id', 'Name', 'Options');28 foreach ($generics as $generic) {29 $links = "";30 $array_param = array(31 'id' => $generic['id'],32 'role' => 'button',33 'class' => 'edit_user',34 'data-toggle' => 'modal',35 'name' => $generic['name']36 );37 if ($generic['active'] == 1) {38 //$links = anchor('genericname_management/edit/' . $generic['id'], 'Edit', array('class' => 'edit_user','id'=>$generic['id'],'name'=>$generic['Name']));39 $links .= anchor('#edit_form', 'Edit', $array_param);40 }41 //Check if user is an admin42 if ($access_level == "facility_administrator") {43 if ($generic['active'] == 1) {44 $links .= " | ";45 $links .= anchor(base_url() . '/genericname_management/disable/' . $generic['id'], 'Disable', array('class' => 'disable_user'));46 } else {47 $links .= anchor(base_url() . '/genericname_management/enable/' . $generic['id'], 'Enable', array('class' => 'enable_user'));48 }49 }50 $this->table->addRow($generic['id'], $generic['name'], $links);51 }52 $data['generic_names'] = $this->table->generate();53 $this->base_params($data);54 }55 public function save() {56 //call validation function57 //$valid = $this->_submit_validate();58 $valid = true;59 if ($valid == false) {60 $data['settings_view'] = "generic_listing_v";61 $this->base_params($data);62 } else {63 $drugname = $this->request->getPost("generic_name");64 $source = new Generic_name();65 $source->Name = $drugname;66 $source->Active = "1";67 $source->save();68 //$this->db->replace('generic_name', array('name' => $drugname));69 $this->session->set('msg_success', $this->request->getPost('generic_name') . ' was Added');70 $this->session->setFlashdata('filter_datatable', $this->request->getPost('generic_name')); //Filter datatable71 return redirect()->to(base_url() . '/settings_management');72 }73 }74 public function edit($generic_id) {75 $data['title'] = "Edit Generic Name";76 $data['settings_view'] = "editgeneric_v";77 $data['banner_text'] = "Edit Generic Name";78 $data['link'] = "generic";79 $data['generics'] = Generic_Name::getGeneric($generic_id);80 $this->base_params($data);81 }82 public function update() {83 $generic_id = $this->request->getPost('generic_id');84 $generic_name = $this->request->getPost('edit_generic_name');85 $query = $this->db->query("UPDATE generic_name SET Name='$generic_name' WHERE id='$generic_id'");86 $this->session->set('msg_success', $this->request->getPost('edit_generic_name') . ' was Updated');87 $this->session->setFlashdata('filter_datatable', $this->request->getPost('edit_generic_name')); //Filter datatable88 return redirect()->to(base_url() . '/settings_management');89 }90 public function enable($generic_id) {91 $query = $this->db->query("UPDATE generic_name SET Active='1'WHERE id='$generic_id'");92 $results = Generic_Name::getGeneric($generic_id);93 $this->session->set('msg_success', $results->name . ' was enabled');94 $this->session->setFlashdata('filter_datatable', $results->name); //Filter datatable95 return redirect()->to(base_url() . '/settings_management');96 }97 public function disable($generic_id) {98 $query = $this->db->query("UPDATE generic_name SET Active='0'WHERE id='$generic_id'");99 $results = Generic_Name::getGeneric($generic_id);100 $this->session->set('msg_error', $results->name . ' was disabled');101 $this->session->setFlashdata('filter_datatable', $results->name); //Filter datatable102 return redirect()->to(base_url() . '/settings_management');103 }104 private function _submit_validate() {105 // validation rules106 $this->form_validation->set_rules('generic_name', 'Generic Name', 'trim|required|min_length[2]|max_length[100]');107 return $this->form_validation->run();108 }109 public function base_params($data) {110 $data['styles'] = array("jquery-ui.css");111 $data['scripts'] = array("jquery-ui.js");112 $data['quick_link'] = "generic";113 $data['title'] = "Generic Names";114 $data['banner_text'] = "Generic Management";115 $data['link'] = "settings_management";116 echo view('\Modules\ADT\Views\\generic_listing_v', $data);117 }118}...

Full Screen

Full Screen

GenericParameterMatchingTests.java

Source:GenericParameterMatchingTests.java Github

copy

Full Screen

...12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.13 * See the License for the specific language governing permissions and14 * limitations under the License.15 */16package org.springframework.aop.aspectj.generic;17import java.util.Collection;18import org.aspectj.lang.annotation.Aspect;19import org.aspectj.lang.annotation.Before;20import org.aspectj.lang.annotation.Pointcut;21import org.junit.Test;22import org.springframework.context.support.ClassPathXmlApplicationContext;23import static org.junit.Assert.*;24/**25 * Tests that poitncut matching is correct with generic method parameter.26 * See SPR-3904 for more details.27 *28 * @author Ramnivas Laddad29 * @author Chris Beams30 */31public class GenericParameterMatchingTests {32 private CounterAspect counterAspect;33 private GenericInterface<String> testBean;34 @SuppressWarnings("unchecked")35 @org.junit.Before36 public void setup() {37 ClassPathXmlApplicationContext ctx =38 new ClassPathXmlApplicationContext(getClass().getSimpleName() + "-context.xml", getClass());39 counterAspect = (CounterAspect) ctx.getBean("counterAspect");40 counterAspect.reset();41 testBean = (GenericInterface<String>) ctx.getBean("testBean");42 }43 @Test44 public void testGenericInterfaceGenericArgExecution() {45 testBean.save("");46 assertEquals(1, counterAspect.genericInterfaceGenericArgExecutionCount);47 }48 @Test49 public void testGenericInterfaceGenericCollectionArgExecution() {50 testBean.saveAll(null);51 assertEquals(1, counterAspect.genericInterfaceGenericCollectionArgExecutionCount);52 }53 @Test54 public void testGenericInterfaceSubtypeGenericCollectionArgExecution() {55 testBean.saveAll(null);56 assertEquals(1, counterAspect.genericInterfaceSubtypeGenericCollectionArgExecutionCount);57 }58 static interface GenericInterface<T> {59 public void save(T bean);60 public void saveAll(Collection<T> beans);61 }62 static class GenericImpl<T> implements GenericInterface<T> {63 @Override64 public void save(T bean) {65 }66 @Override67 public void saveAll(Collection<T> beans) {68 }69 }70 @Aspect71 static class CounterAspect {72 int genericInterfaceGenericArgExecutionCount;73 int genericInterfaceGenericCollectionArgExecutionCount;74 int genericInterfaceSubtypeGenericCollectionArgExecutionCount;75 public void reset() {76 genericInterfaceGenericArgExecutionCount = 0;77 genericInterfaceGenericCollectionArgExecutionCount = 0;78 genericInterfaceSubtypeGenericCollectionArgExecutionCount = 0;79 }80 @Pointcut("execution(* org.springframework.aop.aspectj.generic.GenericParameterMatchingTests.GenericInterface.save(..))")81 public void genericInterfaceGenericArgExecution() {}82 @Pointcut("execution(* org.springframework.aop.aspectj.generic.GenericParameterMatchingTests.GenericInterface.saveAll(..))")83 public void GenericInterfaceGenericCollectionArgExecution() {}84 @Pointcut("execution(* org.springframework.aop.aspectj.generic.GenericParameterMatchingTests.GenericInterface+.saveAll(..))")85 public void genericInterfaceSubtypeGenericCollectionArgExecution() {}86 @Before("genericInterfaceGenericArgExecution()")87 public void incrementGenericInterfaceGenericArgExecution() {88 genericInterfaceGenericArgExecutionCount++;89 }90 @Before("GenericInterfaceGenericCollectionArgExecution()")91 public void incrementGenericInterfaceGenericCollectionArgExecution() {92 genericInterfaceGenericCollectionArgExecutionCount++;93 }94 @Before("genericInterfaceSubtypeGenericCollectionArgExecution()")95 public void incrementGenericInterfaceSubtypeGenericCollectionArgExecution() {96 genericInterfaceSubtypeGenericCollectionArgExecutionCount++;97 }98 }99}...

Full Screen

Full Screen

GenericPaymentMethodMapperInterface.php

Source:GenericPaymentMethodMapperInterface.php Github

copy

Full Screen

...9use SprykerEco\Zed\Payone\Business\Api\Request\Container\GenericPaymentContainer;10interface GenericPaymentMethodMapperInterface11{12 /**13 * @param \SprykerEco\Zed\Payone\Business\Api\Request\Container\GenericPaymentContainer $genericPayment14 * @param \Generated\Shared\Transfer\PayoneInitPaypalExpressCheckoutRequestTransfer $requestTransfer15 *16 * @return \SprykerEco\Zed\Payone\Business\Api\Request\Container\GenericPaymentContainer17 */18 public function mapRequestTransferToGenericPayment(19 GenericPaymentContainer $genericPayment,20 PayoneInitPaypalExpressCheckoutRequestTransfer $requestTransfer21 ): GenericPaymentContainer;22 /**23 * @param \SprykerEco\Zed\Payone\Business\Api\Request\Container\GenericPaymentContainer $genericPayment24 * @param \Generated\Shared\Transfer\QuoteTransfer $quoteTransfer25 *26 * @return \SprykerEco\Zed\Payone\Business\Api\Request\Container\GenericPaymentContainer27 */28 public function mapQuoteTransferToGenericPayment(29 GenericPaymentContainer $genericPayment,30 QuoteTransfer $quoteTransfer31 ): GenericPaymentContainer;32 /**33 * @return \SprykerEco\Zed\Payone\Business\Api\Request\Container\GenericPaymentContainer34 */35 public function createBaseGenericPaymentContainer(): GenericPaymentContainer;36}

Full Screen

Full Screen

generic

Using AI Code Generation

copy

Full Screen

1use mageekguy\atoum;2use mageekguy\atoum\test;3use mageekguy\atoum\asserter;4use mageekguy\atoum\asserters;5use mageekguy\atoum\exceptions;6use mageekguy\atoum\test;7use mageekguy\atoum\asserter;8use mageekguy\atoum\asserters;9use mageekguy\atoum\exceptions;10{11 public function testMyClass()12 {13 ->if($myClass = new MyClass())14 ->and($myClass->setFoo('bar'))15 ->string($myClass->getFoo())->isEqualTo('bar')16 ;17 }18}19use mageekguy\atoum;20use mageekguy\atoum\test;21use mageekguy\atoum\asserter;22use mageekguy\atoum\asserters;23use mageekguy\atoum\exceptions;24{25 public function testMyClass()26 {27 ->if($myClass = new MyClass())28 ->and($myClass->setFoo('bar'))29 ->string($myClass->getFoo())->isEqualTo('bar')30 ;31 }32}33use mageekguy\atoum;34use mageekguy\atoum\test;35use mageekguy\atoum\asserter;36use mageekguy\atoum\asserters;37use mageekguy\atoum\exceptions;38{39 public function testMyClass()40 {41 ->if($myClass = new MyClass())42 ->and($myClass->setFoo('bar'))43 ->string($myClass->getFoo())->isEqualTo('

Full Screen

Full Screen

generic

Using AI Code Generation

copy

Full Screen

1require_once 'vendor/autoload.php';2use \mageekguy\atoum\scripts\runner;3$runner = new runner();4$runner->addTestsFromDirectory(__DIR__ . '/tests/units');5$runner->run();6namespace tests\units;7use atoum;8{9 public function testMyMethod()10 {11 $this->variable("Hello World")->isIdenticalTo("Hello World");12 }13}

Full Screen

Full Screen

generic

Using AI Code Generation

copy

Full Screen

1use mageekguy\atoum\test;2{3 public function testAddition()4 {5 ->integer(1+1)6 ->isEqualTo(2)7 ;8 }9}10use mageekguy\atoum\test;11{12 public function testAddition()13 {14 ->integer(1+1)15 ->isEqualTo(2)16 ;17 }18}19use mageekguy\atoum\test;20{21 public function testAddition()22 {23 ->integer(1+1)24 ->isEqualTo(2)25 ;26 }27}28use mageekguy\atoum\test;29{30 public function testAddition()31 {32 ->integer(1+1)33 ->isEqualTo(2)34 ;35 }36}37use mageekguy\atoum\test;38{39 public function testAddition()40 {41 ->integer(1+1)42 ->isEqualTo(2)43 ;44 }45}46use mageekguy\atoum\test;47{48 public function testAddition()49 {50 ->integer(1+1)51 ->isEqualTo(2)52 ;53 }54}55use mageekguy\atoum\test;56{57 public function testAddition()58 {59 ->integer(1+1)60 ->isEqualTo(2)61 ;62 }63}64use mageekguy\atoum\test;

Full Screen

Full Screen

generic

Using AI Code Generation

copy

Full Screen

1use \mageekguy\atoum;2{3 public function testSomething()4 {5 ->integer(1)6 ->isGreaterThan(0)7 ;8 }9}10use \mageekguy\atoum;11{12 public function testSomething()13 {14 ->integer(1)15 ->isLessThan(2)16 ;17 }18}

Full Screen

Full Screen

generic

Using AI Code Generation

copy

Full Screen

1use mageekguy\atoum;2{3 public function test1()4 {5 $this->assert->boolean(true);6 }7}8use mageekguy\atoum;9{10 public function test1()11 {12 $this->assert->boolean(true);13 }14}15use mageekguy\atoum;16{17 public function test1()18 {19 $this->assert->boolean(true);20 }21}22use mageekguy\atoum;23{24 public function test1()25 {26 $this->assert->boolean(true);27 }28}29use mageekguy\atoum;30{31 public function test1()32 {33 $this->assert->boolean(true);34 }35}36use mageekguy\atoum;37{38 public function test1()39 {40 $this->assert->boolean(true);41 }42}43use mageekguy\atoum;44{45 public function test1()46 {47 $this->assert->boolean(true);48 }49}50use mageekguy\atoum;51{52 public function test1()53 {54 $this->assert->boolean(true);55 }56}57use mageekguy\atoum;58{59 public function test1()60 {

Full Screen

Full Screen

generic

Using AI Code Generation

copy

Full Screen

1use Atoum\Atoum;2use Atoum\Atoum\Specific;3$atoum = new Atoum();4$atoum->run();5use Atoum\Atoum;6use Atoum\Atoum\Specific;7$atoum = new Specific();8$atoum->run();9use Atoum\Atoum;10use Atoum\Atoum\Specific;11$atoum = new Atoum();12$atoum->run();13use Atoum\Atoum;14use Atoum\Atoum\Specific;15$atoum = new Atoum\Atoum\Specific();16$atoum->run();

Full Screen

Full Screen

generic

Using AI Code Generation

copy

Full Screen

1require_once __DIR__ . '/vendor/autoload.php';2use mageekguy\atoum;3{4}5require_once __DIR__ . '/vendor/autoload.php';6use mageekguy\atoum;7{8}9> #0 /home/alexandre/PhpstormProjects/AtoumTest/vendor/atoum/atoum/classes/autoloader.php(42): include()10> #1 [internal function]: atoum\autoloader->load('mageekguy\\atoum...')11> #2 /home/alexandre/PhpstormProjects/AtoumTest/vendor/atoum/atoum/classes/autoloader.php(42): spl_autoload_call('mageekguy\\atoum...')12> #3 [internal function]: atoum\autoloader->load('mageekguy\\atoum...')13> #4 /home/alexandre/PhpstormProjects/AtoumTest/vendor/atoum/atoum/classes/autoloader.php(42): spl_autoload_call('mageekguy\\atoum...')14> #5 [internal function]: atoum\autoloader->load('mageekguy\\atoum...')15> #6 /home/alexandre/PhpstormProjects/AtoumTest/vendor/atoum/atoum/classes/autoloader.php(42): spl_autoload_call('mageekguy\\atoum...')16> #7 [internal function]: atoum\autoloader->load('mageekguy\\atoum...')17> #8 /home/alexandre/PhpstormProjects/AtoumTest/vendor/atoum/atoum/classes/autoloader.php(42): spl

Full Screen

Full Screen

generic

Using AI Code Generation

copy

Full Screen

1$test->assert->class('genericClass')2->hasInterface('genericInterface')3->hasMethod('genericMethod')4->hasConstant('genericConstant')5->hasAttribute('genericAttribute')6->hasParentClass('genericParentClass')7->hasTrait('genericTrait')8->hasTrait('genericTrait2')9->hasTrait('genericTrait3')10->hasTrait('genericTrait4')11->hasTrait('genericTrait5')12->hasTrait('genericTrait6')13->hasTrait('genericTrait7')14->hasTrait('genericTrait8')15->hasTrait('genericTrait9')16->hasTrait('genericTrait10')17->hasTrait('genericTrait11')18->hasTrait('genericTrait12')19->hasTrait('genericTrait13')20->hasTrait('genericTrait14')21->hasTrait('genericTrait15')22->hasTrait('genericTrait16')23->hasTrait('genericTrait17')24->hasTrait('genericTrait18')25->hasTrait('genericTrait19')26->hasTrait('genericTrait20')27->hasTrait('genericTrait21')28->hasTrait('genericTrait22')29->hasTrait('genericTrait23')30->hasTrait('genericTrait24')31->hasTrait('genericTrait25')32->hasTrait('genericTrait26')33->hasTrait('genericTrait27')34->hasTrait('genericTrait28')35->hasTrait('genericTrait29')36->hasTrait('genericTrait30')37->hasTrait('genericTrait31')38->hasTrait('genericTrait32')39->hasTrait('genericTrait33')40->hasTrait('genericTrait34')41->hasTrait('genericTrait35')42->hasTrait('genericTrait36')43->hasTrait('genericTrait37')44->hasTrait('genericTrait38')45->hasTrait('genericTrait39')46->hasTrait('genericTrait40')47->hasTrait('genericTrait41')48->hasTrait('genericTrait42')49->hasTrait('genericTrait43')50->hasTrait('genericTrait44')51->hasTrait('genericTrait45')52->hasTrait('genericTrait46')53->hasTrait('genericTrait47')54->hasTrait('genericTrait48')55->hasTrait('genericTrait49')56->hasTrait('genericTrait50')57->hasTrait('genericTrait51')58->hasTrait('genericTrait52')59->hasTrait('genericTrait53')60->hasTrait('genericTrait54')61->hasTrait('genericTrait55')62->hasTrait('genericTrait56')63->hasTrait('

Full Screen

Full Screen

generic

Using AI Code Generation

copy

Full Screen

1include 'genericClass.php';2$genericClass = new genericClass();3$genericClass->testMethod();4include 'genericClass.php';5$genericClass = new genericClass();6$genericClass->testMethod();7{8 public function testMethod()9 {10 return 'hello world';11 }12}13include 'genericClass.php';14$genericClass = new genericClass();15$genericClass->testMethod();16include 'genericClass.php';17$genericClass = new genericClass();18$genericClass->testMethod();19{20 public function testMethod()21 {22 return 'hello world';23 }24}25include 'genericClass.php';26$genericClass = new genericClass();27$genericClass->testMethod();28include 'genericClass.php';29$genericClass = new genericClass();30$genericClass->testMethod();

Full Screen

Full Screen

Automation Testing Tutorials

Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Run Atoum automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Run Selenium Automation Tests on LambdaTest Cloud Grid

Trigger Selenium automation tests on a cloud-based Grid of 3000+ real browsers and operating systems.

Test now for Free

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful