How to use match method of de.codecentric.hikaku.Hikaku class

Best Hikaku code snippet using de.codecentric.hikaku.Hikaku.match

HikakuTest.kt

Source:HikakuTest.kt Github

copy

Full Screen

...38 )39 )40 //when41 assertFailsWith<AssertionError> {42 hikaku.match()43 }44 }45 @Test46 fun `paths in random order match`() {47 //given48 val specificationDummyConverter = object : EndpointConverter {49 override val conversionResult: Set<Endpoint> = setOf(50 Endpoint("/c", GET),51 Endpoint("/a", GET),52 Endpoint("/b", GET)53 )54 override val supportedFeatures = SupportedFeatures()55 }56 val implementationDummyConverter = object : EndpointConverter {57 override val conversionResult: Set<Endpoint> = setOf(58 Endpoint("/b", GET),59 Endpoint("/c", GET),60 Endpoint("/a", GET)61 )62 override val supportedFeatures = SupportedFeatures(Feature.PathParameters)63 }64 val hikaku = Hikaku(65 specificationDummyConverter,66 implementationDummyConverter,67 HikakuConfig(68 reporters = listOf(NoOperationReporter())69 )70 )71 //when72 hikaku.match()73 }74 @Test75 fun `same number of Endpoints, but paths don't match`() {76 //given77 val specificationDummyConverter = object : EndpointConverter {78 override val conversionResult: Set<Endpoint> = setOf(79 Endpoint("/c", GET),80 Endpoint("/a", GET),81 Endpoint("/b", GET)82 )83 override val supportedFeatures = SupportedFeatures()84 }85 val implementationDummyConverter = object : EndpointConverter {86 override val conversionResult: Set<Endpoint> = setOf(87 Endpoint("/y", GET),88 Endpoint("/z", GET),89 Endpoint("/a", GET)90 )91 override val supportedFeatures = SupportedFeatures()92 }93 val hikaku = Hikaku(94 specificationDummyConverter,95 implementationDummyConverter,96 HikakuConfig(97 reporters = listOf(NoOperationReporter())98 )99 )100 //when101 assertFailsWith<AssertionFailedError> {102 hikaku.match()103 }104 }105 @Test106 fun `http methods in random order match`() {107 //given108 val specificationDummyConverter = object : EndpointConverter {109 override val conversionResult: Set<Endpoint> = setOf(110 Endpoint("/todos", POST),111 Endpoint("/todos", DELETE),112 Endpoint("/todos", GET)113 )114 override val supportedFeatures = SupportedFeatures()115 }116 val implementationDummyConverter = object : EndpointConverter {117 override val conversionResult: Set<Endpoint> = setOf(118 Endpoint("/todos", GET),119 Endpoint("/todos", POST),120 Endpoint("/todos", DELETE)121 )122 override val supportedFeatures = SupportedFeatures(Feature.PathParameters)123 }124 val hikaku = Hikaku(125 specificationDummyConverter,126 implementationDummyConverter,127 HikakuConfig(128 reporters = listOf(NoOperationReporter())129 )130 )131 //when132 hikaku.match()133 }134 @Test135 fun `same number of Endpoints, but http methods don't match`() {136 //given137 val specificationDummyConverter = object : EndpointConverter {138 override val conversionResult: Set<Endpoint> = setOf(139 Endpoint("/todos", PUT),140 Endpoint("/todos", DELETE),141 Endpoint("/todos", GET)142 )143 override val supportedFeatures = SupportedFeatures()144 }145 val implementationDummyConverter = object : EndpointConverter {146 override val conversionResult: Set<Endpoint> = setOf(147 Endpoint("/todos", GET),148 Endpoint("/todos", POST),149 Endpoint("/todos", HEAD)150 )151 override val supportedFeatures = SupportedFeatures()152 }153 val hikaku = Hikaku(154 specificationDummyConverter,155 implementationDummyConverter,156 HikakuConfig(157 reporters = listOf(NoOperationReporter())158 )159 )160 //when161 assertFailsWith<AssertionFailedError> {162 hikaku.match()163 }164 }165 }166 @Nested167 inner class FeatureTests {168 @Nested169 inner class PathParameterTests {170 @Test171 fun `path parameter in random order match if the feature is supported by both converters`() {172 //given173 val specificationDummyConverter = object : EndpointConverter {174 override val conversionResult: Set<Endpoint> = setOf(175 Endpoint(176 path = "/todos/{organizationId}/{accountId}",177 httpMethod = GET,178 pathParameters = setOf(179 PathParameter("accountId"),180 PathParameter("organizationId")181 )182 )183 )184 override val supportedFeatures = SupportedFeatures(Feature.PathParameters)185 }186 val implementationDummyConverter = object : EndpointConverter {187 override val conversionResult: Set<Endpoint> = setOf(188 Endpoint(189 path = "/todos/{organizationId}/{accountId}",190 httpMethod = GET,191 pathParameters = setOf(192 PathParameter("organizationId"),193 PathParameter("accountId")194 )195 )196 )197 override val supportedFeatures = SupportedFeatures(Feature.PathParameters)198 }199 val hikaku = Hikaku(200 specificationDummyConverter,201 implementationDummyConverter,202 HikakuConfig(203 reporters = listOf(NoOperationReporter())204 )205 )206 //when207 hikaku.match()208 }209 @Test210 fun `path parameter are skipped if the feature is not supported by one of the converters`() {211 //given212 val specificationDummyConverter = object : EndpointConverter {213 override val conversionResult: Set<Endpoint> = setOf(214 Endpoint(215 path = "/todos/{id}",216 httpMethod = GET,217 pathParameters = setOf(218 PathParameter("id")219 )220 )221 )222 override val supportedFeatures = SupportedFeatures()223 }224 val implementationDummyConverter = object : EndpointConverter {225 override val conversionResult: Set<Endpoint> = setOf(226 Endpoint(227 path = "/todos/{id}",228 httpMethod = GET,229 pathParameters = setOf(230 PathParameter("othername")231 )232 )233 )234 override val supportedFeatures = SupportedFeatures(Feature.PathParameters)235 }236 val hikaku = Hikaku(237 specificationDummyConverter,238 implementationDummyConverter,239 HikakuConfig(240 reporters = listOf(NoOperationReporter())241 )242 )243 //when244 hikaku.match()245 }246 @Test247 fun `path parameter don't match`() {248 //given249 val specificationDummyConverter = object : EndpointConverter {250 override val conversionResult: Set<Endpoint> = setOf(251 Endpoint(252 path = "/todos/{accountId}",253 httpMethod = GET,254 pathParameters = setOf(255 PathParameter("accountId")256 )257 )258 )259 override val supportedFeatures = SupportedFeatures(Feature.PathParameters)260 }261 val implementationDummyConverter = object : EndpointConverter {262 override val conversionResult: Set<Endpoint> = setOf(263 Endpoint(264 path = "/todos/{id}",265 httpMethod = GET,266 pathParameters = setOf(267 PathParameter("id")268 )269 )270 )271 override val supportedFeatures = SupportedFeatures(Feature.PathParameters)272 }273 val hikaku = Hikaku(274 specificationDummyConverter,275 implementationDummyConverter,276 HikakuConfig(277 reporters = listOf(NoOperationReporter())278 )279 )280 //when281 assertFailsWith<AssertionFailedError> {282 hikaku.match()283 }284 }285 }286 @Nested287 inner class QueryParameterNameTests {288 @Test289 fun `query parameter names in random order match if the feature is supported by both converters`() {290 //given291 val specificationDummyConverter = object : EndpointConverter {292 override val conversionResult: Set<Endpoint> = setOf(293 Endpoint(294 path = "/todos",295 httpMethod = GET,296 queryParameters = setOf(297 QueryParameter("filter"),298 QueryParameter("tag"),299 QueryParameter("query")300 )301 )302 )303 override val supportedFeatures = SupportedFeatures(Feature.QueryParameters)304 }305 val implementationDummyConverter = object : EndpointConverter {306 override val conversionResult: Set<Endpoint> = setOf(307 Endpoint(308 path = "/todos",309 httpMethod = GET,310 queryParameters = setOf(311 QueryParameter("query"),312 QueryParameter("filter"),313 QueryParameter("tag")314 )315 )316 )317 override val supportedFeatures = SupportedFeatures(Feature.QueryParameters)318 }319 val hikaku = Hikaku(320 specificationDummyConverter,321 implementationDummyConverter,322 HikakuConfig(323 reporters = listOf(NoOperationReporter())324 )325 )326 //when327 hikaku.match()328 }329 @Test330 fun `query parameter names are skipped if the feature is not supported by one of the converters`() {331 //given332 val specificationDummyConverter = object : EndpointConverter {333 override val conversionResult: Set<Endpoint> = setOf(334 Endpoint(335 path = "/todos",336 httpMethod = GET,337 queryParameters = setOf(338 QueryParameter("filter")339 )340 )341 )342 override val supportedFeatures = SupportedFeatures()343 }344 val implementationDummyConverter = object : EndpointConverter {345 override val conversionResult: Set<Endpoint> = setOf(346 Endpoint(347 path = "/todos",348 httpMethod = GET,349 queryParameters = setOf(350 QueryParameter("tag")351 )352 )353 )354 override val supportedFeatures = SupportedFeatures(Feature.QueryParameters)355 }356 val hikaku = Hikaku(357 specificationDummyConverter,358 implementationDummyConverter,359 HikakuConfig(360 reporters = listOf(NoOperationReporter())361 )362 )363 //when364 hikaku.match()365 }366 @Test367 fun `query parameter names don't match`() {368 //given369 val specificationDummyConverter = object : EndpointConverter {370 override val conversionResult: Set<Endpoint> = setOf(371 Endpoint(372 path = "/todos",373 httpMethod = GET,374 queryParameters = setOf(375 QueryParameter("filter")376 )377 )378 )379 override val supportedFeatures = SupportedFeatures(Feature.QueryParameters)380 }381 val implementationDummyConverter = object : EndpointConverter {382 override val conversionResult: Set<Endpoint> = setOf(383 Endpoint(384 path = "/todos",385 httpMethod = GET,386 queryParameters = setOf(387 QueryParameter("tag")388 )389 )390 )391 override val supportedFeatures = SupportedFeatures(Feature.QueryParameters)392 }393 val hikaku = Hikaku(394 specificationDummyConverter,395 implementationDummyConverter,396 HikakuConfig(397 reporters = listOf(NoOperationReporter())398 )399 )400 //when401 assertFailsWith<AssertionFailedError> {402 hikaku.match()403 }404 }405 @Test406 fun `query parameter required matches if the feature is supported by both converters`() {407 //given408 val specificationDummyConverter = object : EndpointConverter {409 override val conversionResult: Set<Endpoint> = setOf(410 Endpoint(411 path = "/todos",412 httpMethod = GET,413 queryParameters = setOf(414 QueryParameter("filter", true)415 )416 )417 )418 override val supportedFeatures = SupportedFeatures(Feature.QueryParameters)419 }420 val implementationDummyConverter = object : EndpointConverter {421 override val conversionResult: Set<Endpoint> = setOf(422 Endpoint(423 path = "/todos",424 httpMethod = GET,425 queryParameters = setOf(426 QueryParameter("filter", true)427 )428 )429 )430 override val supportedFeatures = SupportedFeatures(Feature.QueryParameters)431 }432 val hikaku = Hikaku(433 specificationDummyConverter,434 implementationDummyConverter,435 HikakuConfig(436 reporters = listOf(NoOperationReporter())437 )438 )439 //when440 hikaku.match()441 }442 @Test443 fun `query parameter required is skipped if option is not supported by one of the converters`() {444 //given445 val specificationDummyConverter = object : EndpointConverter {446 override val conversionResult: Set<Endpoint> = setOf(447 Endpoint(448 path = "/todos",449 httpMethod = GET,450 queryParameters = setOf(451 QueryParameter("filter", true)452 )453 )454 )455 override val supportedFeatures = SupportedFeatures()456 }457 val implementationDummyConverter = object : EndpointConverter {458 override val conversionResult: Set<Endpoint> = setOf(459 Endpoint(460 path = "/todos",461 httpMethod = GET,462 queryParameters = setOf(463 QueryParameter("filter", false)464 )465 )466 )467 override val supportedFeatures = SupportedFeatures(Feature.QueryParameters)468 }469 val hikaku = Hikaku(470 specificationDummyConverter,471 implementationDummyConverter,472 HikakuConfig(473 reporters = listOf(NoOperationReporter())474 )475 )476 //when477 hikaku.match()478 }479 @Test480 fun `query parameter required don't match`() {481 //given482 val specificationDummyConverter = object : EndpointConverter {483 override val conversionResult: Set<Endpoint> = setOf(484 Endpoint(485 path = "/todos",486 httpMethod = GET,487 queryParameters = setOf(488 QueryParameter("filter", true)489 )490 )491 )492 override val supportedFeatures = SupportedFeatures(Feature.QueryParameters)493 }494 val implementationDummyConverter = object : EndpointConverter {495 override val conversionResult: Set<Endpoint> = setOf(496 Endpoint(497 path = "/todos",498 httpMethod = GET,499 queryParameters = setOf(500 QueryParameter("filter", false)501 )502 )503 )504 override val supportedFeatures = SupportedFeatures(Feature.QueryParameters)505 }506 val hikaku = Hikaku(507 specificationDummyConverter,508 implementationDummyConverter,509 HikakuConfig(510 reporters = listOf(NoOperationReporter())511 )512 )513 //when514 assertFailsWith<AssertionFailedError> {515 hikaku.match()516 }517 }518 }519 @Nested520 inner class HeaderParameterNameTests {521 @Test522 fun `header parameter names in random order match if the feature is supported by both converters`() {523 //given524 val specificationDummyConverter = object : EndpointConverter {525 override val conversionResult: Set<Endpoint> = setOf(526 Endpoint(527 path = "/todos",528 httpMethod = GET,529 headerParameters = setOf(530 HeaderParameter("x-b3-traceid"),531 HeaderParameter("allow-cache")532 )533 )534 )535 override val supportedFeatures = SupportedFeatures(Feature.HeaderParameters)536 }537 val implementationDummyConverter = object : EndpointConverter {538 override val conversionResult: Set<Endpoint> = setOf(539 Endpoint(540 path = "/todos",541 httpMethod = GET,542 headerParameters = setOf(543 HeaderParameter("allow-cache"),544 HeaderParameter("x-b3-traceid")545 )546 )547 )548 override val supportedFeatures = SupportedFeatures(Feature.HeaderParameters)549 }550 val hikaku = Hikaku(551 specificationDummyConverter,552 implementationDummyConverter,553 HikakuConfig(554 reporters = listOf(NoOperationReporter())555 )556 )557 //when558 hikaku.match()559 }560 @Test561 fun `header parameter names are skipped if the feature is not supported by one of the converters`() {562 //given563 val specificationDummyConverter = object : EndpointConverter {564 override val conversionResult: Set<Endpoint> = setOf(565 Endpoint(566 path = "/todos",567 httpMethod = GET,568 headerParameters = setOf(569 HeaderParameter("allow-cache")570 )571 )572 )573 override val supportedFeatures = SupportedFeatures()574 }575 val implementationDummyConverter = object : EndpointConverter {576 override val conversionResult: Set<Endpoint> = setOf(577 Endpoint(578 path = "/todos",579 httpMethod = GET,580 headerParameters = setOf(581 HeaderParameter("x-b3-traceid")582 )583 )584 )585 override val supportedFeatures = SupportedFeatures(Feature.HeaderParameters)586 }587 val hikaku = Hikaku(588 specificationDummyConverter,589 implementationDummyConverter,590 HikakuConfig(591 reporters = listOf(NoOperationReporter())592 )593 )594 //when595 hikaku.match()596 }597 @Test598 fun `header parameter names don't match`() {599 //given600 val specificationDummyConverter = object : EndpointConverter {601 override val conversionResult: Set<Endpoint> = setOf(602 Endpoint(603 path = "/todos",604 httpMethod = GET,605 headerParameters = setOf(606 HeaderParameter("cache")607 )608 )609 )610 override val supportedFeatures = SupportedFeatures(Feature.HeaderParameters)611 }612 val implementationDummyConverter = object : EndpointConverter {613 override val conversionResult: Set<Endpoint> = setOf(614 Endpoint(615 path = "/todos",616 httpMethod = GET,617 headerParameters = setOf(618 HeaderParameter("allow-cache")619 )620 )621 )622 override val supportedFeatures = SupportedFeatures(Feature.HeaderParameters)623 }624 val hikaku = Hikaku(625 specificationDummyConverter,626 implementationDummyConverter,627 HikakuConfig(628 reporters = listOf(NoOperationReporter())629 )630 )631 //when632 assertFailsWith<AssertionFailedError> {633 hikaku.match()634 }635 }636 @Test637 fun `header parameter required matches if the feature is supported by both converters`() {638 //given639 val specificationDummyConverter = object : EndpointConverter {640 override val conversionResult: Set<Endpoint> = setOf(641 Endpoint(642 path = "/todos",643 httpMethod = GET,644 headerParameters = setOf(645 HeaderParameter("allow-cache", true)646 )647 )648 )649 override val supportedFeatures = SupportedFeatures(Feature.HeaderParameters)650 }651 val implementationDummyConverter = object : EndpointConverter {652 override val conversionResult: Set<Endpoint> = setOf(653 Endpoint(654 path = "/todos",655 httpMethod = GET,656 headerParameters = setOf(657 HeaderParameter("allow-cache", true)658 )659 )660 )661 override val supportedFeatures = SupportedFeatures(Feature.HeaderParameters)662 }663 val hikaku = Hikaku(664 specificationDummyConverter,665 implementationDummyConverter,666 HikakuConfig(667 reporters = listOf(NoOperationReporter())668 )669 )670 //when671 hikaku.match()672 }673 @Test674 fun `header parameter required is skipped if option is not supported by one of the converters`() {675 //given676 val specificationDummyConverter = object : EndpointConverter {677 override val conversionResult: Set<Endpoint> = setOf(678 Endpoint(679 path = "/todos",680 httpMethod = GET,681 headerParameters = setOf(682 HeaderParameter("allow-cache", false)683 )684 )685 )686 override val supportedFeatures = SupportedFeatures()687 }688 val implementationDummyConverter = object : EndpointConverter {689 override val conversionResult: Set<Endpoint> = setOf(690 Endpoint(691 path = "/todos",692 httpMethod = GET,693 headerParameters = setOf(694 HeaderParameter("allow-cache", true)695 )696 )697 )698 override val supportedFeatures = SupportedFeatures(Feature.HeaderParameters)699 }700 val hikaku = Hikaku(701 specificationDummyConverter,702 implementationDummyConverter,703 HikakuConfig(704 reporters = listOf(NoOperationReporter())705 )706 )707 //when708 hikaku.match()709 }710 @Test711 fun `header parameter required don't match`() {712 //given713 val specificationDummyConverter = object : EndpointConverter {714 override val conversionResult: Set<Endpoint> = setOf(715 Endpoint(716 path = "/todos",717 httpMethod = GET,718 headerParameters = setOf(719 HeaderParameter("allow-cache", true)720 )721 )722 )723 override val supportedFeatures = SupportedFeatures(Feature.HeaderParameters)724 }725 val implementationDummyConverter = object : EndpointConverter {726 override val conversionResult: Set<Endpoint> = setOf(727 Endpoint(728 path = "/todos",729 httpMethod = GET,730 headerParameters = setOf(731 HeaderParameter("allow-cache", false)732 )733 )734 )735 override val supportedFeatures = SupportedFeatures(Feature.HeaderParameters)736 }737 val hikaku = Hikaku(738 specificationDummyConverter,739 implementationDummyConverter,740 HikakuConfig(741 reporters = listOf(NoOperationReporter())742 )743 )744 //when745 assertFailsWith<AssertionFailedError> {746 hikaku.match()747 }748 }749 }750 @Nested751 inner class MatrixParameterNameTests {752 @Test753 fun `matrix parameter names in random order match if the feature is supported by both converters`() {754 //given755 val specificationDummyConverter = object : EndpointConverter {756 override val conversionResult: Set<Endpoint> = setOf(757 Endpoint(758 path = "/todos",759 httpMethod = GET,760 matrixParameters = setOf(761 MatrixParameter("tag"),762 MatrixParameter("done")763 )764 )765 )766 override val supportedFeatures = SupportedFeatures(Feature.MatrixParameters)767 }768 val implementationDummyConverter = object : EndpointConverter {769 override val conversionResult: Set<Endpoint> = setOf(770 Endpoint(771 path = "/todos",772 httpMethod = GET,773 matrixParameters = setOf(774 MatrixParameter("done"),775 MatrixParameter("tag")776 )777 )778 )779 override val supportedFeatures = SupportedFeatures(Feature.MatrixParameters)780 }781 val hikaku = Hikaku(782 specificationDummyConverter,783 implementationDummyConverter,784 HikakuConfig(785 reporters = listOf(NoOperationReporter())786 )787 )788 //when789 hikaku.match()790 }791 @Test792 fun `matrix parameter names are skipped if the feature is not supported by one of the converters`() {793 //given794 val specificationDummyConverter = object : EndpointConverter {795 override val conversionResult: Set<Endpoint> = setOf(796 Endpoint(797 path = "/todos",798 httpMethod = GET,799 matrixParameters = setOf(800 MatrixParameter("done")801 )802 )803 )804 override val supportedFeatures = SupportedFeatures()805 }806 val implementationDummyConverter = object : EndpointConverter {807 override val conversionResult: Set<Endpoint> = setOf(808 Endpoint(809 path = "/todos",810 httpMethod = GET,811 matrixParameters = setOf(812 MatrixParameter("tag")813 )814 )815 )816 override val supportedFeatures = SupportedFeatures(Feature.MatrixParameters)817 }818 val hikaku = Hikaku(819 specificationDummyConverter,820 implementationDummyConverter,821 HikakuConfig(822 reporters = listOf(NoOperationReporter())823 )824 )825 //when826 hikaku.match()827 }828 @Test829 fun `matrix parameter names don't match`() {830 //given831 val specificationDummyConverter = object : EndpointConverter {832 override val conversionResult: Set<Endpoint> = setOf(833 Endpoint(834 path = "/todos",835 httpMethod = GET,836 matrixParameters = setOf(837 MatrixParameter("tag")838 )839 )840 )841 override val supportedFeatures = SupportedFeatures(Feature.MatrixParameters)842 }843 val implementationDummyConverter = object : EndpointConverter {844 override val conversionResult: Set<Endpoint> = setOf(845 Endpoint(846 path = "/todos",847 httpMethod = GET,848 matrixParameters = setOf(849 MatrixParameter("done")850 )851 )852 )853 override val supportedFeatures = SupportedFeatures(Feature.MatrixParameters)854 }855 val hikaku = Hikaku(856 specificationDummyConverter,857 implementationDummyConverter,858 HikakuConfig(859 reporters = listOf(NoOperationReporter())860 )861 )862 //when863 assertFailsWith<AssertionFailedError> {864 hikaku.match()865 }866 }867 @Test868 fun `matrix parameter required matches if the feature is supported by both converters`() {869 //given870 val specificationDummyConverter = object : EndpointConverter {871 override val conversionResult: Set<Endpoint> = setOf(872 Endpoint(873 path = "/todos",874 httpMethod = GET,875 matrixParameters = setOf(876 MatrixParameter("tag", true)877 )878 )879 )880 override val supportedFeatures = SupportedFeatures(Feature.MatrixParameters)881 }882 val implementationDummyConverter = object : EndpointConverter {883 override val conversionResult: Set<Endpoint> = setOf(884 Endpoint(885 path = "/todos",886 httpMethod = GET,887 matrixParameters = setOf(888 MatrixParameter("tag", true)889 )890 )891 )892 override val supportedFeatures = SupportedFeatures(Feature.MatrixParameters)893 }894 val hikaku = Hikaku(895 specificationDummyConverter,896 implementationDummyConverter,897 HikakuConfig(898 reporters = listOf(NoOperationReporter())899 )900 )901 //when902 hikaku.match()903 }904 @Test905 fun `matrix parameter required is skipped if option is not supported by one of the converters`() {906 //given907 val specificationDummyConverter = object : EndpointConverter {908 override val conversionResult: Set<Endpoint> = setOf(909 Endpoint(910 path = "/todos",911 httpMethod = GET,912 matrixParameters = setOf(913 MatrixParameter("tag", true)914 )915 )916 )917 override val supportedFeatures = SupportedFeatures()918 }919 val implementationDummyConverter = object : EndpointConverter {920 override val conversionResult: Set<Endpoint> = setOf(921 Endpoint(922 path = "/todos",923 httpMethod = GET,924 headerParameters = setOf(925 HeaderParameter("tag", false)926 )927 )928 )929 override val supportedFeatures = SupportedFeatures(Feature.MatrixParameters)930 }931 val hikaku = Hikaku(932 specificationDummyConverter,933 implementationDummyConverter,934 HikakuConfig(935 reporters = listOf(NoOperationReporter())936 )937 )938 //when939 hikaku.match()940 }941 @Test942 fun `matrix parameter required don't match`() {943 //given944 val specificationDummyConverter = object : EndpointConverter {945 override val conversionResult: Set<Endpoint> = setOf(946 Endpoint(947 path = "/todos",948 httpMethod = GET,949 matrixParameters = setOf(950 MatrixParameter("allow-cache", true)951 )952 )953 )954 override val supportedFeatures = SupportedFeatures(Feature.MatrixParameters)955 }956 val implementationDummyConverter = object : EndpointConverter {957 override val conversionResult: Set<Endpoint> = setOf(958 Endpoint(959 path = "/todos",960 httpMethod = GET,961 matrixParameters = setOf(962 MatrixParameter("allow-cache", false)963 )964 )965 )966 override val supportedFeatures = SupportedFeatures(Feature.MatrixParameters)967 }968 val hikaku = Hikaku(969 specificationDummyConverter,970 implementationDummyConverter,971 HikakuConfig(972 reporters = listOf(NoOperationReporter())973 )974 )975 //when976 assertFailsWith<AssertionFailedError> {977 hikaku.match()978 }979 }980 }981 @Nested982 inner class ProducesTests {983 @Test984 fun `media types in random order match if the feature is supported by both converters`() {985 //given986 val specificationDummyConverter = object : EndpointConverter {987 override val conversionResult: Set<Endpoint> = setOf(988 Endpoint(989 path = "/todos",990 httpMethod = GET,991 produces = setOf(992 "application/json",993 "text/plain"994 )995 )996 )997 override val supportedFeatures = SupportedFeatures(Feature.Produces)998 }999 val implementationDummyConverter = object : EndpointConverter {1000 override val conversionResult: Set<Endpoint> = setOf(1001 Endpoint(1002 path = "/todos",1003 httpMethod = GET,1004 produces = setOf(1005 "text/plain",1006 "application/json"1007 )1008 )1009 )1010 override val supportedFeatures = SupportedFeatures(Feature.Produces)1011 }1012 val hikaku = Hikaku(1013 specificationDummyConverter,1014 implementationDummyConverter,1015 HikakuConfig(1016 reporters = listOf(NoOperationReporter())1017 )1018 )1019 //when1020 hikaku.match()1021 }1022 @Test1023 fun `produces is skipped if the feature is not supported by one of the converters`() {1024 //given1025 val specificationDummyConverter = object : EndpointConverter {1026 override val conversionResult: Set<Endpoint> = setOf(1027 Endpoint(1028 path = "/todos",1029 httpMethod = GET,1030 produces = setOf(1031 "application/xml",1032 "text/plain"1033 )1034 )1035 )1036 override val supportedFeatures = SupportedFeatures()1037 }1038 val implementationDummyConverter = object : EndpointConverter {1039 override val conversionResult: Set<Endpoint> = setOf(1040 Endpoint(1041 path = "/todos",1042 httpMethod = GET,1043 produces = setOf(1044 "application/json"1045 )1046 )1047 )1048 override val supportedFeatures = SupportedFeatures(Feature.Produces)1049 }1050 val hikaku = Hikaku(1051 specificationDummyConverter,1052 implementationDummyConverter,1053 HikakuConfig(1054 reporters = listOf(NoOperationReporter())1055 )1056 )1057 //when1058 hikaku.match()1059 }1060 @Test1061 fun `media types don't match`() {1062 //given1063 val specificationDummyConverter = object : EndpointConverter {1064 override val conversionResult: Set<Endpoint> = setOf(1065 Endpoint(1066 path = "/todos",1067 httpMethod = GET,1068 produces = setOf(1069 "application/xml",1070 "text/plain"1071 )1072 )1073 )1074 override val supportedFeatures = SupportedFeatures(Feature.Produces)1075 }1076 val implementationDummyConverter = object : EndpointConverter {1077 override val conversionResult: Set<Endpoint> = setOf(1078 Endpoint(1079 path = "/todos",1080 httpMethod = GET,1081 produces = setOf(1082 "application/json"1083 )1084 )1085 )1086 override val supportedFeatures = SupportedFeatures(Feature.Produces)1087 }1088 val hikaku = Hikaku(1089 specificationDummyConverter,1090 implementationDummyConverter,1091 HikakuConfig(1092 reporters = listOf(NoOperationReporter())1093 )1094 )1095 //when1096 assertFailsWith<AssertionFailedError> {1097 hikaku.match()1098 }1099 }1100 }1101 @Nested1102 inner class ConsumesTests {1103 @Test1104 fun `media types in random order match if the feature is supported by both converters`() {1105 //given1106 val specificationDummyConverter = object : EndpointConverter {1107 override val conversionResult: Set<Endpoint> = setOf(1108 Endpoint(1109 path = "/todos",1110 httpMethod = GET,1111 consumes = setOf(1112 "application/json",1113 "text/plain"1114 )1115 )1116 )1117 override val supportedFeatures = SupportedFeatures(Feature.Consumes)1118 }1119 val implementationDummyConverter = object : EndpointConverter {1120 override val conversionResult: Set<Endpoint> = setOf(1121 Endpoint(1122 path = "/todos",1123 httpMethod = GET,1124 consumes = setOf(1125 "text/plain",1126 "application/json"1127 )1128 )1129 )1130 override val supportedFeatures = SupportedFeatures(Feature.Consumes)1131 }1132 val hikaku = Hikaku(1133 specificationDummyConverter,1134 implementationDummyConverter,1135 HikakuConfig(1136 reporters = listOf(NoOperationReporter())1137 )1138 )1139 //when1140 hikaku.match()1141 }1142 @Test1143 fun `produces is skipped if the feature is not supported by one of the converters`() {1144 //given1145 val specificationDummyConverter = object : EndpointConverter {1146 override val conversionResult: Set<Endpoint> = setOf(1147 Endpoint(1148 path = "/todos",1149 httpMethod = GET,1150 consumes = setOf(1151 "application/xml",1152 "text/plain"1153 )1154 )1155 )1156 override val supportedFeatures = SupportedFeatures()1157 }1158 val implementationDummyConverter = object : EndpointConverter {1159 override val conversionResult: Set<Endpoint> = setOf(1160 Endpoint(1161 path = "/todos",1162 httpMethod = GET,1163 consumes = setOf(1164 "application/json"1165 )1166 )1167 )1168 override val supportedFeatures = SupportedFeatures(Feature.Consumes)1169 }1170 val hikaku = Hikaku(1171 specificationDummyConverter,1172 implementationDummyConverter,1173 HikakuConfig(1174 reporters = listOf(NoOperationReporter())1175 )1176 )1177 //when1178 hikaku.match()1179 }1180 @Test1181 fun `media types don't match`() {1182 //given1183 val specificationDummyConverter = object : EndpointConverter {1184 override val conversionResult: Set<Endpoint> = setOf(1185 Endpoint(1186 path = "/todos",1187 httpMethod = GET,1188 consumes = setOf(1189 "application/xml",1190 "text/plain"1191 )1192 )1193 )1194 override val supportedFeatures = SupportedFeatures(Feature.Consumes)1195 }1196 val implementationDummyConverter = object : EndpointConverter {1197 override val conversionResult: Set<Endpoint> = setOf(1198 Endpoint(1199 path = "/todos",1200 httpMethod = GET,1201 consumes = setOf(1202 "application/json"1203 )1204 )1205 )1206 override val supportedFeatures = SupportedFeatures(Feature.Consumes)1207 }1208 val hikaku = Hikaku(1209 specificationDummyConverter,1210 implementationDummyConverter,1211 HikakuConfig(1212 reporters = listOf(NoOperationReporter())1213 )1214 )1215 //when1216 assertFailsWith<AssertionFailedError> {1217 hikaku.match()1218 }1219 }1220 }1221 @Nested1222 inner class DeprecationTests {1223 @Test1224 fun `deprecation info in random order match if the feature is supported by both converters`() {1225 //given1226 val specificationDummyConverter = object : EndpointConverter {1227 override val conversionResult: Set<Endpoint> = setOf(1228 Endpoint(1229 path = "/todos",1230 httpMethod = GET,1231 deprecated = false1232 ),1233 Endpoint(1234 path = "/todos/tags",1235 httpMethod = GET,1236 deprecated = true1237 )1238 )1239 override val supportedFeatures = SupportedFeatures(Feature.Deprecation)1240 }1241 val implementationDummyConverter = object : EndpointConverter {1242 override val conversionResult: Set<Endpoint> = setOf(1243 Endpoint(1244 path = "/todos/tags",1245 httpMethod = GET,1246 deprecated = true1247 ),1248 Endpoint(1249 path = "/todos",1250 httpMethod = GET,1251 deprecated = false1252 )1253 )1254 override val supportedFeatures = SupportedFeatures(Feature.Deprecation)1255 }1256 val hikaku = Hikaku(1257 specificationDummyConverter,1258 implementationDummyConverter,1259 HikakuConfig(1260 reporters = listOf(NoOperationReporter())1261 )1262 )1263 //when1264 hikaku.match()1265 }1266 @Test1267 fun `deprecation info is skipped if the feature is not supported by one of the converters`() {1268 //given1269 val specificationDummyConverter = object : EndpointConverter {1270 override val conversionResult: Set<Endpoint> = setOf(1271 Endpoint(1272 path = "/todos",1273 httpMethod = GET,1274 deprecated = false1275 )1276 )1277 override val supportedFeatures = SupportedFeatures()1278 }1279 val implementationDummyConverter = object : EndpointConverter {1280 override val conversionResult: Set<Endpoint> = setOf(1281 Endpoint(1282 path = "/todos",1283 httpMethod = GET,1284 deprecated = true1285 )1286 )1287 override val supportedFeatures = SupportedFeatures(Feature.Deprecation)1288 }1289 val hikaku = Hikaku(1290 specificationDummyConverter,1291 implementationDummyConverter,1292 HikakuConfig(1293 reporters = listOf(NoOperationReporter())1294 )1295 )1296 //when1297 hikaku.match()1298 }1299 @Test1300 fun `deprecation info does not match`() {1301 //given1302 val specificationDummyConverter = object : EndpointConverter {1303 override val conversionResult: Set<Endpoint> = setOf(1304 Endpoint(1305 path = "/todos",1306 httpMethod = GET,1307 deprecated = false1308 )1309 )1310 override val supportedFeatures = SupportedFeatures(Feature.Deprecation)1311 }1312 val implementationDummyConverter = object : EndpointConverter {1313 override val conversionResult: Set<Endpoint> = setOf(1314 Endpoint(1315 path = "/todos",1316 httpMethod = GET,1317 deprecated = true1318 )1319 )1320 override val supportedFeatures = SupportedFeatures(Feature.Deprecation)1321 }1322 val hikaku = Hikaku(1323 specificationDummyConverter,1324 implementationDummyConverter,1325 HikakuConfig(1326 reporters = listOf(NoOperationReporter())1327 )1328 )1329 //when1330 assertFailsWith<AssertionFailedError> {1331 hikaku.match()1332 }1333 }1334 }1335 }1336 @Nested1337 inner class ConfigTests {1338 @Test1339 fun `ignore endpoints with http method HEAD and OPTIONS on specification`() {1340 //given1341 val dummyConverterWithHeadAndOptions = object : EndpointConverter {1342 override val conversionResult: Set<Endpoint> = setOf(1343 Endpoint("/todos", GET),1344 Endpoint("/todos", HEAD),1345 Endpoint("/todos", OPTIONS)1346 )1347 override val supportedFeatures = SupportedFeatures()1348 }1349 val dummyConverter = object : EndpointConverter {1350 override val conversionResult: Set<Endpoint> = setOf(1351 Endpoint("/todos", GET)1352 )1353 override val supportedFeatures = SupportedFeatures()1354 }1355 val hikaku = Hikaku(1356 dummyConverterWithHeadAndOptions,1357 dummyConverter,1358 HikakuConfig(1359 filters = listOf (1360 { endpoint -> endpoint.httpMethod == HEAD },1361 { endpoint -> endpoint.httpMethod == OPTIONS }1362 ),1363 reporters = listOf(NoOperationReporter())1364 )1365 )1366 //when1367 hikaku.match()1368 }1369 @Test1370 fun `ignore endpoints with http method HEAD and OPTIONS on implementation`() {1371 //given1372 val dummyConverter = object : EndpointConverter {1373 override val conversionResult: Set<Endpoint> = setOf(1374 Endpoint("/todos", GET)1375 )1376 override val supportedFeatures = SupportedFeatures()1377 }1378 val dummyConverterWithHeadAndOptions = object : EndpointConverter {1379 override val conversionResult: Set<Endpoint> = setOf(1380 Endpoint("/todos", GET),1381 Endpoint("/todos", HEAD),1382 Endpoint("/todos", OPTIONS)1383 )1384 override val supportedFeatures = SupportedFeatures()1385 }1386 val hikaku = Hikaku(1387 dummyConverter,1388 dummyConverterWithHeadAndOptions,1389 HikakuConfig(1390 filters = listOf (1391 { endpoint -> endpoint.httpMethod == HEAD },1392 { endpoint -> endpoint.httpMethod == OPTIONS }1393 ),1394 reporters = listOf(NoOperationReporter())1395 )1396 )1397 //when1398 hikaku.match()1399 }1400 @Test1401 fun `ignore specific paths`() {1402 //given1403 val specificationDummyConverter = object : EndpointConverter {1404 override val conversionResult: Set<Endpoint> = setOf(1405 Endpoint("/todos", GET)1406 )1407 override val supportedFeatures = SupportedFeatures()1408 }1409 val implementationDummyConverter = object : EndpointConverter {1410 override val conversionResult: Set<Endpoint> = setOf(1411 Endpoint("/todos", GET),1412 Endpoint("/error", GET),1413 Endpoint("/error", HEAD),1414 Endpoint("/error", OPTIONS),1415 Endpoint("/actuator/health", OPTIONS)1416 )1417 override val supportedFeatures = SupportedFeatures()1418 }1419 val hikaku = Hikaku(1420 specificationDummyConverter,1421 implementationDummyConverter,1422 HikakuConfig(1423 filters = listOf (1424 { endpoint -> endpoint.path == "/error" },1425 { endpoint -> endpoint.path.startsWith("/actuator") }1426 ),1427 reporters = listOf(NoOperationReporter())1428 )1429 )1430 //when1431 hikaku.match()1432 }1433 }1434 @Nested1435 inner class ReporterTests {1436 @Test1437 fun `MatchResult has to be passed to the Reporter`() {1438 //given1439 val dummyConverter = object : EndpointConverter {1440 override val conversionResult: Set<Endpoint> = setOf(1441 Endpoint("/todos", GET)1442 )1443 override val supportedFeatures = SupportedFeatures()1444 }1445 val reporter = object : Reporter {1446 var hasBeenCalled: Boolean = false1447 override fun report(endpointMatchResult: MatchResult) {1448 hasBeenCalled = true1449 }1450 }1451 val hikaku = Hikaku(1452 dummyConverter,1453 dummyConverter,1454 HikakuConfig(1455 reporters = listOf(reporter)1456 )1457 )1458 //when1459 hikaku.match()1460 //then1461 assertThat(reporter.hasBeenCalled).isTrue()1462 }1463 @Test1464 fun `MatchResult can be passed to multiple Reporter`() {1465 //given1466 val dummyConverter = object : EndpointConverter {1467 override val conversionResult: Set<Endpoint> = setOf(1468 Endpoint("/todos", GET)1469 )1470 override val supportedFeatures = SupportedFeatures()1471 }1472 val firstReporter = object : Reporter {1473 var hasBeenCalled: Boolean = false1474 override fun report(endpointMatchResult: MatchResult) {1475 hasBeenCalled = true1476 }1477 }1478 val secondReporter = object : Reporter {1479 var hasBeenCalled: Boolean = false1480 override fun report(endpointMatchResult: MatchResult) {1481 hasBeenCalled = true1482 }1483 }1484 val hikaku = Hikaku(1485 dummyConverter,1486 dummyConverter,1487 HikakuConfig(1488 reporters = listOf(firstReporter, secondReporter)1489 )1490 )1491 //when1492 hikaku.match()1493 //then1494 assertThat(firstReporter.hasBeenCalled).isTrue()1495 assertThat(secondReporter.hasBeenCalled).isTrue()1496 }1497 }1498}...

