From 7a0aa306e3971891f9e3bbb8bd1037d8d02f3516 Mon Sep 17 00:00:00 2001 From: David Gageot Date: Mon, 24 Sep 2012 13:38:18 +0200 Subject: SONAR-3529 API: ability to define property sets --- .../server/startup/RegisterPropertySetsTest.java | 55 ++++++++++++++++++++++ 1 file changed, 55 insertions(+) create mode 100644 sonar-server/src/test/java/org/sonar/server/startup/RegisterPropertySetsTest.java (limited to 'sonar-server/src/test') diff --git a/sonar-server/src/test/java/org/sonar/server/startup/RegisterPropertySetsTest.java b/sonar-server/src/test/java/org/sonar/server/startup/RegisterPropertySetsTest.java new file mode 100644 index 00000000000..b74d1b8eb54 --- /dev/null +++ b/sonar-server/src/test/java/org/sonar/server/startup/RegisterPropertySetsTest.java @@ -0,0 +1,55 @@ +/* + * 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.startup; + +import org.junit.Before; +import org.junit.Test; +import org.sonar.api.config.PropertySet; +import org.sonar.api.config.PropertySetDefinitions; +import org.sonar.api.config.PropertySetTemplate; + +import static org.mockito.Mockito.*; + +public class RegisterPropertySetsTest { + private RegisterPropertySets task; + private PropertySetDefinitions propertySetDefinitions = mock(PropertySetDefinitions.class); + private PropertySetTemplate firstTemplate = mock(PropertySetTemplate.class); + private PropertySetTemplate secondTemplate = mock(PropertySetTemplate.class); + private PropertySet firstPropertySet = mock(PropertySet.class); + private PropertySet secondPropertySet = mock(PropertySet.class); + + @Before + public void init() { + task = new RegisterPropertySets(new PropertySetTemplate[]{firstTemplate, secondTemplate}, propertySetDefinitions); + } + + @Test + public void should_register_on_startup() { + when(firstTemplate.getName()).thenReturn("first"); + when(secondTemplate.getName()).thenReturn("second"); + when(firstTemplate.createPropertySet()).thenReturn(firstPropertySet); + when(secondTemplate.createPropertySet()).thenReturn(secondPropertySet); + + task.start(); + + verify(propertySetDefinitions).register("first", firstPropertySet); + verify(propertySetDefinitions).register("second", secondPropertySet); + } +} -- cgit v1.2.3