You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@maven.apache.org by GitBox <gi...@apache.org> on 2018/06/15 08:09:36 UTC

[GitHub] cardil commented on a change in pull request #112: Adding support for externally passed random seed and printing used seed on console

cardil commented on a change in pull request #112: Adding support for externally passed random seed and printing used seed on console
URL: https://github.com/apache/maven-surefire/pull/112#discussion_r195660396
 
 

 ##########
 File path: surefire-api/src/main/java/org/apache/maven/surefire/util/RunOrders.java
 ##########
 @@ -0,0 +1,103 @@
+package org.apache.maven.surefire.util;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+import javax.annotation.ParametersAreNonnullByDefault;
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.List;
+
+/**
+ * Represents a complete set of run orders with arguments
+ *
+ * @author <a href="krzysztof.suszynski@wavesoftware.pl">Krzysztof SuszyƄski</a>
+ */
+@ParametersAreNonnullByDefault
+public final class RunOrders
+{
+    private final List<RunOrderWithArguments> withArguments;
+
+    public RunOrders( RunOrder... runOrders )
+    {
+        this( withEmptyArguments( runOrders ) );
+    }
+
+    RunOrders( List<RunOrderWithArguments> runOrders )
+    {
+        this.withArguments = Collections.unmodifiableList( runOrders );
+    }
+
+    public Iterable<RunOrderWithArguments> getIterable()
+    {
+        return withArguments;
+    }
+
+    public boolean any()
+    {
+        return !withArguments.isEmpty();
+    }
+
+    public boolean contains( RunOrder runOrder )
+    {
+        for ( RunOrderWithArguments order : withArguments )
+        {
+            if ( order.getRunOrder().equals( runOrder ) )
+            {
+                return true;
+            }
+        }
+        return false;
+    }
+
+    public RunOrderArguments getArguments( RunOrder runOrder )
+    {
+        for ( RunOrderWithArguments order : withArguments )
+        {
+            if ( order.getRunOrder().equals( runOrder ) )
+            {
+                return order.getRunOrderArguments();
+            }
+        }
+        throw new IllegalStateException( "20180524:221004 - check if contains specific run "
+                + "order before using getArguments" );
+    }
+
+    RunOrder firstAsType()
+    {
+        if ( !any() )
+        {
+            throw new IllegalStateException(
+                    "20180524:222348 - use #any() method before invoking #firstAsType() method."
 
 Review comment:
   Oh. It is exception id. A randomly unique generated id that can be easily traced to the place of it's origin. Its only intended for developer bugs, not end user error communication. Its here: https://github.com/wavesoftware/java-eid-exceptions
   
   I use this convention so this slipped. I can remove it.

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services