|
| 1 | +/* |
| 2 | + * Copyright 2025 Red Hat, Inc. and/or its affiliates |
| 3 | + * and other contributors as indicated by the @author tags. |
| 4 | + * |
| 5 | + * Licensed under the Apache License, Version 2.0 (the "License"); |
| 6 | + * you may not use this file except in compliance with the License. |
| 7 | + * You may obtain a copy of the License at |
| 8 | + * |
| 9 | + * http://www.apache.org/licenses/LICENSE-2.0 |
| 10 | + * |
| 11 | + * Unless required by applicable law or agreed to in writing, software |
| 12 | + * distributed under the License is distributed on an "AS IS" BASIS, |
| 13 | + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 14 | + * |
| 15 | + * See the License for the specific language governing permissions and |
| 16 | + * limitations under the License. |
| 17 | + */ |
| 18 | + |
| 19 | +package com.redhat.exhort.integration.modelcards; |
| 20 | + |
| 21 | +import static io.restassured.RestAssured.given; |
| 22 | +import static org.junit.jupiter.api.Assertions.assertEquals; |
| 23 | +import static org.junit.jupiter.api.Assertions.assertNotNull; |
| 24 | + |
| 25 | +import java.util.List; |
| 26 | + |
| 27 | +import org.junit.jupiter.api.Test; |
| 28 | + |
| 29 | +import com.redhat.exhort.api.v4.ListModelCardResponse; |
| 30 | +import com.redhat.exhort.api.v4.ModelCardQueryItem; |
| 31 | +import com.redhat.exhort.api.v4.ModelCardQueryRequest; |
| 32 | + |
| 33 | +import io.quarkus.test.junit.QuarkusTest; |
| 34 | + |
| 35 | +@QuarkusTest |
| 36 | +public class ModelCardIntegrationTest { |
| 37 | + |
| 38 | + @Test |
| 39 | + public void testListModelCards() { |
| 40 | + var request = new ModelCardQueryRequest(); |
| 41 | + var queryItem = new ModelCardQueryItem(); |
| 42 | + queryItem.setModelName("microsoft/phi-2"); |
| 43 | + var notFoundItem = new ModelCardQueryItem(); |
| 44 | + notFoundItem.setModelName("not-found"); |
| 45 | + request.addQueriesItem(queryItem); |
| 46 | + request.addQueriesItem(notFoundItem); |
| 47 | + |
| 48 | + List<ListModelCardResponse> responses = |
| 49 | + given() |
| 50 | + .contentType("application/json") |
| 51 | + .when() |
| 52 | + .body(request) |
| 53 | + .post("/api/v4/model-cards") |
| 54 | + .then() |
| 55 | + .statusCode(200) |
| 56 | + .extract() |
| 57 | + .body() |
| 58 | + .jsonPath() |
| 59 | + .getList(".", ListModelCardResponse.class); |
| 60 | + |
| 61 | + assertNotNull(responses); |
| 62 | + assertEquals(1, responses.size()); // Only one should be found |
| 63 | + } |
| 64 | + |
| 65 | + @Test |
| 66 | + public void testGetModelCard() { |
| 67 | + given() |
| 68 | + .when() |
| 69 | + .get("/api/v4/model-cards/550e8400-e29b-41d4-a716-446655440004") |
| 70 | + .then() |
| 71 | + .statusCode(200); |
| 72 | + } |
| 73 | + |
| 74 | + @Test |
| 75 | + public void testGetModelCard_NotFound() { |
| 76 | + given() |
| 77 | + .when() |
| 78 | + .get("/api/v4/model-cards/550e8400-e29b-41d4-a716-446655440007") |
| 79 | + .then() |
| 80 | + .statusCode(404); |
| 81 | + } |
| 82 | +} |
0 commit comments