text:
<?php
	// set or read cookie
	if (!isset($_COOKIE["labelingsystem-menulang"])) {
		// set cookie "labelingsystem-menulang" with default language
		GlobalVariables::$menuLanguage = "de";
		setcookie("labelingsystem-menulang",GlobalVariables::$menuLanguage,time() + 60*60*24*360*20); // Cookie erlischt in 20 Jahren
	} else {
		// read cookie
		GlobalVariables::$menuLanguage = $_COOKIE["labelingsystem-menulang"];
	}

	// language change with form
	if (isset($_POST["menulanguage-select"])) {
		// read language out of form and rewrite cookie
		GlobalVariables::$menuLanguage = $_POST["menulanguage-select"];
		setcookie("labelingsystem-menulang",GlobalVariables::$menuLanguage,time() + 60*60*24*360*20); // Cookie erlischt in 20 Jahren
	}

	if (!isset($_COOKIE["labelingsystem-preflang"])) {
		// set cookie "labelingsystem-preflang" with default language
		GlobalVariables::$prefLanguage = "de";
		setcookie("labelingsystem-preflang",GlobalVariables::$prefLanguage,time() + 60*60*24*360*20); // Cookie erlischt in 20 Jahren
	} else {
		// read cookie
		GlobalVariables::$prefLanguage = $_COOKIE["labelingsystem-preflang"];
	}

	// language change with form
	if (isset($_POST["preflanguage-select"])) {
		// read language out of form and rewrite cookie
		GlobalVariables::$prefLanguage = $_POST["preflanguage-select"];
		setcookie("labelingsystem-preflang",GlobalVariables::$prefLanguage,time() + 60*60*24*360*20); // Cookie erlischt in 20 Jahren
	}
?>


text:
package org.springframework.mail.javamail;

import org.junit.jupiter.api.Test;

import static org.assertj.core.api.Assertions.assertThat;
import static org.assertj.core.api.Assertions.assertThatIllegalArgumentException;

/**
 * @author Brian Hanafee
 * @author Sam Brannen
 * @since 09.07.2005
 */
public class InternetAddressEditorTests {

	private static final String EMPTY = "";
	private static final String SIMPLE = "nobody@nowhere.com";
	private static final String BAD = "(";

	private final InternetAddressEditor editor = new InternetAddressEditor();

	@Test
	public void uninitialized() {
		assertThat(editor.getAsText()).as("Uninitialized editor did not return empty value string").isEqualTo(EMPTY);
	}

	@Test
	public void setNull() {
		editor.setAsText(null);
		assertThat(editor.getAsText()).as("Setting null did not result in empty value string").isEqualTo(EMPTY);
	}

	@Test
	public void setEmpty() {
		editor.setAsText(EMPTY);
		assertThat(editor.getAsText()).as("Setting empty string did not result in empty value string").isEqualTo(EMPTY);
	}

	@Test
	public void allWhitespace() {
		editor.setAsText(" ");
		assertThat(editor.getAsText()).as("All whitespace was not recognized").isEqualTo(EMPTY);
	}

	@Test
	public void simpleGoodAddress() {
		editor.setAsText(SIMPLE);
		assertThat(editor.getAsText()).as("Simple email address failed").isEqualTo(SIMPLE);
	}

	@Test
	public void excessWhitespace() {
		editor.setAsText(" " + SIMPLE + " ");
		assertThat(editor.getAsText()).as("Whitespace was not stripped").isEqualTo(SIMPLE);
	}

	@Test
	public void simpleBadAddress() {
		assertThatIllegalArgumentException().isThrownBy(() ->
				editor.setAsText(BAD));
	}

}

redpajama_set_name: RedPajamaGithub


text:
package com.google.cloud.spark.bigquery.v2.context;

import java.io.IOException;

public interface InputPartitionReaderContext<T> {

  boolean next() throws IOException;

  T get();

  void close() throws IOException;
}


text:
#ifndef DATAFORMATTER_H_
#define DATAFORMATTER_H_
#include "TembooGlobal.h"
#include "ChoreoInputSet.h"
#include "ChoreoOutputSet.h"
#include "ChoreoPreset.h"
#include "ChoreoInputFormatter.h"
#include "ChoreoOutputFormatter.h"
#include "ChoreoPresetFormatter.h"

class DataFormatter {

    public:
        DataFormatter(const ChoreoInputSet* inputSet, const ChoreoOutputSet* outputSet, const ChoreoPreset* preset);
        bool hasNext();
        char next();
        void reset();

    private:
        const ChoreoInputSet* m_inputSet;
        const ChoreoOutputSet* m_outputSet;
        const ChoreoPreset* m_preset;

        ChoreoInputFormatter m_inputFormatter;
        ChoreoOutputFormatter m_outputFormatter;
        ChoreoPresetFormatter m_presetFormatter;

        enum State {
            DATA_START,
            FORMATTING_INPUTS,
            FORMATTING_OUTPUTS,
            FORMATTING_PRESET,
            FORMATTING_EMPTY,
            DATA_END
        };

        State m_nextState;

};
#endif


text:
package opmap.model.application;

import java.io.Serializable;
import java.util.HashSet;
import java.util.Objects;
import java.util.Set;
import java.util.function.Function;

import opmap.model.application.OPRole;
import opmap.model.architecture.EXNode;

public class OPNode implements Comparable<OPNode>, Serializable {

	private static final long serialVersionUID = -8266724889784176862L;

	private int id;
	private OPRole role;
	private String name;
	private Function<Double, Double> transformation;
	private int resources;
	private double speed;
	private double flowIn;
	private double flowOut;
	private Set<Integer> pinnables;
	private boolean alwaysPinnable;

	public OPNode(final int id, final OPRole role, final String name, final Function<Double, Double> transformation,
			   	  final int resources, final double speed) {
		this.setId(id);
		this.setRole(role);
		this.setName(name);
		this.setTransformation(transformation);
		this.setResources(resources);
		this.setSpeed(speed);
		this.setPinnables(new HashSet<Integer>());
		this.setAlwaysPinnable(true);

		if (this.isSource())
			this.setFlowOut(this.getTransformation().apply(0.0));
		else if (this.isSink())
			this.setFlowOut(0);
	}

	public int getId() {
		return this.id;
	}

	private void setId(final int id) {
		this.id = id;
	}

	public OPRole getRole() {
		return this.role;
	}

	private void setRole(final OPRole role) {
		this.role = role;
	}

	public String getName() {
		return this.name;
	}

	private void setName(final String name) {
		this.name = name;
	}

	public Function<Double, Double> getTransformation() {
		return this.transformation;
	}

	private void setTransformation(final Function<Double, Double> transformation) {
		this.transformation = transformation;
	}

	public int getResources() {
		return this.resources;
	}

	public void setResources(final int resources) {
		this.resources = resources;
	}

	public double getSpeed() {
		return this.speed;
	}

	public void setSpeed(final double speed) {
		this.speed = speed;
	}

	public double getFlowIn() {
		return this.flowIn;
	}

	public void setFlowIn(final double flowIn) {
		this.flowIn = flowIn;
		this.flowOut = this.transformation.apply(this.flowIn);
	}

	public double getFlowOut() {
		return this.flowOut;
	}

	public void setFlowOut(final double flowOut) {
		this.flowOut = flowOut;
	}

	public Set<Integer> getPinnables() {
		return this.pinnables;
	}

	public void setPinnables(final Set<Integer> pinnables) {
		this.pinnables = pinnables;
	}

	public boolean addPinnable(final int exnodeid) {
		this.alwaysPinnable = false;
		return this.pinnables.add(exnodeid);
	}

	public boolean addPinnable(final EXNode exnode) {
		return this.addPinnable(exnode.getId());
	}

	public void setAlwaysPinnable(final boolean alwaysPinnable) {
		this.alwaysPinnable = alwaysPinnable;
	}

	public boolean isSource() {
		return this.getRole().equals(OPRole.SRC);
	}

	public boolean isSink() {
		return this.getRole().equals(OPRole.SNK);
	}

	public boolean isPipe() {
		return this.getRole().equals(OPRole.PIP);
	}

	public boolean isAlwaysPinnable() {
		return this.alwaysPinnable;
	}

	public void addFlowIn(final double flow) {
		this.setFlowIn(this.getFlowIn() + flow);
	}

	public boolean isPinnableOn(final EXNode exnode) {
		if (this.isAlwaysPinnable())
			return true;
		else
			return this.pinnables.contains(exnode.getId());
	}

	@Override
	public boolean equals(Object obj) {
		if (this.getClass() != obj.getClass())
			return false;

		OPNode other = (OPNode) obj;

		return (this.getId() == other.getId());
	}

	@Override
	public int compareTo(OPNode other) {
		return Integer.valueOf(this.getId()).compareTo(other.getId());
	}

	public String toPrettyString() {
		String str = String.format("#opnode# id:%d|opr:%s|role:%s|resources:%d|speed:%.5f:fIn:%.5f|fOut:%.5f|pinnables:%s",
				this.getId(),
				this.getName(),
				this.getRole(),
				this.getResources(),
				this.getSpeed(),
				this.getFlowIn(),
				this.getFlowOut(),
				this.isAlwaysPinnable()?"every":this.getPinnables());

		return str;
	}

	@Override
	public String toString() {
		String str = String.format("OPNode(id:%d|opr:%s|role:%s|resources:%d|speed:%f:fIn:%f|fOut:%f|pinnables:%s)",
				this.getId(),
				this.getName(),
				this.getRole(),
				this.getResources(),
				this.getSpeed(),
				this.getFlowIn(),
				this.getFlowOut(),
				this.isAlwaysPinnable()?"every":this.getPinnables());

		return str;
	}

	@Override
	public int hashCode() {
		return Objects.hash(this.getId());
	}

}