Full Screen

Full Screen

SpringConverterPathTest.kt

Source:SpringConverterPathTest.kt Github

copy

Full Screen

...38 val implementation = SpringConverter(context)39 //when40 val hikaku = Hikaku(config = hikakuConfig, specification = specification, implementation = implementation)41 //then42 hikaku.match()43 }44 }45 @Nested46 inner class ClassLevelTests {47 @Nested48 @WebMvcTest(RequestMappingOnClassWithMultiplePathsController::class, excludeAutoConfiguration = [ErrorMvcAutoConfiguration::class])49 inner class RequestMappingOnClassWithMultiplePathsTest {50 @Autowired51 lateinit var context: ConfigurableApplicationContext52 @Test53 fun `multiple paths extracted correctly`() {54 //given55 val specification: Set<Endpoint> = setOf(56 Endpoint("/todos", GET),...

Full Screen

Full Screen

Hikaku.kt

Source:Hikaku.kt Github

copy

Full Screen

...5import de.codecentric.hikaku.reporters.MatchResult6import de.codecentric.hikaku.reporters.Reporter7import kotlin.test.fail8/**9 * Entry point for writing a hikaku test. Provide the [EndpointConverter]s and call [match] to test if the specification and the implementation of your REST-API match.10 * @param specification An [EndpointConverter] which converts your specification for the equality check.11 * @param implementation An [EndpointConverter] which converts your implementation for the equality check.12 * @param config The configuration is optional. It lets you control the matching.13 */14class Hikaku(15 private val specification: EndpointConverter,16 private val implementation: EndpointConverter,17 var config: HikakuConfig = HikakuConfig()18) {19 private val supportedFeatures = SupportedFeatures(specification.supportedFeatures.intersect(implementation.supportedFeatures))20 private fun Set<Endpoint>.applyConfig(config: HikakuConfig): List<Endpoint> {21 val result = this.toMutableList()22 config.filters.forEach {23 result.removeAll(this.filter(it))24 }25 return result26 }27 private fun reportResult(matchResult: MatchResult) {28 config.reporters.forEach { it.report(matchResult) }29 }30 /**31 * Calling this method creates a [MatchResult]. It will be passed to the [Reporter] defined in the configuration and call [assert] with the end result.32 */33 fun match() {34 val specificationEndpoints = specification35 .conversionResult36 .applyConfig(config)37 .toSet()38 val implementationEndpoints = implementation39 .conversionResult40 .applyConfig(config)41 .toSet()42 val notExpected = implementationEndpoints.toMutableSet()43 val notFound = specificationEndpoints.toMutableSet()44 specificationEndpoints.forEach { currentEndpoint ->45 if (iterableContains(notExpected, currentEndpoint)) {46 notExpected.removeIf(endpointMatches(currentEndpoint))47 notFound.removeIf(endpointMatches(currentEndpoint))48 }49 }50 reportResult(51 MatchResult(52 supportedFeatures,53 specificationEndpoints,54 implementationEndpoints,55 notFound,56 notExpected57 )58 )59 if (notExpected.isNotEmpty() || notFound.isNotEmpty()) {60 fail("Implementation does not match specification.")61 }62 }63 private fun endpointMatches(otherEndpoint: Endpoint): (Endpoint) -> Boolean {64 return {65 var matches = true66 matches = matches && it.path == otherEndpoint.path67 matches = matches && it.httpMethod == otherEndpoint.httpMethod68 supportedFeatures.forEach { feature ->69 matches = when (feature) {70 Feature.QueryParameters -> matches && it.queryParameters == otherEndpoint.queryParameters71 Feature.PathParameters -> matches && it.pathParameters == otherEndpoint.pathParameters72 Feature.HeaderParameters -> matches && it.headerParameters == otherEndpoint.headerParameters73 Feature.MatrixParameters -> matches && it.matrixParameters == otherEndpoint.matrixParameters74 Feature.Produces -> matches && it.produces == otherEndpoint.produces75 Feature.Consumes -> matches && it.consumes == otherEndpoint.consumes76 Feature.Deprecation -> matches && it.deprecated == otherEndpoint.deprecated77 }78 }79 matches80 }81 }82 private fun iterableContains(notExpected: Set<Endpoint>, value: Endpoint) = notExpected.any(endpointMatches(value))83}...

