001/* -*- mode: Java; c-basic-offset: 2; indent-tabs-mode: nil; coding: utf-8-unix -*-
002 *
003 * Copyright © 2017-2018 microBean.
004 *
005 * Licensed under the Apache License, Version 2.0 (the "License");
006 * you may not use this file except in compliance with the License.
007 * You may obtain a copy of the License at
008 *
009 *     http://www.apache.org/licenses/LICENSE-2.0
010 *
011 * Unless required by applicable law or agreed to in writing, software
012 * distributed under the License is distributed on an "AS IS" BASIS,
013 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
014 * implied.  See the License for the specific language governing
015 * permissions and limitations under the License.
016 */
017package org.microbean.helm.maven;
018
019import java.io.Serializable; // for javadoc only
020
021import java.util.EventObject; // for javadoc only
022import java.util.Objects;
023
024import hapi.services.tiller.Tiller.TestReleaseResponseOrBuilder;
025
026/**
027 * An {@link AbstractReleaseEvent} describing the result of running a
028 * test on a <a href="https://docs.helm.sh/glossary/#release">Helm
029 * release</a>.
030 *
031 * @author <a href="https://about.me/lairdnelson"
032 * target="_parent">Laird Nelson</a>
033 *
034 * @see ReleaseTestListener
035 *
036 * @see TestReleaseMojo
037 */
038public class ReleaseTestEvent extends AbstractReleaseEvent {
039
040
041  /*
042   * Static fields.
043   */
044
045
046  /**
047   * The version of this class for {@linkplain Serializable
048   * serialization} purposes.
049   */
050  private static final long serialVersionUID = 1L;
051
052
053  /*
054   * Instance fields.
055   */
056
057
058  /**
059   * The {@link
060   * hapi.services.tiller.Tiller.TestReleaseResponseOrBuilder}
061   * describing the test run.
062   *
063   * <p>This field will never be {@code null}.</p>
064   *
065   * @see #ReleaseTestEvent(TestReleaseMojo,
066   * hapi.services.tiller.Tiller.TestReleaseResponseOrBuilder)
067   */
068  private final TestReleaseResponseOrBuilder testReleaseResponseOrBuilder;
069
070
071  /*
072   * Constructors.
073   */
074
075
076  /**
077   * Creates a new {@link ReleaseTestEvent}.
078   *
079   * @param source the {@link TestReleaseMojo} responsible for running
080   * the tests; must not be {@code null}
081   *
082   * @param testReleaseResponseOrBuilder the {@link
083   * hapi.services.tiller.Tiller.TestReleaseResponseOrBuilder}
084   * describing the test run; must not be {@code null}
085   *
086   * @exception IllegalArgumentException if {@code source} is {@code
087   * null}; thrown by the {@link EventObject#EventObject(Object)}
088   * constructor
089   *
090   * @exception NullPointerException if {@code
091   * testReleaseResponseOrBuilder} is {@code null}
092   */
093  public ReleaseTestEvent(final TestReleaseMojo source, final TestReleaseResponseOrBuilder testReleaseResponseOrBuilder) {
094    super(source);
095    Objects.requireNonNull(testReleaseResponseOrBuilder);
096    this.testReleaseResponseOrBuilder = testReleaseResponseOrBuilder;
097  }
098
099
100  /*
101   * Instance methods.
102   */
103
104
105  /**
106   * Returns the {@link
107   * hapi.services.tiller.Tiller.TestReleaseResponseOrBuilder}
108   * implementation representing the test run.
109   *
110   * <p>This method never returns {@code null}.</p>
111   *
112   * @return the {@link
113   * hapi.services.tiller.Tiller.TestReleaseResponseOrBuilder}
114   * implementation representing the test run; never {@code null}
115   */
116  public final TestReleaseResponseOrBuilder getTestReleaseResponseOrBuilder() {
117    return this.testReleaseResponseOrBuilder;
118  }
119
120  /**
121   * Returns the {@link TestReleaseMojo} responsible for firing this
122   * event.
123   *
124   * <p>This method never returns {@code null}.</p>
125   *
126   * @return the {@link TestReleaseMojo} responsible for firing this
127   * event; never {@code null}
128   */
129  @Override
130  public final TestReleaseMojo getSource() {
131    return (TestReleaseMojo)super.getSource();
132  }
133  
134}