text:
class CreateUsers < ActiveRecord::Migration
  def change
    create_table :users do |t|
      t.string :first_name
      t.string :last_name
      t.string :email_address
      t.string :location
      t.boolean :active

      t.timestamps
    end
  end
end


text:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">

<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Uses of Package org.apache.taverna.download (Apache Taverna OSGi plugin system 0.2.1-incubating API)</title>
<meta name="date" content="2016-03-14">
<link rel="stylesheet" type="text/css" href="../../../../stylesheet.css" title="Style">

JavaScript is disabled on your browser.

Skip navigation links

Overview

Package

Class

Use

Tree

Deprecated

Index

Help

Prev

Next

Frames

No Frames

All Classes

Uses of Package
org.apache.taverna.download

Packages that use org.apache.taverna.download

Package
Description

org.apache.taverna.download

org.apache.taverna.download.impl

org.apache.taverna.plugin.impl

org.apache.taverna.update.impl

Classes in org.apache.taverna.download used by org.apache.taverna.download

Class and Description

DownloadException

Classes in org.apache.taverna.download used by org.apache.taverna.download.impl

Class and Description

DownloadException

DownloadManager

Download Manager for handling file download and checking the integrity of the download.

Classes in org.apache.taverna.download used by org.apache.taverna.plugin.impl

Class and Description

DownloadManager

Download Manager for handling file download and checking the integrity of the download.

Classes in org.apache.taverna.download used by org.apache.taverna.update.impl

Class and Description

DownloadManager

Download Manager for handling file download and checking the integrity of the download.

Skip navigation links

Overview

Package

Class

Use

Tree

Deprecated

Index

Help

Prev

Next

Frames

No Frames

All Classes

Copyright © 2015–2016 The Apache Software Foundation. All rights reserved.


text:
using System;
using FluentDate;
using FluentDateTimeOffset;
using GitVersion;
using LibGit2Sharp;
using NUnit.Framework;
using ObjectApproval;

[TestFixture]
public class VersionOnMasterFinderTests
{
    [Test]
    public void Should_find_previous_commit_that_was_at_least_a_minor_bump()
    {
        var finder = new VersionOnMasterFinder();

        var dateTime = new DateTimeOffset(2000, 10, 10,0,0,0,new TimeSpan(0));
        var signature = 2.Seconds().Before(dateTime).ToSignature();

        const string sha = "deadbeefdeadbeefdeadbeefdeadbeefdeadbeef";

        var version = finder.Execute(new GitVersionContext
        {
            Repository = new MockRepository
            {
                Branches = new MockBranchCollection
                {
                    new MockBranch("master")
                    {
                        new MockMergeCommit(new ObjectId(sha))
                        {
                            MessageEx = "Merge branch 'hotfix-0.3.0'",
                            CommitterEx = signature
                        },
                        new MockMergeCommit
                        {
                            MessageEx = "Merge branch 'hotfix-0.3.1'",
                            CommitterEx = signature,
                        },
                        new MockMergeCommit
                        {
                            MessageEx = "Merge branch 'hotfix-0.2.0'",
                            CommitterEx = signature
                        },
                    },
                }
            }
        }, 1.Seconds().Ago());
        ObjectApprover.VerifyWithJson(version);
    }
}


text:
layout: wiki
title: Tell
---
.


text:
class HollowTerra1 : public DefaultPlaneSimplexNoise3D
{
//DECLARE_TYPE(HollowTerra1)
public:
	virtual const char* shortName() const { return "hollow1"; }

	SphereVoxMap defaultSphere;
	DefaultPlaneSimplexNoise3D hmap;

	HollowTerra1()
	{
		defaultSphere.r = 4000.0f;
		defaultSphere.ox = 0.0f;
		defaultSphere.oy = defaultSphere.r+yGround;
		defaultSphere.oz = 0.0f;

		hmap.octaves = 2;
		hmap.wavelength = 400.0f;
		hmap.yThickness = 60.0f;
		hmap.ampScale = 0.5f;
		hmap.freqScale = 1.9f;
		hmap.ridged = true;

		octaves = 3;
		wavelength = 48.0f;
	}

	//virtual void describeParameters( ParameterDictionary& params )
	//{
	//	params.beginGroup("hmap");
	//	hmap.describeParameters(params);
	//	params.endGroup();

	//	DefaultPlaneSimplexNoise3D::describeParameters(params);
	//}

	virtual float getValueF(float x, float y, float z) const
	{
		static const float kx = 100;
		static const float ky = 200;
		static const float kz = 300;

		float dx = defaultSphere.ox - x;
		float dy = defaultSphere.oy - y;
		float dz = defaultSphere.oz - z;
		float d = sqrtf(dx*dx+dy*dy+dz*dz);

		float yy = defaultSphere.r-d;

		float a = 1.0f;
		float denom = std::max(0.0000001f, d * hmap.wavelength);
		dx *= defaultSphere.r/denom;
		dy *= defaultSphere.r/denom;
		dz *= defaultSphere.r/denom;

		float yLo = hmap.f(dx,dy,dz, 6);
		float yground = yLo * hmap.yThickness;
		float t = -(yy - float(yground)) / hmap.yThickness;

		return (t+1.0f)*0.5f;
	}
 };


text:
var should = require('should'),
    needle = require('./../'),
    http   = require('http'),
    zlib   = require('zlib'),
    stream = require('stream'),
    port   = 11123,
    server;

describe('compression', function(){

  require.bind(null, 'zlib').should.not.throw()

  var jsonData = '{"foo":"bar"}';

  describe('when server supports compression', function(){

    before(function(){
      server = http.createServer(function(req, res) {
        var raw = new stream.PassThrough();

        var acceptEncoding = req.headers['accept-encoding'];
        if (!acceptEncoding) {
          acceptEncoding = '';
        }

        if (acceptEncoding.match(/\bdeflate\b/)) {
          res.setHeader('Content-Encoding', 'deflate');
          raw.pipe(zlib.createDeflate()).pipe(res);
        } else if (acceptEncoding.match(/\bgzip\b/)) {
          res.setHeader('Content-Encoding', 'gzip');
          raw.pipe(zlib.createGzip()).pipe(res);
        } else if (acceptEncoding.match(/\bbr\b/)) {
          res.setHeader('Content-Encoding', 'br');
          raw.pipe(zlib.createBrotliCompress()).pipe(res);
        } else {
          raw.pipe(res);
        }

        res.setHeader('Content-Type', 'application/json')
        if (req.headers['with-bad']) {
          res.end('foo'); // end, no deflate data
        } else {
          raw.end(jsonData)
        }

      })

      server.listen(port);
    });

    after(function(done){
      server.close(done);
    })

    describe('and client requests no compression', function() {
      it('should have the body decompressed', function(done){
        needle.get('localhost:' + port, function(err, response, body){
          should.ifError(err);
          body.should.have.property('foo', 'bar');
          response.bytes.should.equal(jsonData.length);
          done();
        })
      })
    })

    describe('and client requests gzip compression', function() {
      it('should have the body decompressed', function(done){
        needle.get('localhost:' + port, {headers: {'Accept-Encoding': 'gzip'}}, function(err, response, body){
          should.ifError(err);
          body.should.have.property('foo', 'bar');
          response.bytes.should.not.equal(jsonData.length);
          done();
        })
      })
    })

    describe('and client requests deflate compression', function() {
      it('should have the body decompressed', function(done){
        needle.get('localhost:' + port, {headers: {'Accept-Encoding': 'deflate'}}, function(err, response, body){
          should.ifError(err);
          body.should.have.property('foo', 'bar');
          response.bytes.should.not.equal(jsonData.length);
          done();
        })
      })

      it('should rethrow errors from decompressors', function(done){
        needle.get('localhost:' + port, {headers: {'Accept-Encoding': 'deflate', 'With-Bad': 'true'}}, function(err, response, body) {
          should.exist(err);
          err.message.should.equal("incorrect header check");
          err.code.should.equal("Z_DATA_ERROR")
          done();
        })
      })
    })

    describe('and client requests brotli compression', function() {
      it('should have the body decompressed', function(done){
        // Skip this test if Brotli is not supported
        if (typeof zlib.BrotliDecompress !== 'function') {
          return done();
        }
        needle.get('localhost:' + port, {headers: {'Accept-Encoding': 'br'}}, function(err, response, body){
          should.ifError(err);
          body.should.have.property('foo', 'bar');
          response.bytes.should.not.equal(jsonData.length);
          done();
        })
      })
    })
  })
})


text:
package com.google.j2cl.junit.apt;

import static com.google.common.base.Preconditions.checkState;

import com.google.auto.value.AutoValue;
import com.google.common.collect.ImmutableList;
import java.util.Optional;

/** Represents a JUnit test case. */
@AutoValue
public abstract class TestClass {

  public static Builder builder() {
    return new AutoValue_TestClass.Builder();
  }

  public abstract String packageName();

  public abstract String simpleName();

  public abstract String qualifiedName();

  public abstract TestConstructor testConstructor();

  public abstract ImmutableList<TestMethod> testMethods();

  public abstract ImmutableList<TestMethod> beforeMethods();

  public abstract ImmutableList<TestMethod> afterMethods();

  public abstract ImmutableList<TestMethod> beforeClassMethods();

  public abstract ImmutableList<TestMethod> afterClassMethods();

  public abstract ImmutableList<TestMethod> beforeParamMethods();

  public abstract ImmutableList<TestMethod> afterParamMethods();

  public abstract boolean isJUnit3();

  public abstract Optional<ParameterizedDataMethod> parameterizedDataMethod();

  public abstract ImmutableList<ParameterizedTestField> parameterizedFields();

  public int numberOfTestMethods() {
    return testMethods().size();
  }

  public boolean needsAsyncSetup() {
    return beforeMethods().stream().anyMatch(TestMethod::isAsync);
  }