Full Screen

Full Screen

CommandLineReporter.kt

Source:CommandLineReporter.kt Github

copy

Full Screen

...11 println("\n")12 println(heading)13 println("#".repeat(heading.length))14 val features = endpointMatchResult.supportedFeatures.joinToString(separator = ", ")15 println("The following features were used for matching: HttpMethod, Path, $features")16 if (endpointMatchResult.notFound.isEmpty() && endpointMatchResult.notExpected.isEmpty()) {17 println ("")18 println ("✅ Test successful. Specification and implementation match.")19 }20 if (endpointMatchResult.notFound.isNotEmpty()) {21 println("\n👀 Expected, but unable to find:")22 endpointMatchResult.notFound.forEach {23 printEndpoint(endpointMatchResult.supportedFeatures, it)24 }25 }26 if (endpointMatchResult.notExpected.isNotEmpty()) {27 println("\n👻 Unexpected, but found:")28 endpointMatchResult.notExpected.forEach {29 printEndpoint(endpointMatchResult.supportedFeatures, it)30 }31 }32 }...

Full Screen

Full Screen

MatchResult.kt

Source:MatchResult.kt Github

copy

Full Screen

2import de.codecentric.hikaku.SupportedFeatures3import de.codecentric.hikaku.endpoints.Endpoint4/**5 * Contains the complete result.6 * @param supportedFeatures Contains all features which have been used for the match.7 * @param specificationEndpoints All [Endpoint]s extracted from the specification.8 * @param implementationEndpoints All [Endpoint]s extracted from the implementation.9 * @param notFound A [Set] of [Endpoint]s which were expected due to their existence in the specification, but which couldn't be found.10 * @param notExpected A [Set] of [Endpoint]s which have been found in the implementation, but which were unexpected, because they don't exist in the specification.11 */12data class MatchResult(13 val supportedFeatures: SupportedFeatures,14 val specificationEndpoints: Set<Endpoint>,15 val implementationEndpoints: Set<Endpoint>,16 val notFound: Set<Endpoint>,17 val notExpected: Set<Endpoint>18)

