summaryrefslogtreecommitdiffstats
path: root/openecomp-be/api/openecomp-sdc-rest-webapp
diff options
context:
space:
mode:
authorkooper <sergey.sachkov@est.tech>2019-05-15 10:39:07 +0000
committerkooper <sergey.sachkov@est.tech>2019-05-15 10:39:07 +0000
commit02a3b49bec86eb0a434afb86e158ca2670cb718f (patch)
treeb24193003058bb85db012172fae19e2dc31a10b4 /openecomp-be/api/openecomp-sdc-rest-webapp
parent19493ec749d39407c90e841a2f3e503f6a03ecd7 (diff)
Update test coverage
Change-Id: Ib92d00266d17635b53593eaa544ca3b312c7ddb2 Issue-ID: SDC-2310 Signed-off-by: kooper <sergey.sachkov@est.tech>
Diffstat (limited to 'openecomp-be/api/openecomp-sdc-rest-webapp')
-rw-r--r--openecomp-be/api/openecomp-sdc-rest-webapp/validation-rest/validation-rest-services/pom.xml5
-rw-r--r--openecomp-be/api/openecomp-sdc-rest-webapp/validation-rest/validation-rest-services/src/test/java/org/openecomp/sdcrests/validation/rest/service/ValidationImplTest.java44
2 files changed, 49 insertions, 0 deletions
diff --git a/openecomp-be/api/openecomp-sdc-rest-webapp/validation-rest/validation-rest-services/pom.xml b/openecomp-be/api/openecomp-sdc-rest-webapp/validation-rest/validation-rest-services/pom.xml
index 33b8aafec1..fc1adc6bbb 100644
--- a/openecomp-be/api/openecomp-sdc-rest-webapp/validation-rest/validation-rest-services/pom.xml
+++ b/openecomp-be/api/openecomp-sdc-rest-webapp/validation-rest/validation-rest-services/pom.xml
@@ -128,6 +128,11 @@
<artifactId>junit</artifactId>
<scope>test</scope>
</dependency>
+ <dependency>
+ <groupId>org.mockito</groupId>
+ <artifactId>mockito-core</artifactId>
+ <scope>test</scope>
+ </dependency>
</dependencies>
</project>
diff --git a/openecomp-be/api/openecomp-sdc-rest-webapp/validation-rest/validation-rest-services/src/test/java/org/openecomp/sdcrests/validation/rest/service/ValidationImplTest.java b/openecomp-be/api/openecomp-sdc-rest-webapp/validation-rest/validation-rest-services/src/test/java/org/openecomp/sdcrests/validation/rest/service/ValidationImplTest.java
new file mode 100644
index 0000000000..08dcd4ed97
--- /dev/null
+++ b/openecomp-be/api/openecomp-sdc-rest-webapp/validation-rest/validation-rest-services/src/test/java/org/openecomp/sdcrests/validation/rest/service/ValidationImplTest.java
@@ -0,0 +1,44 @@
+package org.openecomp.sdcrests.validation.rest.service;
+
+import org.junit.Before;
+import org.junit.Test;
+import org.mockito.InjectMocks;
+import org.mockito.Mock;
+import org.openecomp.sdc.validation.UploadValidationManager;
+import org.openecomp.sdc.validation.types.ValidationFileResponse;
+import org.openecomp.sdcrests.validation.rest.services.ValidationImpl;
+
+import javax.ws.rs.core.Response;
+import java.io.ByteArrayInputStream;
+import java.io.IOException;
+
+import static org.junit.Assert.assertEquals;
+import static org.mockito.ArgumentMatchers.any;
+import static org.mockito.Mockito.when;
+import static org.mockito.MockitoAnnotations.initMocks;
+
+public class ValidationImplTest {
+
+ @Mock
+ private UploadValidationManager uploadValidationManager;
+ @InjectMocks
+ private ValidationImpl validation;
+
+ @Before
+ public void setUp(){
+ initMocks(this);
+ }
+
+ @Test
+ public void validateFileTest() throws IOException {
+ when(uploadValidationManager.validateFile(any(), any())).thenReturn(new ValidationFileResponse());
+ Response response = validation.validateFile("", new ByteArrayInputStream("".getBytes()));
+ assertEquals(response.getStatus(), Response.Status.OK.getStatusCode());
+ }
+
+ @Test(expected = RuntimeException.class)
+ public void validateFileExceptionTest() throws IOException {
+ when(uploadValidationManager.validateFile(any(), any())).thenThrow(new IOException());
+ Response response = validation.validateFile("", new ByteArrayInputStream("".getBytes()));
+ }
+}
>347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624