  public boolean needsAsyncTeardown() {
    return afterMethods().stream().anyMatch(TestMethod::isAsync);
  }

  public String jsUnitPackageName() {
    return "javatests." + packageName();
  }

  public String jsUnitAdapterClassName() {
    return simpleName() + "_Adapter";
  }

  public String jsUnitAdapterQualifiedClassName() {
    return jsUnitPackageName() + "." + jsUnitAdapterClassName();
  }

  public String jsUnitQualifiedName() {
    return jsUnitAdapterQualifiedClassName() + "Suite";
  }

  public boolean isParameterized() {
    return parameterizedDataMethod().isPresent();
  }

  /** Builder for TestClass. */
  @AutoValue.Builder
  public abstract static class Builder {

    abstract Builder isJUnit3(boolean i);

    abstract Builder packageName(String s);

    abstract Builder simpleName(String s);

    abstract Builder qualifiedName(String s);

    abstract Builder testConstructor(TestConstructor t);

    abstract Builder testMethods(ImmutableList<TestMethod> t);

    abstract Builder beforeMethods(ImmutableList<TestMethod> t);

    abstract Builder afterMethods(ImmutableList<TestMethod> t);

    abstract Builder beforeClassMethods(ImmutableList<TestMethod> t);

    abstract Builder afterClassMethods(ImmutableList<TestMethod> t);

    abstract Builder beforeParamMethods(ImmutableList<TestMethod> t);

    abstract Builder afterParamMethods(ImmutableList<TestMethod> t);

    abstract Builder parameterizedDataMethod(Optional<ParameterizedDataMethod> t);

    abstract Builder parameterizedFields(ImmutableList<ParameterizedTestField> t);

    abstract TestClass autoBuild();

    public TestClass build() {
      TestClass testClass = autoBuild();
      checkState(
          !testClass.isJUnit3()
              || (testClass.beforeMethods().isEmpty() && testClass.afterMethods().isEmpty()),
          "When marked as JUnit3, beforeMethods and afterMethods should be empty");
      return testClass;
    }
  }
}


text:
<?php
Class m1478236580_feed_date {
  public static function up() {
    Database::query("ALTER TABLE feed ADD feed_timestamp INT UNSIGNED NOT NULL DEFAULT '0' AFTER feed_desc_en");
  }

  public static function down() {
    return false;
  }
}
?>


text:
package io.kimo.lib.faker.api;

public interface AddressAPI {

    String city();
    String street();
    String streetWithNumber();
    String secondaryAddress();
    String buildingNumber();
    String zipCode();
    String postCode();
    String timeZone();
    String citySuffix();
    String cityPrefix();
    String state();
    String stateAbbreviation();
    String country();
    String countryAbbreviation();
    String latitude();
    String longitude();
}


text:
package com.github.grimpy.botifier.receivers;

import android.annotation.TargetApi;
import android.app.Notification;
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.content.IntentFilter;
import android.os.Handler;
import android.os.Message;
import android.service.notification.NotificationListenerService;
import android.service.notification.StatusBarNotification;
import android.util.Log;

import com.github.grimpy.botifier.Botification;
import com.github.grimpy.botifier.NotificationEvents;

@TargetApi(18)
public class BotifierNotificationService extends NotificationListenerService{
	private static String TAG = "Botifier";
    public static String REMOVE_NOTIFICATION = "com.github.grimpy.botifier.REMOVE_NOTIFICATION";
	private Handler mHandler;

    private final BroadcastReceiver mIntentReceiver = new BroadcastReceiver() {
        /**
         * {@inheritDoc}
         */
        @Override
        public void onReceive(final Context context, final Intent intent) {
            Log.d(TAG, "Received action " + intent.getAction());
            if (intent.getAction().equals(NOTIFICATION_SERVICE) ) {
                Botification bot = intent.getParcelableExtra("botification");
                cancelNotification(bot);
            }
        }
    };

	@Override
	public void onCreate() {
		super.onCreate();
		Log.i(TAG, "Manager started");
        final IntentFilter filter = new IntentFilter();
        filter.addAction(REMOVE_NOTIFICATION);
        // Attach the broadcast listener
        registerReceiver(mIntentReceiver, filter);
	    mHandler = new Handler(){
	    	public void handleMessage(Message msg){
	    		String cmd = NotificationEvents.NOTIFICATION_ADDED;
	    		if (msg.arg1 == 1) {
	    			cmd = NotificationEvents.NOTIFICATION_REMOVED;
	    		}
	    		StatusBarNotification stn = (StatusBarNotification)msg.obj;
	    		if (stn == null) {
	    			return;
	    		}
	    		Notification not = stn.getNotification();
	    		if (not == null) {
	    			return;
	    		}
	    		String description = "";
	    		if (not.tickerText != null) {
	    			description = not.tickerText.toString();
	    		}
	    		android.app.Service srv = BotifierNotificationService.this;
	    		String text = Botification.extractTextFromNotification(srv, not);
	    		Botification bot = new Botification(stn.getId(), stn.getPackageName(), stn.getTag(), description, text);
	    		bot.load(BotifierNotificationService.this);
	    		if (bot.isBlackListed() || !bot.isIntresting(not)) {
	    		    return;
	    		}
	    		Intent i = new Intent(cmd);
	    		i.putExtra("botification", bot);
	    		sendBroadcast(i);
		    }
		};
	}

	@Override
	public void onDestroy() {
		super.onDestroy();
	}

	@Override
	public void onNotificationPosted(StatusBarNotification statusnotification) {
		Log.i(TAG, "new notification received");
		Message msg = new Message();
		msg.obj = statusnotification;
		msg.arg1 = 0;
		mHandler.sendMessage(msg);
	}

	@Override
	public void onNotificationRemoved(StatusBarNotification statusnotification) {
		Log.d(TAG, "Cleaning up notifications");
		Message msg = new Message();
		msg.obj = statusnotification;
		msg.arg1 = 1;
		mHandler.sendMessage(msg);
	}

	public void cancelNotification(Botification not){
		cancelNotification(not.mPkg, not.mTag, not.mId);
	}

}


text:
import sys

from builtins import object
from nose.tools import assert_equal, assert_true, assert_false, assert_raises

from desktop.lib.django_test_util import make_logged_in_client
from useradmin.models import User

from notebook.connectors.spark_shell import SparkApi

if sys.version_info[0] > 2:
  from unittest.mock import patch, Mock
else:
  from mock import patch, Mock