Full Screen

Full Screen

HikakuConfig.kt

Source:HikakuConfig.kt Github

copy

Full Screen

...3import de.codecentric.hikaku.reporters.CommandLineReporter4import de.codecentric.hikaku.reporters.MatchResult5import de.codecentric.hikaku.reporters.Reporter6/**7 * Configuration for [Hikaku] class. It lets you partially control the matching process.8 * @param reporters The [MatchResult] will be passed to one or many [Reporter] before the test either fails or succeeds. Default is a [CommandLineReporter] that prints the results to [System.out].9 * @param filters Filtering rule: [Endpoint]s matching the predicate will be ignored.10 */11data class HikakuConfig12@JvmOverloads constructor(13 val reporters: List<Reporter> = listOf(CommandLineReporter()),14 val filters: List<(Endpoint) -> Boolean> = emptyList()15)...

Full Screen

Full Screen

Reporter.kt

Source:Reporter.kt Github

copy

Full Screen

1package de.codecentric.hikaku.reporters2/**3 * A [Reporter] will receive the [MatchResult] before the test terminates.4 */5interface Reporter {6 fun report(endpointMatchResult: MatchResult)7}...

Full Screen

Full Screen

NoOperationReporter.kt

Source:NoOperationReporter.kt Github

copy

Full Screen

