From 6b2b041383ff5cded872faa0828219b81485fd4d Mon Sep 17 00:00:00 2001 From: Evgeny Mandrikov Date: Wed, 18 Jan 2012 16:23:09 +0400 Subject: SONAR-3179 Add API to define resources --- .../ui/ResourceDefinitionRepositoryTest.java | 40 ++++++++++++++++++++++ 1 file changed, 40 insertions(+) create mode 100644 sonar-server/src/test/java/org/sonar/server/ui/ResourceDefinitionRepositoryTest.java (limited to 'sonar-server/src/test/java') diff --git a/sonar-server/src/test/java/org/sonar/server/ui/ResourceDefinitionRepositoryTest.java b/sonar-server/src/test/java/org/sonar/server/ui/ResourceDefinitionRepositoryTest.java new file mode 100644 index 00000000000..a182f96b2ae --- /dev/null +++ b/sonar-server/src/test/java/org/sonar/server/ui/ResourceDefinitionRepositoryTest.java @@ -0,0 +1,40 @@ +/* + * Sonar, open source software quality management tool. + * Copyright (C) 2008-2012 SonarSource + * mailto:contact AT sonarsource DOT com + * + * Sonar is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 3 of the License, or (at your option) any later version. + * + * Sonar is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with Sonar; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02 + */ +package org.sonar.server.ui; + +import org.junit.Test; +import org.sonar.api.resources.ResourceDefinition; + +import static org.hamcrest.Matchers.*; +import static org.junit.Assert.assertThat; + +public class ResourceDefinitionRepositoryTest { + + @Test + public void test() { + ResourceDefinition def1 = ResourceDefinition.builder("1").build(); + ResourceDefinition def2 = ResourceDefinition.builder("2").build(); + ResourceDefinitionRepository repository = new ResourceDefinitionRepository(new ResourceDefinition[] {def1, def2}); + assertThat(repository.getAll(), hasItems(def1, def2)); + assertThat(repository.get("1"), is(def1)); + assertThat(repository.get("unknown"), notNullValue()); + } + +} -- cgit v1.2.3