class TestSparkApi(object):

  def setUp(self):
    self.client = make_logged_in_client(username="hue_test", groupname="default", recreate=True, is_superuser=False)
    self.user = User.objects.get(username="hue_test")

    self.interpreter = {
        'name': 'livy',
        'options': {
          'api_url': 'http://gethue.com:8998'
        },
      }
    self.api = SparkApi(self.user, self.interpreter)

  def test_get_api(self):
    lang = 'pyspark'
    properties = None

    # with patch('notebook.connectors.spark_shell.get_spark_api') as get_spark_api:
    spark_api = self.api.get_api()
    assert_equal(spark_api.__class__.__name__, 'LivyClient')

  def test_get_livy_props_method(self):
    test_properties = [{
        "name": "files",
        "value": 'file_a,file_b,file_c',
      }]
    props = self.api.get_livy_props('scala', test_properties)
    assert_equal(props['files'], ['file_a', 'file_b', 'file_c'])

  def test_create_session_with_config(self):
    lang = 'pyspark'
    properties = None
    session_key = self.api._get_session_key()

    with patch('notebook.connectors.spark_shell.get_spark_api') as get_spark_api:
      with patch('notebook.connectors.spark_shell.DefaultConfiguration') as DefaultConfiguration:
        with patch('notebook.connectors.spark_shell.USE_DEFAULT_CONFIGURATION') as USE_DEFAULT_CONFIGURATION:
          DefaultConfiguration.objects.get_configuration_for_user.return_value = Mock(
                properties_list=[
                  {'multiple': False, 'name': 'driverCores', 'defaultValue': 1, 'value': 2, 'nice_name': 'Driver Cores',
                   'help_text': 'Number of cores used by the driver, only in cluster mode (Default: 1)', 'type': 'number',
                   'is_yarn': True}]
          )

          get_spark_api.return_value = Mock(
            create_session=Mock(
              return_value={'id': '1'}
            ),
            get_session=Mock(
              return_value={'state': 'idle', 'log': ''}
            )
          )
          # Case with user configuration. Expected 2 driverCores
          USE_DEFAULT_CONFIGURATION.get.return_value = True
          session = self.api.create_session(lang=lang, properties=properties)

          assert_equal(session['type'], 'pyspark')
          assert_equal(session['id'], '1')

          for p in session['properties']:
            if p['name'] == 'driverCores':
              cores = p['value']
          assert_equal(cores, 2)

          if self.api._get_session_info_from_user():
            self.api._remove_session_info_from_user()

          # Case without user configuration. Expected 1 driverCores
          USE_DEFAULT_CONFIGURATION.get.return_value = True
          DefaultConfiguration.objects.get_configuration_for_user.return_value = None
          session2 = self.api.create_session(lang=lang, properties=properties)

          assert_equal(session2['type'], 'pyspark')
          assert_equal(session2['id'], '1')

          for p in session2['properties']:
            if p['name'] == 'driverCores':
              cores = p['value']
          assert_equal(cores, 1)

          # Case with no user configuration. Expected 1 driverCores
          USE_DEFAULT_CONFIGURATION.get.return_value = False
          session3 = self.api.create_session(lang=lang, properties=properties)

          assert_equal(session3['type'], 'pyspark')
          assert_equal(session3['id'], '1')

          for p in session3['properties']:
            if p['name'] == 'driverCores':
              cores = p['value']
          assert_equal(cores, 1)

  def test_create_session_plain(self):
    lang = 'pyspark'
    properties = None
    session_key = self.api._get_session_key()

    with patch('notebook.connectors.spark_shell.get_spark_api') as get_spark_api:
      get_spark_api.return_value = Mock(
        create_session=Mock(
          return_value={'id': '1'}
        ),
        get_session=Mock(
          return_value={'state': 'idle', 'log': ''}
        )
      )

      session = self.api.create_session(lang=lang, properties=properties)

      assert_equal(session['type'], 'pyspark')
      assert_equal(session['id'], '1')

      files_properties = [prop for prop in session['properties'] if prop['name'] == 'files']
      assert_true(files_properties, session['properties'])
      assert_equal(files_properties[0]['value'], [], session['properties'])

  def test_execute(self):
    with patch('notebook.connectors.spark_shell._get_snippet_session') as _get_snippet_session:
      with patch('notebook.connectors.spark_shell.get_spark_api') as get_spark_api:
        notebook = Mock()
        snippet = {'statement': 'select * from test_table'}
        _get_snippet_session.return_value = {'id': '1'}

        get_spark_api.return_value = Mock(
          submit_statement=Mock(
            return_value={'id': 'test_id'}
          )
        )
        self.api._check_session = Mock(return_value={'id': '1'})

        response = self.api.execute(notebook, snippet)
        assert_equal(response['id'], 'test_id')

        get_spark_api.return_value = Mock(
          submit_statement=Mock()
        )
        assert_raises(Exception, self.api.execute, notebook, snippet)

  def test_check_status(self):
    with patch('notebook.connectors.spark_shell._get_snippet_session') as _get_snippet_session:
      with patch('notebook.connectors.spark_shell.get_spark_api') as get_spark_api:
        notebook = Mock()
        snippet = {
          'result': {
            'handle': {
              'id': {'test_id'}
            }
          }
        }
        _get_snippet_session.return_value = {'id': '1'}

        get_spark_api.return_value = Mock(
          fetch_data=Mock(
            return_value={'state': 'test_state'}
          )
        )
        self.api._handle_session_health_check = Mock(return_value={'id': '1'})

        response = self.api.check_status(notebook, snippet)
        assert_equal(response['status'], 'test_state')

        get_spark_api.return_value = Mock(
          submit_statement=Mock()
        )
        assert_raises(Exception, self.api.check_status, notebook, snippet)

  def test_get_sample_data(self):
    snippet = Mock()
    self.api._execute = Mock(
      return_value='test_value'
    )
    self.api.create_session = Mock(
      return_value={
        'id': 'test_id'
      }
    )
    self.api._check_status_and_fetch_result = Mock(
      return_value={
        'data': 'test_data',
        'meta': 'test_meta'
      }
    )

    # When table is transactional
    self.api.describe_table = Mock(
      return_value={
        'stats': [{
          'data_type': 'transactional',
          'col_name': 'true',
          'comment': ''
        }]
      }
    )
    response = self.api.get_sample_data(snippet, 'test_db', 'test_table', 'test_column')

    assert_equal(response['rows'], [])
    assert_equal(response['full_headers'], [])

    # When table is not transactional
    self.api.describe_table = Mock(
      return_value={
        'stats': [] # No details regarding transactionality is present in describe response
      }
    )
    response = self.api.get_sample_data(snippet, 'test_db', 'test_table', 'test_column')

    assert_equal(response['rows'], 'test_data')
    assert_equal(response['full_headers'], 'test_meta')

  def test_get_select_query(self):
    # With operation as 'hello'
    response = self.api._get_select_query('test_db', 'test_table', 'test_column', 'hello')
    assert_equal(response, "SELECT 'Hello World!'")

    # Without column name
    response = self.api._get_select_query('test_db', 'test_table')
    assert_equal(response, 'SELECT *\nFROM test_db.test_table\nLIMIT 100\n')

    # With some column name
    response = self.api._get_select_query('test_db', 'test_table', 'test_column')
    assert_equal(response, 'SELECT test_column\nFROM test_db.test_table\nLIMIT 100\n')

  def test_describe_database(self):
    notebook = Mock()
    snippet = Mock()
    self.api.create_session = Mock(
      return_value={
        'id': 'test_id'
      }
    )
    self.api._execute = Mock(
      return_value='test_value'
    )
    self.api._check_status_and_fetch_result = Mock(
      return_value={
        'data': [
          ['Namespace Name', 'employees'],
          ['Comment', 'For software companies'],
          ['Location', 'hdfs://test_url:8020/warehouse/tablespace/external/hive/employees.db'],
          ['Owner', 'demo'],
          ['Properties', '((Create-by,Kevin), (Create-date,09/01/2019))']],
        'images': [],
        'meta': [
          {'comment': '', 'name': 'info_name', 'type': 'string'},
          {'comment': '', 'name': 'info_value', 'type': 'string'}],
        'type': 'table'}
    )
    response = self.api.describe_database(notebook, snippet, 'employees')

    assert_equal(response, {
      'comment': 'For software companies',
      'db_name': 'employees',
      'location': 'hdfs://test_url:8020/warehouse/tablespace/external/hive/employees.db',
      'owner_name': 'demo',
      'parameters': '{Create-by=Kevin, Create-date=09/01/2019}',
      'status': 0})

  def test_describe_table(self):
    notebook = Mock()
    snippet = Mock()
    self.api.create_session = Mock(
      return_value={
        'id': 'test_id'
      }
    )
    self.api._execute = Mock(
      return_value='test_value'
    )
    self.api._check_status_and_fetch_result = Mock(
      return_value={
        'data': [
          ['nname', 'string', None],
          ['# Partition Information', '', ''],
          ['# col_name', 'data_type', 'comment'],
          ['state', 'string', 'null'],
          ['', '', ''],
          ['# Detailed Table Information', '', ''],
          ['Database', 'default', ''],
          ['Table', 'test_nonacid', ''],
          ['Owner', 'demo', ''],
          ['Created Time', 'Tue Jun 28 11:35:33 UTC 2022', ''],
          ['Last Access', 'UNKNOWN', ''],
          ['Created By', 'Spark 3.3.0.7.2.16.0-94', ''],
          ['Type', 'EXTERNAL', ''],
          ['Provider', 'hive', ''],
          ['Table Properties',
            '[TRANSLATED_TO_EXTERNAL=TRUE, bucketing_version=2, '
            'external.table.purge=TRUE, numFilesErasureCoded=0, '
            'transient_lastDdlTime=1656416152]',
            ''],
          ['Statistics', '6 bytes', ''],
          ['Location',
            'hdfs://test_url:8020/warehouse/tablespace/external/hive/test_nonacid',
            ''],
          ['Serde Library',
            'org.apache.hadoop.hive.serde2.lazy.LazySimpleSerDe',
            ''],
          ['InputFormat', 'org.apache.hadoop.mapred.TextInputFormat', ''],
          ['OutputFormat',
            'org.apache.hadoop.hive.ql.io.HiveIgnoreKeyTextOutputFormat',
            ''],
          ['Storage Properties', '[serialization.format=1]', ''],
          ['Partition Provider', 'Catalog', '']],
        'images': [],
        'meta': [
          {'comment': '', 'name': 'col_name', 'type': 'string'},
          {'comment': '', 'name': 'data_type', 'type': 'string'},
          {'comment': '', 'name': 'comment', 'type': 'string'}],
        'type': 'table'
      }
    )
    response = self.api.describe_table(notebook, snippet, 'default', 'test_nonacid')

    assert_equal(response, {
      'cols': [{'comment': 'None', 'name': 'nname', 'type': 'string'}],
      'comment': '',
      'details': {'properties': {
        'create_time': 'Tue Jun 28 11:35:33 UTC 2022',
        'format': 'text',
        'owner': 'demo',
        'table_type': 'EXTERNAL'},
      'stats': [
        {
          'col_name': 'TRUE',
          'comment': '',
          'data_type': 'TRANSLATED_TO_EXTERNAL'},
        {
          'col_name': '2',
          'comment': '',
          'data_type': 'bucketing_version'},
        {
          'col_name': 'TRUE',
          'comment': '',
          'data_type': 'external.table.purge'},
        {
          'col_name': '0',
          'comment': '',
          'data_type': 'numFilesErasureCoded'},
        {
          'col_name': '1656416152',
          'comment': '',
          'data_type': 'transient_lastDdlTime'}]},
      'hdfs_link': '/filebrowser/view=/warehouse/tablespace/external/hive/test_nonacid',
      'is_view': False,
      'name': 'test_nonacid',
      'partition_keys': [{'name': 'state', 'type': 'string'}],
      'path_location': 'hdfs://test_url:8020/warehouse/tablespace/external/hive/test_nonacid',
      'primary_keys': [],
      'properties': [{'col_name': '# Partition Information',
                      'comment': '',
                      'data_type': ''},
                      {'col_name': '# col_name',
                      'comment': 'comment',
                      'data_type': 'data_type'},
                      {'col_name': 'state', 'comment': 'null', 'data_type': 'string'},
                      {'col_name': '', 'comment': '', 'data_type': ''},
                      {'col_name': '# Detailed Table Information',
                      'comment': '',
                      'data_type': ''},
                      {'col_name': 'Database', 'comment': '', 'data_type': 'default'},
                      {'col_name': 'Table',
                      'comment': '',
                      'data_type': 'test_nonacid'},
                      {'col_name': 'Owner', 'comment': '', 'data_type': 'demo'},
                      {'col_name': 'Created Time',
                      'comment': '',
                      'data_type': 'Tue Jun 28 11:35:33 UTC 2022'},
                      {'col_name': 'Last Access',
                      'comment': '',
                      'data_type': 'UNKNOWN'},
                      {'col_name': 'Created By',
                      'comment': '',
                      'data_type': 'Spark 3.3.0.7.2.16.0-94'},
                      {'col_name': 'Type', 'comment': '', 'data_type': 'EXTERNAL'},
                      {'col_name': 'Provider', 'comment': '', 'data_type': 'hive'},
                      {'col_name': 'Table Properties',
                      'comment': '',
                      'data_type': '[TRANSLATED_TO_EXTERNAL=TRUE, '
                                    'bucketing_version=2, external.table.purge=TRUE, '
                                    'numFilesErasureCoded=0, '
                                    'transient_lastDdlTime=1656416152]'},
                      {'col_name': 'Statistics',
                      'comment': '',
                      'data_type': '6 bytes'},
                      {'col_name': 'Location',
                      'comment': '',
                      'data_type': 'hdfs://test_url:8020/warehouse/tablespace/external/hive/test_nonacid'},
                      {'col_name': 'Serde Library',
                      'comment': '',
                      'data_type': 'org.apache.hadoop.hive.serde2.lazy.LazySimpleSerDe'},
                      {'col_name': 'InputFormat',
                      'comment': '',
                      'data_type': 'org.apache.hadoop.mapred.TextInputFormat'},
                      {'col_name': 'OutputFormat',
                      'comment': '',
                      'data_type': 'org.apache.hadoop.hive.ql.io.HiveIgnoreKeyTextOutputFormat'},
                      {'col_name': 'Storage Properties',
                      'comment': '',
                      'data_type': '[serialization.format=1]'},
                      {'col_name': 'Partition Provider',
                      'comment': '',
                      'data_type': 'Catalog'}],
      'stats': [{'col_name': 'TRUE',
                  'comment': '',
                  'data_type': 'TRANSLATED_TO_EXTERNAL'},
                {'col_name': '2', 'comment': '', 'data_type': 'bucketing_version'},
                {'col_name': 'TRUE',
                  'comment': '',
                  'data_type': 'external.table.purge'},
                {'col_name': '0',
                  'comment': '',
                  'data_type': 'numFilesErasureCoded'},
                {'col_name': '1656416152',
                  'comment': '',
                  'data_type': 'transient_lastDdlTime'}],
      'status': 0})

  def test_get_jobs(self):
    local_jobs = [
      {'url': u'http://172.21.1.246:4040/jobs/job/?id=0', 'name': u'0'}
    ]
    jobs = self.api._get_standalone_jobs(LIVY_STANDALONE_LOG)
    assert_equal(jobs, local_jobs, jobs)

    yarn_jobs = [
      {'url': u'http://huetest-1.test.com:8088/proxy/application_1444070328046_0002/', 'name': u'application_1444070328046_0002'}
    ]
    jobs = self.api._get_yarn_jobs(LIVY_YARN_LOG)
    assert_equal(jobs, yarn_jobs, jobs)