1package de.codecentric.hikaku.reporters2/**3 * Receives the result and does nothing.4 */5class NoOperationReporter : Reporter {6 override fun report(endpointMatchResult: MatchResult) { }7}...

Full Screen

Full Screen

match

Using AI Code Generation

copy

Full Screen

1import de.codecentric.hikaku.converters.openapitools.OpenApiToolsConverter2import de.codecentric.hikaku.endpoints.Endpoint3import de.codecentric.hikaku.endpoints.Path4import de.codecentric.hikaku.endpoints.QueryParameter5import de.codecentric.hikaku.endpoints.http.HttpMethod6import de.codecentric.hikaku.endpoints.http.HttpMethod.DELETE7import de.codecentric.hikaku.endpoints.http.HttpMethod.GET8import de.codecentric.hikaku.endpoints.http.HttpMethod.POST9import de.codecentric.hikaku.endpoints.http.HttpMethod.PUT10import de.codecentric.hikaku.endpoints.http.HttpStatus11import de.codecentric.hikaku.endpoints.http.HttpStatus.OK12import de.codecentric.hikaku.endpoints.http.HttpStatus.CREATED13import de.codecentric.hikaku.endpoints.http.HttpStatus.NO_CONTENT14import de.codecentric.hikaku.endpoints.http.HttpStatus.BAD_REQUEST15import de.codecentric.hikaku.endpoints.http.HttpStatus.UNAUTHORIZED16import de.codecentric.hikaku.endpoints.http.HttpStatus.FORBIDDEN17import de.codecentric.hikaku.endpoints.http.HttpStatus.NOT_FOUND18import de.codecentric.hikaku.endpoints.http.HttpStatus.INTERNAL_SERVER_ERROR19import de.codecentric.hikaku.endpoints.http.HttpStatus.NOT_IMPLEMENTED20import de.codecentric.hikaku.endpoints.http.HttpStatus.BAD_GATEWAY21import de.codecentric.hikaku.endpoints.http.HttpStatus.SERVICE_UNAVAILABLE22import de.codecentric.hikaku.endpoints.http.HttpStatus.GATEWAY_TIMEOUT23import de.codecentric.hikaku.endpoints.http.HttpStatus.HTTP_VERSION_NOT_SUPPORTED24import de.codecentric.hikaku.endpoints.http.HttpStatus.NETWORK_AUTHENTICATION_REQUIRED25import de.codecentric.hikaku.endpoints.http.HttpStatus.TOO_MANY_REQUESTS26import de.codecentric.hikaku.endpoints.http.HttpStatus.REQUEST_HEADER_FIELDS_TOO_LARGE27import de.codecentric.hikaku.endpoints.http.HttpStatus.UNAVAILABLE_FOR_LEGAL_REASONS28import de.codecentric.hikaku.endpoints.http.HttpStatus.INSUFFICIENT_STORAGE29import de.codecentric.hikaku.endpoints.http.HttpStatus.LOOP_DETECTED30import de.codecentric.hikaku.endpoints.http.HttpStatus.NOT_EXTENDED31import de.codecentric.hikaku.endpoints.http.HttpStatus.NETWORK_CONNECT_TIMEOUT_ERROR32import de.codecentric.hikaku

