1 package org.apache.archiva.rest.v2.svc;
4 * Licensed to the Apache Software Foundation (ASF) under one
5 * or more contributor license agreements. See the NOTICE file
6 * distributed with this work for additional information
7 * regarding copyright ownership. The ASF licenses this file
8 * to you under the Apache License, Version 2.0 (the
9 * "License"); you may not use this file except in compliance
10 * with the License. You may obtain a copy of the License at
12 * http://www.apache.org/licenses/LICENSE-2.0
13 * Unless required by applicable law or agreed to in writing,
14 * software distributed under the License is distributed on an
15 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16 * KIND, either express or implied. See the License for the
17 * specific language governing permissions and limitations
21 import io.restassured.path.json.JsonPath;
22 import io.restassured.response.Response;
23 import org.apache.archiva.rest.api.v2.model.MavenManagedRepository;
24 import org.apache.archiva.rest.api.v2.svc.RestConfiguration;
25 import org.junit.jupiter.api.AfterAll;
26 import org.junit.jupiter.api.BeforeAll;
27 import org.junit.jupiter.api.DisplayName;
28 import org.junit.jupiter.api.MethodOrderer;
29 import org.junit.jupiter.api.Order;
30 import org.junit.jupiter.api.Tag;
31 import org.junit.jupiter.api.Test;
32 import org.junit.jupiter.api.TestInstance;
33 import org.junit.jupiter.api.TestMethodOrder;
35 import java.util.List;
37 import static io.restassured.RestAssured.given;
38 import static io.restassured.http.ContentType.JSON;
39 import static org.junit.jupiter.api.Assertions.*;
42 * @author Martin Stockhammer <martin_s@apache.org>
44 @TestInstance( TestInstance.Lifecycle.PER_CLASS )
46 @TestMethodOrder( MethodOrderer.OrderAnnotation.class )
47 @DisplayName( "Native REST tests for V2 ManagedRepositoryService" )
48 public class NativeMavenManagedRepositoryServiceTest extends AbstractNativeRestServices
51 protected String getServicePath( )
53 return "/repositories/maven/managed";
57 void setup( ) throws Exception
63 void destroy( ) throws Exception
65 super.shutdownNative( );
70 void testGetRepositories( )
72 String token = getAdminToken( );
73 Response response = given( ).spec( getRequestSpec( token ) ).contentType( JSON )
76 .then( ).statusCode( 200 ).extract( ).response( );
77 JsonPath json = response.getBody( ).jsonPath( );
78 assertEquals( 2, json.getInt( "pagination.total_count" ) );
79 assertEquals( 0, json.getInt( "pagination.offset" ) );
80 assertEquals( Integer.valueOf( RestConfiguration.DEFAULT_PAGE_LIMIT ), json.getInt( "pagination.limit" ) );
81 List<MavenManagedRepository> repositories = json.getList( "data", MavenManagedRepository.class );
82 assertEquals( "internal", repositories.get( 0 ).getId( ) );
83 assertEquals( "snapshots", repositories.get( 1 ).getId( ) );