LIVY_STANDALONE_LOG = """
  Starting livy-repl on http://172.21.1.246:58449
  Using Spark's default log4j profile: org/apache/spark/log4j-defaults.properties
  15/10/05 14:02:33 INFO SparkContext: Running Spark version 1.5.0
  15/10/05 14:02:33 INFO SecurityManager: Changing view acls to: huetest
  15/10/05 14:02:33 INFO SecurityManager: Changing modify acls to: huetest
  15/10/05 14:02:33 INFO SecurityManager: SecurityManager: authentication disabled; ui acls disabled; users with view permissions: Set(huetest); users with modify permissions: Set(huetest)
  15/10/05 14:02:33 INFO Slf4jLogger: Slf4jLogger started
  15/10/05 14:02:33 INFO Remoting: Starting remoting
  15/10/05 14:02:33 INFO Remoting: Remoting started; listening on addresses :[akka.tcp://sparkDriver@172.21.1.246:58451]
  15/10/05 14:02:33 INFO Utils: Successfully started service 'sparkDriver' on port 58451.
  15/10/05 14:02:33 INFO SparkEnv: Registering MapOutputTracker
  15/10/05 14:02:33 INFO SparkEnv: Registering BlockManagerMaster
  15/10/05 14:02:33 INFO DiskBlockManager: Created local directory at /private/var/folders/7t/31vfhhq92_g628vh8q5pspbc0000gp/T/blockmgr-f63fdd28-6d86-4ae6-a91c-902fb0310fb4
  15/10/05 14:02:33 INFO MemoryStore: MemoryStore started with capacity 530.0 MB
  15/10/05 14:02:33 INFO HttpFileServer: HTTP File server directory is /private/var/folders/7t/31vfhhq92_g628vh8q5pspbc0000gp/T/spark-a0e35333-e2be-4b83-8a7e-3cb468270dc2/httpd-0235b01f-ee8b-40fd-96a9-de946b1a3426
  15/10/05 14:02:33 INFO HttpServer: Starting HTTP Server
  15/10/05 14:02:33 INFO Utils: Successfully started service 'HTTP file server' on port 58452.
  15/10/05 14:02:33 INFO SparkEnv: Registering OutputCommitCoordinator
  15/10/05 14:02:33 INFO Utils: Successfully started service 'SparkUI' on port 4040.
  15/10/05 14:02:33 INFO SparkUI: Started SparkUI at http://172.21.1.246:4040
  15/10/05 14:02:34 INFO SparkContext: Added JAR file:/Users/huetest/Dev/hue/apps/spark/java/livy-assembly/target/scala-2.10/livy-assembly-3.9.0-SNAPSHOT.jar at http://172.21.1.246:58452/jars/livy-assembly-3.9.0-SNAPSHOT.jar with timestamp 1444078954103
  15/10/05 14:02:34 WARN MetricsSystem: Using default name DAGScheduler for source because spark.app.id is not set.
  15/10/05 14:02:34 INFO Executor: Starting executor ID driver on host localhost
  15/10/05 14:02:34 INFO Utils: Successfully started service 'org.apache.spark.network.netty.NettyBlockTransferService' on port 58453.
  15/10/05 14:02:34 INFO NettyBlockTransferService: Server created on 58453
  15/10/05 14:02:34 INFO BlockManagerMaster: Trying to register BlockManager
  15/10/05 14:02:34 INFO BlockManagerMasterEndpoint: Registering block manager localhost:58453 with 530.0 MB RAM, BlockManagerId(driver, localhost, 58453)
  15/10/05 14:02:34 INFO BlockManagerMaster: Registered BlockManager
  15/10/05 14:02:36 INFO MemoryStore: ensureFreeSpace(130448) called with curMem=0, maxMem=555755765
  15/10/05 14:02:36 INFO MemoryStore: Block broadcast_0 stored as values in memory (estimated size 127.4 KB, free 529.9 MB)
  15/10/05 14:02:36 INFO MemoryStore: ensureFreeSpace(14276) called with curMem=130448, maxMem=555755765
  15/10/05 14:02:36 INFO MemoryStore: Block broadcast_0_piece0 stored as bytes in memory (estimated size 13.9 KB, free 529.9 MB)
  15/10/05 14:02:36 INFO BlockManagerInfo: Added broadcast_0_piece0 in memory on localhost:58453 (size: 13.9 KB, free: 530.0 MB)
  15/10/05 14:02:36 INFO SparkContext: Created broadcast 0 from textFile at NativeMethodAccessorImpl.java:-2
  15/10/05 14:02:36 INFO FileInputFormat: Total input paths to process : 1
  15/10/05 14:02:36 INFO SparkContext: Starting job: collect at <stdin>:1
  15/10/05 14:02:36 INFO DAGScheduler: Registering RDD 3 (reduceByKey at <stdin>:1)
  15/10/05 14:02:36 INFO DAGScheduler: Registering RDD 7 (combineByKey at <stdin>:3)
  15/10/05 14:02:36 INFO DAGScheduler: Got job 0 (collect at <stdin>:1) with 2 output partitions
  15/10/05 14:02:36 INFO DAGScheduler: Final stage: ResultStage 2(collect at <stdin>:1)
  15/10/05 14:02:36 INFO DAGScheduler: Parents of final stage: List(ShuffleMapStage 1)
  15/10/05 14:02:36 INFO DAGScheduler: Missing parents: List(ShuffleMapStage 1)
  15/10/05 14:02:36 INFO DAGScheduler: Submitting ShuffleMapStage 0 (PairwiseRDD[3] at reduceByKey at <stdin>:1), which has no missing parents
  15/10/05 14:02:36 INFO MemoryStore: ensureFreeSpace(8960) called with curMem=144724, maxMem=555755765
  15/10/05 14:02:36 INFO MemoryStore: Block broadcast_1 stored as values in memory (estimated size 8.8 KB, free 529.9 MB)
  15/10/05 14:02:36 INFO MemoryStore: ensureFreeSpace(5483) called with curMem=153684, maxMem=555755765
  15/10/05 14:02:36 INFO MemoryStore: Block broadcast_1_piece0 stored as bytes in memory (estimated size 5.4 KB, free 529.9 MB)
  15/10/05 14:02:36 INFO BlockManagerInfo: Added broadcast_1_piece0 in memory on localhost:58453 (size: 5.4 KB, free: 530.0 MB)
  15/10/05 14:02:36 INFO SparkContext: Created broadcast 1 from broadcast at DAGScheduler.scala:861
  15/10/05 14:02:36 INFO DAGScheduler: Submitting 2 missing tasks from ShuffleMapStage 0 (PairwiseRDD[3] at reduceByKey at <stdin>:1)
  15/10/05 14:02:36 INFO TaskSchedulerImpl: Adding task set 0.0 with 2 tasks
  15/10/05 14:02:36 INFO TaskSetManager: Starting task 0.0 in stage 0.0 (TID 0, localhost, PROCESS_LOCAL, 2266 bytes)
  15/10/05 14:02:36 INFO TaskSetManager: Starting task 1.0 in stage 0.0 (TID 1, localhost, PROCESS_LOCAL, 2266 bytes)
  15/10/05 14:02:36 INFO Executor: Running task 0.0 in stage 0.0 (TID 0)
  15/10/05 14:02:36 INFO Executor: Running task 1.0 in stage 0.0 (TID 1)
  15/10/05 14:02:36 INFO Executor: Fetching http://172.21.1.246:58452/jars/livy-assembly-3.9.0-SNAPSHOT.jar with timestamp 1444078954103
  15/10/05 14:02:36 INFO Utils: Fetching http://172.21.1.246:58452/jars/livy-assembly-3.9.0-SNAPSHOT.jar to /private/var/folders/7t/31vfhhq92_g628vh8q5pspbc0000gp/T/spark-a0e35333-e2be-4b83-8a7e-3cb468270dc2/userFiles-d0940846-b38a-4e4d-af07-8419b364d7ff/fetchFileTemp476551478197543813.tmp
  15/10/05 14:02:36 INFO Executor: Adding file:/private/var/folders/7t/31vfhhq92_g628vh8q5pspbc0000gp/T/spark-a0e35333-e2be-4b83-8a7e-3cb468270dc2/userFiles-d0940846-b38a-4e4d-af07-8419b364d7ff/livy-assembly-3.9.0-SNAPSHOT.jar to class loader
  15/10/05 14:02:36 INFO HadoopRDD: Input split: file:/Users/huetest/Downloads/babs_open_data_year_1/201402_babs_open_data/201402_trip_data.csv:0+8609511
  15/10/05 14:02:36 INFO HadoopRDD: Input split: file:/Users/huetest/Downloads/babs_open_data_year_1/201402_babs_open_data/201402_trip_data.csv:8609511+8609511
  15/10/05 14:02:36 INFO deprecation: mapred.tip.id is deprecated. Instead, use mapreduce.task.id
  15/10/05 14:02:36 INFO deprecation: mapred.task.id is deprecated. Instead, use mapreduce.task.attempt.id
  15/10/05 14:02:36 INFO deprecation: mapred.task.is.map is deprecated. Instead, use mapreduce.task.ismap
  15/10/05 14:02:36 INFO deprecation: mapred.task.partition is deprecated. Instead, use mapreduce.task.partition
  15/10/05 14:02:36 INFO deprecation: mapred.job.id is deprecated. Instead, use mapreduce.job.id
  15/10/05 14:02:37 INFO PythonRDD: Times: total = 727, boot = 229, init = 44, finish = 454
  15/10/05 14:02:37 INFO PythonRDD: Times: total = 730, boot = 226, init = 46, finish = 458
  15/10/05 14:02:37 INFO Executor: Finished task 1.0 in stage 0.0 (TID 1). 2318 bytes result sent to driver
  15/10/05 14:02:37 INFO Executor: Finished task 0.0 in stage 0.0 (TID 0). 2318 bytes result sent to driver
  15/10/05 14:02:37 INFO TaskSetManager: Finished task 1.0 in stage 0.0 (TID 1) in 950 ms on localhost (1/2)
  15/10/05 14:02:37 INFO TaskSetManager: Finished task 0.0 in stage 0.0 (TID 0) in 962 ms on localhost (2/2)
  15/10/05 14:02:37 INFO TaskSchedulerImpl: Removed TaskSet 0.0, whose tasks have all completed, from pool
  15/10/05 14:02:37 INFO DAGScheduler: ShuffleMapStage 0 (reduceByKey at <stdin>:1) finished in 0.973 s
  15/10/05 14:02:37 INFO DAGScheduler: looking for newly runnable stages
"""
LIVY_YARN_LOG = """
  15/10/05 13:51:21 INFO client.RMProxy: Connecting to ResourceManager at huetest-1.test.com/175.18.213.12:8032
  15/10/05 13:51:21 INFO yarn.Client: Requesting a new application from cluster with 3 NodeManagers
  15/10/05 13:51:21 INFO yarn.Client: Verifying our application has not requested more than the maximum memory capability of the cluster (2048 MB per container)
  15/10/05 13:51:21 INFO yarn.Client: Will allocate AM container, with 1408 MB memory including 384 MB overhead
  15/10/05 13:51:21 INFO yarn.Client: Setting up container launch context for our AM
  15/10/05 13:51:21 INFO yarn.Client: Setting up the launch environment for our AM container
  15/10/05 13:51:21 INFO yarn.Client: Preparing resources for our AM container
  15/10/05 13:51:21 WARN util.NativeCodeLoader: Unable to load native-hadoop library for your platform... using builtin-java classes where applicable
  15/10/05 13:51:21 INFO yarn.Client: Uploading resource file:/Users/huetest/Dev/spark-1.5.0-bin-hadoop2.6/lib/spark-assembly-1.5.0-hadoop2.6.0.jar -> hdfs://huetest-1.vpc.cloudera.com:8020/user/huetest/.sparkStaging/application_1444070328046_0002/spark-assembly-1.5.0-hadoop2.6.0.jar
  15/10/05 13:52:00 INFO yarn.Client: Uploading resource file:/Users/huetest/Dev/hue/apps/spark/java/livy-assembly/target/scala-2.10/livy-assembly-3.9.0-SNAPSHOT.jar -> hdfs://huetest-1.vpc.cloudera.com:8020/user/huetest/.sparkStaging/application_1444070328046_0002/livy-assembly-3.9.0-SNAPSHOT.jar
  15/10/05 13:52:09 INFO yarn.Client: Uploading resource file:/Users/huetest/Dev/spark-1.5.0-bin-hadoop2.6/python/lib/pyspark.zip -> hdfs://huetest-1.vpc.cloudera.com:8020/user/huetest/.sparkStaging/application_1444070328046_0002/pyspark.zip
  15/10/05 13:52:09 INFO yarn.Client: Uploading resource file:/Users/huetest/Dev/spark-1.5.0-bin-hadoop2.6/python/lib/py4j-0.8.2.1-src.zip -> hdfs://huetest-1.vpc.cloudera.com:8020/user/huetest/.sparkStaging/application_1444070328046_0002/py4j-0.8.2.1-src.zip
  15/10/05 13:52:10 INFO yarn.Client: Uploading resource file:/private/var/folders/7t/31vfhhq92_g628vh8q5pspbc0000gp/T/spark-3bde33db-374c-4abe-a4af-704bd5dc09d2/__spark_conf__4420686202746650998.zip -> hdfs://huetest-1.vpc.cloudera.com:8020/user/huetest/.sparkStaging/application_1444070328046_0002/__spark_conf__4420686202746650998.zip
  15/10/05 13:52:10 INFO spark.SecurityManager: Changing view acls to: huetest
  15/10/05 13:52:10 INFO spark.SecurityManager: Changing modify acls to: huetest
  15/10/05 13:52:10 INFO spark.SecurityManager: SecurityManager: authentication disabled; ui acls disabled; users with view permissions: Set(huetest); users with modify permissions: Set(huetest)
  15/10/05 13:52:10 INFO yarn.Client: Submitting application 2 to ResourceManager
  15/10/05 13:52:10 INFO impl.YarnClientImpl: Submitted application application_1444070328046_0002
  15/10/05 13:52:11 INFO yarn.Client: Application report for application_1444070328046_0002 (state: ACCEPTED)
  15/10/05 13:52:11 INFO yarn.Client:
        client token: N/A
        diagnostics: N/A
        ApplicationMaster host: N/A
        ApplicationMaster RPC port: -1
        queue: root.huetest
        start time: 1444078329419
        final status: UNDEFINED
        tracking URL: http://huetest-1.test.com:8088/proxy/application_1444070328046_0002/
        user: huetest
  15/10/05 13:52:12 INFO yarn.Client: Application report for application_1444070328046_0002 (state: ACCEPTED)
  15/10/05 13:52:13 INFO yarn.Client: Application report for application_1444070328046_0002 (state: ACCEPTED)
  15/10/05 13:52:14 INFO yarn.Client: Application report for application_1444070328046_0002 (state: ACCEPTED)
  15/10/05 13:52:16 INFO yarn.Client: Application report for application_1444070328046_0002 (state: ACCEPTED)
  15/10/05 13:52:17 INFO yarn.Client: Application report for application_1444070328046_0002 (state: ACCEPTED)
  15/10/05 13:52:18 INFO yarn.Client: Application report for application_1444070328046_0002 (state: ACCEPTED)
  15/10/05 13:52:19 INFO yarn.Client: Application report for application_1444070328046_0002 (state: ACCEPTED)
  15/10/05 13:52:20 INFO yarn.Client: Application report for application_1444070328046_0002 (state: ACCEPTED)
  15/10/05 13:52:21 INFO yarn.Client: Application report for application_1444070328046_0002 (state: ACCEPTED)
  15/10/05 13:52:22 INFO yarn.Client: Application report for application_1444070328046_0002 (state: ACCEPTED)
  15/10/05 13:52:23 INFO yarn.Client: Application report for application_1444070328046_0002 (state: RUNNING)
  15/10/05 13:52:23 INFO yarn.Client:
        client token: N/A
        diagnostics: N/A
        ApplicationMaster host: 175.18.213.12
        ApplicationMaster RPC port: 0
        queue: root.huetest
        start time: 1444078329419
        final status: UNDEFINED
        tracking URL: http://huetest-1.test.com:8088/proxy/application_1444070328046_0002/
        user: huetest
  15/10/05 13:52:24 INFO yarn.Client: Application report for application_1444070328046_0002 (state: RUNNING)
"""