Full Screen

Full Screen

match

Using AI Code Generation

copy

Full Screen

1val hikaku = Hikaku()2hikaku.match(converter.convert(contract), converter.convert(api))3val hikaku = Hikaku()4hikaku.match(converter.convert(contract), converter.convert(api))5val hikaku = Hikaku()6hikaku.match(converter.convert(contract), converter.convert(api))7val hikaku = Hikaku()8hikaku.match(converter.convert(contract), converter.convert(api))9val hikaku = Hikaku()10hikaku.match(converter.convert(contract), converter.convert(api))11val hikaku = Hikaku()12hikaku.match(converter.convert(contract), converter.convert(api))13val hikaku = Hikaku()14hikaku.match(converter.convert(contract), converter.convert(api))15val hikaku = Hikaku()16hikaku.match(converter.convert(contract), converter.convert(api))17val hikaku = Hikaku()18hikaku.match(converter.convert(contract), converter.convert(api))19val hikaku = Hikaku()20hikaku.match(converter.convert(contract), converter.convert(api))21val hikaku = Hikaku()22hikaku.match(converter.convert(contract), converter.convert(api))23val hikaku = Hikaku()24hikaku.match(converter.convert(contract), converter.convert(api))

Full Screen

Full Screen

match

Using AI Code Generation

