1 package org.apache.archiva.rest.services.v2;
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 io.restassured.response.ResponseBody;
24 import org.apache.archiva.components.rest.model.PagedResult;
25 import org.apache.archiva.components.rest.model.PropertyEntry;
26 import org.apache.archiva.rest.api.model.v2.BeanInformation;
27 import org.apache.archiva.rest.api.model.v2.CacheConfiguration;
28 import org.apache.archiva.rest.api.model.v2.LdapConfiguration;
29 import org.apache.archiva.rest.api.model.v2.MavenManagedRepository;
30 import org.apache.archiva.rest.api.services.v2.RestConfiguration;
31 import org.junit.jupiter.api.AfterAll;
32 import org.junit.jupiter.api.BeforeAll;
33 import org.junit.jupiter.api.DisplayName;
34 import org.junit.jupiter.api.MethodOrderer;
35 import org.junit.jupiter.api.Order;
36 import org.junit.jupiter.api.Tag;
37 import org.junit.jupiter.api.Test;
38 import org.junit.jupiter.api.TestInstance;
39 import org.junit.jupiter.api.TestMethodOrder;
41 import java.util.Arrays;
42 import java.util.HashMap;
43 import java.util.List;
46 import static io.restassured.RestAssured.given;
47 import static io.restassured.http.ContentType.JSON;
48 import static org.junit.jupiter.api.Assertions.*;
51 * @author Martin Stockhammer <martin_s@apache.org>
53 @TestInstance( TestInstance.Lifecycle.PER_CLASS )
55 @TestMethodOrder( MethodOrderer.OrderAnnotation.class )
56 @DisplayName( "Native REST tests for V2 ManagedRepositoryService" )
57 public class NativeMavenManagedRepositoryServiceTest extends AbstractNativeRestServices
60 protected String getServicePath( )
62 return "/repositories/maven/managed";
66 void setup( ) throws Exception
72 void destroy( ) throws Exception
74 super.shutdownNative( );
79 void testGetRepositories( )
81 String token = getAdminToken( );
82 Response response = given( ).spec( getRequestSpec( token ) ).contentType( JSON )
85 .then( ).statusCode( 200 ).extract( ).response( );
86 JsonPath json = response.getBody( ).jsonPath( );
87 assertEquals( 2, json.getInt( "pagination.total_count" ) );
88 assertEquals( 0, json.getInt( "pagination.offset" ) );
89 assertEquals( Integer.valueOf( RestConfiguration.DEFAULT_PAGE_LIMIT ), json.getInt( "pagination.limit" ) );
90 List<MavenManagedRepository> repositories = json.getList( "data", MavenManagedRepository.class );
91 assertEquals( "internal", repositories.get( 0 ).getId( ) );
92 assertEquals( "snapshots", repositories.get( 1 ).getId( ) );