text:
package org.basex.index.value;

import org.basex.index.*;
import org.basex.util.hash.*;
import org.basex.util.list.*;

/**
 * This class provides index-supported access to values
 * (attribute values, text contents, full-texts).
 *
 * @author BaseX Team 2005-15, BSD License
 * @author Christian Gruen
 */
public interface ValueIndex extends Index {
  /**
   * Add entries to the index.
   * @param map a set of [key, id-list] pairs
   */
  void add(final TokenObjMap<IntList> map);

  /**
   * Deletes index entries from the index.
   * @param map a set of [key, id-list] pairs
   */
  void delete(final TokenObjMap<IntList> map);

  /**
   * Replaces an index entry in the index.
   * @param old old record key
   * @param key new record key
   * @param id record id
   */
  void replace(final byte[] old, final byte[] key, final int id);

  /**
   * Flushes the buffered data.
   */
  void flush();
}


text:
package com.mogproject.mogami.core.move

import com.mogproject.mogami._
import com.mogproject.mogami.core.io._
import com.mogproject.mogami.core.io.csa.{CsaFactory, CsaLike}
import com.mogproject.mogami.core.state.State
import com.mogproject.mogami.util.Implicits._

import scala.util.Try

sealed trait MoveBuilderCsa extends MoveBuilder with CsaLike