copy

Full Screen

1val match = Hikaku.match(response, expectedResponse)2val match = Hikaku.match(response, expectedResponse)3val match = Hikaku.match(response, expectedResponse)4val match = Hikaku.match(response, expectedResponse)5val match = Hikaku.match(response, expectedResponse)6val match = Hikaku.match(response, expectedResponse)7val match = Hikaku.match(response, expectedResponse)8val match = Hikaku.match(response, expectedResponse)

Full Screen

Full Screen

match

Using AI Code Generation

copy

Full Screen

1val hikaku = Hikaku()2val contract = ContractSpecification.fromYamlFile("src/test/resources/contract.yml")3val api = ApiSpecification.fromYamlFile("src/test/resources/api.yml")4val result = hikaku.match(contract, api)5val output = result.toYaml()6File("src/test/resources/result.yml").writeText(output)

Full Screen

Full Screen

match

Using AI Code Generation

copy

Full Screen

1val result = Hikaku.match(2ContentTypeComparison(),3HeaderComparison(),4QueryParameterComparison(),5PathParameterComparison(),6RequestBodyComparison(),7ResponseBodyComparison()8val result = Hikaku.match(9ContentTypeComparison(),10HeaderComparison(),11QueryParameterComparison(),12PathParameterComparison(),13RequestBodyComparison(),14ResponseBodyComparison()15val result = Hikaku.match(16ContentTypeComparison(),17HeaderComparison(),18QueryParameterComparison(),19PathParameterComparison(),20RequestBodyComparison(),21ResponseBodyComparison()22val result = Hikaku.match(23ContentTypeComparison(),24HeaderComparison(),25QueryParameterComparison(),26PathParameterComparison(),27RequestBodyComparison(),28ResponseBodyComparison()29val result = Hikaku.match(30ContentTypeComparison(),31HeaderComparison(),32QueryParameterComparison(),33PathParameterComparison(),34RequestBodyComparison(),35ResponseBodyComparison()36val result = Hikaku.match(37ContentTypeComparison(),38HeaderComparison(),39QueryParameterComparison(),40PathParameterComparison(),41RequestBodyComparison(),42ResponseBodyComparison()43val result = Hikaku.match(44ContentTypeComparison(),45HeaderComparison(),46QueryParameterComparison(),47PathParameterComparison(),48RequestBodyComparison(),49ResponseBodyComparison()50val result = Hikaku.match(51ContentTypeComparison(),52HeaderComparison(),53QueryParameterComparison(),54PathParameterComparison(),55RequestBodyComparison(),

Full Screen

Full Screen

match

Using AI Code Generation

copy

Full Screen

1}2}3Hikaku.match(endpoints)4Hikaku.matchWithCustomMatcher(endpoints, customMatchers)5Hikaku.matchWithCustomMatcher(endpoints, customMatchers, customMatchers)6Hikaku.matchWithCustomMatcher(endpoints, customMatchers, customMatchers, customMatchers)7Hikaku.matchWithCustomMatcher(endpoints, customMatchers, customMatchers, customMatchers, customMatchers)

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 Hikaku automation tests on LambdaTest cloud grid

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

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful