3 * Copyright (C) 2009-2016 SonarSource SA
4 * mailto:contact AT sonarsource DOT com
6 * This program is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public
8 * License as published by the Free Software Foundation; either
9 * version 3 of the License, or (at your option) any later version.
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Lesser General Public License for more details.
16 * You should have received a copy of the GNU Lesser General Public License
17 * along with this program; if not, write to the Free Software Foundation,
18 * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
20 package org.sonar.api.ce.posttask;
22 import org.junit.Rule;
23 import org.junit.Test;
24 import org.junit.rules.ExpectedException;
26 import static org.assertj.core.api.Assertions.assertThat;
28 public class CeTaskBuilder_PostProjectAnalysisTaskTesterTest {
29 private static final CeTask.Status SOME_STATUS = CeTask.Status.SUCCESS;
30 private static final String SOME_ID = "some id";
33 public ExpectedException expectedException = ExpectedException.none();
35 private PostProjectAnalysisTaskTester.CeTaskBuilder underTest = PostProjectAnalysisTaskTester.newCeTaskBuilder();
38 public void setId_throws_NPE_if_id_is_null() {
39 expectedException.expect(NullPointerException.class);
40 expectedException.expectMessage("id can not be null");
42 underTest.setId(null);
46 public void setStatus_throws_NPE_if_status_is_null() {
47 expectedException.expect(NullPointerException.class);
48 expectedException.expectMessage("status can not be null");
50 underTest.setStatus(null);
54 public void build_throws_NPE_if_id_is_null() {
55 underTest.setStatus(SOME_STATUS);
57 expectedException.expect(NullPointerException.class);
58 expectedException.expectMessage("id can not be null");
64 public void build_throws_NPE_if_status_is_null() {
65 underTest.setId(SOME_ID);
67 expectedException.expect(NullPointerException.class);
68 expectedException.expectMessage("status can not be null");
74 public void build_returns_new_instance_at_each_call() {
75 underTest.setId(SOME_ID).setStatus(SOME_STATUS);
77 assertThat(underTest.build()).isNotSameAs(underTest.build());
81 public void verify_getters() {
82 CeTask ceTask = underTest.setId(SOME_ID).setStatus(SOME_STATUS).build();
84 assertThat(ceTask.getId()).isEqualTo(SOME_ID);
85 assertThat(ceTask.getStatus()).isEqualTo(SOME_STATUS);
89 public void verify_toString() {
90 assertThat(underTest.setId(SOME_ID).setStatus(SOME_STATUS).build().toString()).isEqualTo("CeTask{id='some id', status=SUCCESS}");