object MoveBuilderCsa extends CsaFactory[MoveBuilderCsa] {

  def parseTime(nel: NonEmptyLines): (Line, Option[Int]) = nel.lines.toList match {
    case mv :: Nil => (mv, None)
    case mv :: (tm, n) :: Nil if tm.startsWith("T") =>
      Try(tm.tail.toInt).filter(_ >= 0).map(x => (mv, Some(x))).getOrElse {
        throw new RecordFormatException(n, s"invalid time expression: ${tm}")
      }
    case _ :: (ln, n) :: Nil => throw new RecordFormatException(n, s"invalid time format: ${ln}")
    case _ :: _ :: (ln, n) :: _ => throw new RecordFormatException(n, s"too long move expression: ${ln}")
    // $COVERAGE-OFF$
    case Nil => throw new RuntimeException("never happens")
    // $COVERAGE-ON$
  }

  override def parseCsaString(nel: NonEmptyLines): MoveBuilderCsa = {
    val ((mv, n), t) = parseTime(nel)
    if (mv.length != 7) throw new RecordFormatException(n, s"invalid move expression: ${mv}")

    def f(begin: Int, end: Int): NonEmptyLines = NonEmptyLines(n, mv.substring(begin, end))

    val isHand = mv.substring(1, 3) == "00"
    val pl = Player.parseCsaString(f(0, 1))
    val to = Square.parseCsaString(f(3, 5))
    val pt = Ptype.parseCsaString(f(5, 7))

    if (isHand) {
      if (!pt.isHandType) throw new RecordFormatException(n, s"invalid piece type for hand: ${mv}")
      MoveBuilderCsaHand(pl, to, pt, t)
    } else {
      val from = Square.parseCsaString(f(1, 3))
      if (from == to) throw new RecordFormatException(n, s"move_to must not be the same as move_from: ${mv}")
      MoveBuilderCsaBoard(pl, from, to, pt, t)
    }
  }

}

case class MoveBuilderCsaBoard(player: Player, from: Square, to: Square, newPtype: Ptype, elapsedTime: Option[Int] = None) extends MoveBuilderCsa {
  override def toCsaString: String = List(player, from, to, newPtype).map(_.toCsaString).mkString + timeToCsaString(elapsedTime)

  override def toMove(state: State, lastMoveTo: Option[Square] = None, isStrict: Boolean = true): Option[Move] =
    for {
      oldPiece <- state.board.get(from)
      promote = oldPiece.ptype != newPtype
      isSame = lastMoveTo.contains(to)
      isCheck = isCheckMove(state, Some(from), to, newPtype)
      movement = getMovement(state, Some(from), to, oldPiece.ptype)
      captured = state.board.get(to).map(_.ptype).filter(_ != KING)
      mv <- Try(Move(player, Some(from), to, newPtype, promote, isSame, movement, captured, isCheck, elapsedTime, isStrict)).toOption
      if player == state.turn
      if oldPiece.ptype == promote.fold(newPtype.demoted, newPtype)
    } yield mv
}

case class MoveBuilderCsaHand(player: Player, to: Square, ptype: Ptype, elapsedTime: Option[Int] = None) extends MoveBuilderCsa {
  override def toCsaString: String = s"${player.toCsaString}00${to.toCsaString}${ptype.toCsaString}${timeToCsaString(elapsedTime)}"

  override def toMove(state: State, lastMoveTo: Option[Square] = None, isStrict: Boolean = true): Option[Move] = {
    val isCheck = isCheckMove(state, None, to, ptype)
    val movement = getMovement(state, None, to, ptype)
    for {
      mv <- Try(Move(player, None, to, ptype, promote = false, isSameSquare = false, movement, captured = None, isCheck, elapsedTime, isStrict)).toOption
      if player == state.turn
    } yield mv
  }
}


text:
package org.apache.jena.riot.langsuite ;

import junit.framework.Test ;
import junit.framework.TestSuite ;
import org.apache.jena.rdf.model.Resource ;
import org.apache.jena.riot.RDFLanguages ;
import org.apache.jena.riot.RiotException ;
import org.apache.jena.sparql.junit.EarlReport ;
import org.apache.jena.util.junit.TestFactoryManifest ;
import org.apache.jena.util.junit.TestUtils ;
import org.apache.jena.vocabulary.RDF ;

public class FactoryTestRiot extends TestFactoryManifest
{
    public static String assumedRootURIex = "http://example/base/" ;
    public static String assumedRootURITurtle = "http://www.w3.org/2013/TurtleTests/" ;
    public static String assumedRootURITriG = "http://www.w3.org/2013/TriGTests/" ;

    public static EarlReport report = null ;

    public static TestSuite make(String manifest, Resource dftTestType, String labelPrefix)
    {
        return new FactoryTestRiot(dftTestType, labelPrefix).process(manifest) ;
    }

    private Resource dftTestType ;
    private String labelPrefix ;

    public FactoryTestRiot(Resource dftTestType, String labelPrefix)
    {
        this.dftTestType = dftTestType ;
        this.labelPrefix = labelPrefix ;
    }

    @Override
    public Test makeTest(Resource manifest, Resource item, String testName, Resource action, Resource result)
    {
        try
        {
            Resource r = TestUtils.getResource(item, RDF.type) ;
            if ( r == null )
                r = dftTestType ;
            if ( r == null )
                throw new RiotException("Can't determine the test type") ;

            if ( labelPrefix != null )
                testName = labelPrefix+testName ;

            // In Turtle tests, the action directly names the file to process.
            Resource input = action ;
            Resource output = result ;

            if ( r.equals(VocabLangRDF.TestPositiveSyntaxTTL) )
                return new UnitTestSyntax(testName, item.getURI(), input.getURI(), RDFLanguages.TURTLE, report) ;

            if ( r.equals(VocabLangRDF.TestNegativeSyntaxTTL) )
                return new UnitTestBadSyntax(testName, item.getURI(), input.getURI(), RDFLanguages.TURTLE, report) ;

            if ( r.equals(VocabLangRDF.TestPositiveSyntaxTriG) )
                return new UnitTestSyntax(testName, item.getURI(), input.getURI(), RDFLanguages.TRIG, report) ;

            if ( r.equals(VocabLangRDF.TestNegativeSyntaxTriG) )
                return new UnitTestBadSyntax(testName, item.getURI(), input.getURI(), RDFLanguages.TRIG, report) ;

            if ( r.equals(VocabLangRDF.TestPositiveSyntaxNT) )
                return new UnitTestSyntax(testName, item.getURI(), input.getURI(), RDFLanguages.NTRIPLES, report) ;

            if ( r.equals(VocabLangRDF.TestNegativeSyntaxNT) )
                return new UnitTestBadSyntax(testName, item.getURI(), input.getURI(), RDFLanguages.NTRIPLES, report) ;

            if ( r.equals(VocabLangRDF.TestPositiveSyntaxNQ) )
                return new UnitTestSyntax(testName, item.getURI(), input.getURI(), RDFLanguages.NQUADS, report) ;

            if ( r.equals(VocabLangRDF.TestNegativeSyntaxNQ) )
                return new UnitTestBadSyntax(testName, item.getURI(), input.getURI(), RDFLanguages.NQUADS, report) ;

            if ( r.equals(VocabLangRDF.TestPositiveSyntaxRJ) )
                return new UnitTestSyntax(testName, item.getURI(), input.getURI(), RDFLanguages.RDFJSON, report) ;

            if ( r.equals(VocabLangRDF.TestNegativeSyntaxRJ) )
                return new UnitTestBadSyntax(testName, item.getURI(), input.getURI(), RDFLanguages.RDFJSON, report) ;

            if ( r.equals(VocabLangRDF.TestSurpressed ))
                return new UnitTestSurpressed(testName, item.getURI(), report) ;

            // Eval.

            if ( r.equals(VocabLangRDF.TestEvalTTL) ) {
                String base = rebase(input, assumedRootURITurtle) ;
                return new UnitTestEval(testName, item.getURI(), input.getURI(), result.getURI(), base, RDFLanguages.TURTLE, report) ;
            }

            if ( r.equals(VocabLangRDF.TestEvalTriG) ) {
                String base = rebase(input, assumedRootURITriG) ;
                return new UnitTestEval(testName, item.getURI(), input.getURI(), result.getURI(), base, RDFLanguages.TRIG, report) ;
            }

            if ( r.equals(VocabLangRDF.TestNegativeEvalTTL) )
                return new UnitTestBadEval(testName, item.getURI(), input.getURI(), RDFLanguages.TURTLE, report) ;

            if ( r.equals(VocabLangRDF.TestNegativeEvalTriG) )
                return new UnitTestBadEval(testName, item.getURI(), input.getURI(), RDFLanguages.TRIG, report) ;

            if ( r.equals(VocabLangRDF.TestEvalNT) )
                return new UnitTestEval(testName, item.getURI(), input.getURI(), result.getURI(), null, RDFLanguages.NTRIPLES, report) ;

            if ( r.equals(VocabLangRDF.TestNegativeEvalNT) )
                return new UnitTestBadEval(testName, item.getURI(), input.getURI(), RDFLanguages.NTRIPLES, report) ;

            if ( r.equals(VocabLangRDF.TestEvalRJ) ) {
                String base = rebase(input, assumedRootURIex) ;
                return new UnitTestEval(testName, item.getURI(), input.getURI(), result.getURI(), base, RDFLanguages.RDFJSON, report) ;
            }

            if ( r.equals(VocabLangRDF.TestNegativeEvalRJ) )
                return new UnitTestBadEval(testName, item.getURI(), input.getURI(), RDFLanguages.RDFJSON, report) ;

            System.err.println("Unrecognized turtle test : ("+r+")" + testName) ;
            return null ;

        } catch (Exception ex)
        {
            ex.printStackTrace(System.err) ;
            System.err.println("Failed to grok test : " + testName) ;
            return null ;
        }
    }

