1 package org.apache.archiva.rest.services;
3 * Licensed to the Apache Software Foundation (ASF) under one
4 * or more contributor license agreements. See the NOTICE file
5 * distributed with this work for additional information
6 * regarding copyright ownership. The ASF licenses this file
7 * to you under the Apache License, Version 2.0 (the
8 * "License"); you may not use this file except in compliance
9 * with the License. You may obtain a copy of the License at
11 * 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 org.apache.archiva.rest.api.model.FileType;
22 import org.apache.archiva.rest.api.model.LegacyArtifactPath;
23 import org.junit.Test;
25 import java.util.Arrays;
28 * @author Olivier Lamy
30 public class ArchivaAdministrationServiceTest
31 extends AbstractArchivaRestTest
34 public void getAllLegacyPaths()
37 assertNotNull( getArchivaAdministrationService().getLegacyArtifactPaths() );
38 assertFalse( getArchivaAdministrationService().getLegacyArtifactPaths().isEmpty() );
42 public void addAndDeleteLegacyPath()
45 int initialSize = getArchivaAdministrationService().getLegacyArtifactPaths().size();
46 LegacyArtifactPath legacyArtifactPath = new LegacyArtifactPath();
47 legacyArtifactPath.setArtifact( "foo" );
48 legacyArtifactPath.setPath( "bar" );
49 getArchivaAdministrationService().addLegacyArtifactPath( legacyArtifactPath );
50 assertEquals( initialSize + 1, getArchivaAdministrationService().getLegacyArtifactPaths().size() );
52 getArchivaAdministrationService().deleteLegacyArtifactPath( "bar" );
53 assertEquals( initialSize, getArchivaAdministrationService().getLegacyArtifactPaths().size() );
57 public void addAndDeleteFileType()
60 int initialSize = getArchivaAdministrationService().getFileTypes().size();
61 FileType fileType = new FileType();
62 fileType.setId( "footwo" );
63 fileType.setPatterns( Arrays.asList( "foo", "bar" ) );
64 getArchivaAdministrationService().addFileType( fileType );
65 assertEquals( initialSize + 1, getArchivaAdministrationService().getFileTypes().size() );
67 assertNotNull( getArchivaAdministrationService().getFileType( "footwo" ) );
68 assertEquals( Arrays.asList( "foo", "bar" ),
69 getArchivaAdministrationService().getFileType( "footwo" ).getPatterns() );
71 getArchivaAdministrationService().removeFileType( "footwo" );
73 assertEquals( initialSize , getArchivaAdministrationService().getFileTypes().size() );
75 assertNull( getArchivaAdministrationService().getFileType( "footwo" ) );