bdfd31ef2dc5b43e5e4fbb2078679b3aec352910
[Sone.git] / src / test / java / net / pterodactylus / sone / fcp / VersionCommandTest.java
1 /*
2  * Sone - VersionCommandTest.java - Copyright © 2013 David Roden
3  *
4  * This program is free software: you can redistribute it and/or modify
5  * it under the terms of the GNU General Public License as published by
6  * the Free Software Foundation, either version 3 of the License, or
7  * (at your option) any later version.
8  *
9  * This program is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12  * GNU General Public License for more details.
13  *
14  * You should have received a copy of the GNU General Public License
15  * along with this program.  If not, see <http://www.gnu.org/licenses/>.
16  */
17
18 package net.pterodactylus.sone.fcp;
19
20 import static net.pterodactylus.sone.fcp.Verifiers.verifyAnswer;
21 import static net.pterodactylus.sone.freenet.fcp.Command.AccessType.DIRECT;
22 import static net.pterodactylus.sone.main.SonePlugin.VERSION;
23 import static org.hamcrest.MatcherAssert.assertThat;
24 import static org.hamcrest.Matchers.is;
25
26 import net.pterodactylus.sone.data.Mocks;
27 import net.pterodactylus.sone.freenet.SimpleFieldSetBuilder;
28 import net.pterodactylus.sone.freenet.fcp.Command.Response;
29
30 import freenet.support.SimpleFieldSet;
31
32 import org.junit.Test;
33
34 /**
35  * Unit test for {@link VersionCommand}.
36  *
37  * @author <a href="mailto:bombe@pterodactylus.net">David ‘Bombe’ Roden</a>
38  */
39 public class VersionCommandTest {
40
41         private final Mocks mocks = new Mocks();
42         private final VersionCommand versionCommand = new VersionCommand(mocks.core);
43
44         @Test
45         public void theCorrectVersionNumberIsReturned() {
46                 SimpleFieldSet versionFieldSet = new SimpleFieldSetBuilder().put("Message", "Version").get();
47                 Response response = versionCommand.execute(versionFieldSet, null, DIRECT);
48                 verifyAnswer(response, "Version");
49                 assertThat(response.getReplyParameters().get("Version"), is(VERSION.toString()));
50         }
51
52 }