    private static String rebase(Resource input, String baseIRI) {
        String x = input.getLocalName() ;
        // Yuk, yuk, yuk.
        baseIRI = baseIRI+x ;
        return baseIRI ;
    }

}


text:
<?php

namespace ZendTest\View\_stubs\HelperDir1;

// used to test when helper file is loaded but class is not within


text:
require 'rubocop'

module RuboCop
  module Cop
    module UmtsCustomCops
      # Prefer the easier-to-read be matcher for non-duplicable types.
      #
      # See the specs for examples.
      class BeMatcherForNonDuplicableTypes < Cop
        MSG = 'Prefer `be` matcher to `eq` or `eql` for non-duplicable types.'

        def_node_matcher :eq_on_non_duplicable_type?, <<-PATTERN
          (send
            _expectation {:to :not_to}
            (send
              _context {:eq :eql}
              {true false nil}
            )
          )
        PATTERN

        def autocorrect(node)
          lambda do |corrector|
            matcher = node.child_nodes[1]
            corrector.replace matcher.loc.selector, 'be'
          end
        end

        def on_send(node)
          return unless eq_on_non_duplicable_type? node

          add_offense node, location: :expression, message: MSG
        end
      end
    end
  end
end


text:
Open Street Map data is used under the Open Street Map license https://www.opens
treetmap.org/copyright

Data for the analysis is from http://www.geofabrik.de/ using the download hostin
g service http://download.geofabrik.de/

## Pre-requisites

To extract and process the data is dependant on the following tools:

  * [python](https://python.org)
  * [wget](https://www.gnu.org/software/wget/)
  * [parallel](https://www.gnu.org/software/parallel/)
  * `xml-split4.py`, `add-x-tag.sh` and `xml-to-ndjson.sh`scripts from `bin` directory of [goldfinch](https://github.com/anisotropi4/goldfinch) in the local directory
  * [jq](https://stedolan.github.io/jq) lightweight and flexible command-line JSON processor
  * [xml-to-json](https://hackage.haskell.org/package/xml-to-json)
  * osmctools apt repository [here](https://gitlab.com/osm-c-tools/osmctools)
  * npm [nodejs](https://www.npmjs.com/) installation
  * arangoimp [arangodb](https://www.arangodb.com/download-major/ubuntu) import tool
  * [d3](https://d3js.org) and [leaflet](http://leafletjs.com)

#### For ease of python dependency management a local python3 [miniconda](https://conda.io/miniconda.html) installation is recomended

## Obtain, convert and filter OSM data

This an attempt to apply the OSEMN model (Obtain, Scrub, Explore, Model, and iNterpret) on OSM data on the British rail-network

### Get an up-to-date copy of OSM data

The `create-update.sh` script updates the `great-britain-update.osm.pbf` data file or downloads the data if not present

```
$ ./create-update.sh
```

The `REGION` parameter in the `create-update.sh` script identifies the OSM region to process

The `create-update.sh` script archives the last `great-britain-lastest.osm.pbf` in the `archive` directory

### Extract and manipulate OSM data

This uses a simple pipeline to extract and manipulate OpenStreetMap data extracted from Overpass API using ArangoDB and then rendered using a d3/leaflet interactive map

1) Using the `run.sh` script

```
$ ./run.sh
```

This then:

 - Converts the `.osm.pbf` file to a `.o5m` format file
 - Extracts elements associated with tags 'rail', 'railway' or 'train' to a `.osm` format
 - Extracts nodes, ways and relations into `.xml` files in the output directory
 - Converts the node, way and relation `.xml` data into Newline Delimited JSON`.ndjson`and tag values from `{"k": key, "v": value}` format to `key: value` pairs
 - Combines the node, way and relation files into a `great-britain-railway.ndjson` file
 - Creates an `ogrrailway` arangodb database and uploads the `node`, `way` and `relationship` data
 - Exports railway data into the `visualisation` directory to be visualised in an javascript based interactive webpage

The resulting 'raildata.json' file is visualised in an interactive webpage, using an d3 and OpenStreetMap Leaflet javascript framework, by running a simple webserver on a random port, say 8273, in the `visualisation` directory

```
$ python3 -m http.server 8273
```

Then browsing to http://localhost:8273

## Notes:

### Data file management

The `run.sh` only creates if a file with the same name does not exist

To delete all files processed by the `run.sh` script run the `clean-up.sh`. As the execute permission bit is not set `clean-up.sh` script

```
$ sh ./clean-up.sh
```

### Set up of an arangodb database

Information and scripts to install and configure an arangodb docker installation on a Debian based Linux system is detailed [here](https://github.com/guidoeco/docker)

### Visualisation References

The key element is the use of the quadtree function in the visiblenodes functionto quickly find nodes and is based on at least:
 - The excellent work of Mike Bostock in developing [d3](https://bost.ocks.org/mike/)
 - Scott Murray's 'Interactive Data Visualization for the Web' [here](http://alignedleft.com/work/d3-book)
 - Sumbera implementation 'Many points with d3 and leaflet' [here](http://bl.ocks.org/sumbera/10463358)
 - [OpenStreetMap](https://www.openstreetmap.org) data and maptiles
 - [Leaflet](http://leafletjs.com) javascript library
 - [parallel](https://doi.org/10.5281/zenodo.1146014)
 - The OSEMN approach is set out by the [Dataists](http://www.dataists.com/tag/osemn) and is based on the work of Jeroen Janssens in 'Data Science at the Command Line' https://github.com/jeroenjanssens/data-science-at-the-command-line


text:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace libaxolotl
{
    public interface DecryptionCallback
    {
        void handlePlaintext(byte[] plaintext);

    }
}


text:
namespace Microsoft.Azure.Management.RecoveryServices.SiteRecovery.Models
{
    using Microsoft.Azure;
    using Microsoft.Azure.Management;
    using Microsoft.Azure.Management.RecoveryServices;
    using Microsoft.Azure.Management.RecoveryServices.SiteRecovery;
    using Newtonsoft.Json;
    using System.Collections;
    using System.Collections.Generic;
    using System.Linq;

    /// <summary>
    /// Recovery plan group details.
    /// </summary>
    public partial class RecoveryPlanGroup
    {
        /// <summary>
        /// Initializes a new instance of the RecoveryPlanGroup class.
        /// </summary>
        public RecoveryPlanGroup()
        {
          CustomInit();
        }

        /// <summary>
        /// Initializes a new instance of the RecoveryPlanGroup class.
        /// </summary>
        /// <param name="groupType">The group type. Possible values include:
        /// 'Shutdown', 'Boot', 'Failover'</param>
        /// <param name="replicationProtectedItems">The list of protected
        /// items.</param>
        /// <param name="startGroupActions">The start group actions.</param>
        /// <param name="endGroupActions">The end group actions.</param>
        public RecoveryPlanGroup(RecoveryPlanGroupType groupType, IList<RecoveryPlanProtectedItem> replicationProtectedItems = default(IList<RecoveryPlanProtectedItem>), IList<RecoveryPlanAction> startGroupActions = default(IList<RecoveryPlanAction>), IList<RecoveryPlanAction> endGroupActions = default(IList<RecoveryPlanAction>))
        {
            GroupType = groupType;
            ReplicationProtectedItems = replicationProtectedItems;
            StartGroupActions = startGroupActions;
            EndGroupActions = endGroupActions;
            CustomInit();
        }

        /// <summary>
        /// An initialization method that performs custom operations like setting defaults
        /// </summary>
        partial void CustomInit();

        /// <summary>
        /// Gets or sets the group type. Possible values include: 'Shutdown',
        /// 'Boot', 'Failover'
        /// </summary>
        [JsonProperty(PropertyName = "groupType")]
        public RecoveryPlanGroupType GroupType { get; set; }

        /// <summary>
        /// Gets or sets the list of protected items.
        /// </summary>
        [JsonProperty(PropertyName = "replicationProtectedItems")]
        public IList<RecoveryPlanProtectedItem> ReplicationProtectedItems { get; set; }

        /// <summary>
        /// Gets or sets the start group actions.
        /// </summary>
        [JsonProperty(PropertyName = "startGroupActions")]
        public IList<RecoveryPlanAction> StartGroupActions { get; set; }

        /// <summary>
        /// Gets or sets the end group actions.
        /// </summary>
        [JsonProperty(PropertyName = "endGroupActions")]
        public IList<RecoveryPlanAction> EndGroupActions { get; set; }

        /// <summary>
        /// Validate the object.
        /// </summary>
        /// <exception cref="Rest.ValidationException">
        /// Thrown if validation fails
        /// </exception>
        public virtual void Validate()
        {
            if (StartGroupActions != null)
            {
                foreach (var element in StartGroupActions)
                {
                    if (element != null)
                    {
                        element.Validate();
                    }
                }
            }
            if (EndGroupActions != null)
            {
                foreach (var element1 in EndGroupActions)
                {
                    if (element1 != null)
                    {
                        element1.Validate();
                    }
                }
            }
        }
    }
}