text:
using System.Collections.Generic;
using System.Configuration;
using System.Data.Entity;
using System.Linq;
using Thinktecture.IdentityModel.Constants;
using Thinktecture.IdentityServer.Repositories.Sql.Configuration;

namespace Thinktecture.IdentityServer.Repositories.Sql
{
    public class ConfigurationDatabaseInitializer : CreateDatabaseIfNotExists<IdentityServerConfigurationContext>
    {
        public static void SeedContext(IdentityServerConfigurationContext context, bool loadTestData = false)
        {
            // test data
            var entry = ConfigurationManager.AppSettings["idsrv:CreateTestDataOnInitialization"];

            if (loadTestData && entry != null)
            {
                bool createData = false;
                if (bool.TryParse(entry, out createData))
                {
                    if (createData)
                    {
                        // test configuration
                        context.GlobalConfiguration.Add(CreateTestGlobalConfiguration());
                        context.WSFederation.Add(CreateTestWSFederationConfiguration());
                        context.WSTrust.Add(CreateTestWSTrustConfiguration());
                        context.FederationMetadata.Add(CreateTestFederationMetadataConfiguration());
                        context.OAuth2.Add(CreateTestOAuth2Configuration());
                        context.AdfsIntegration.Add(CreateTestAdfsIntegrationConfiguration());
                        context.SimpleHttp.Add(CreateTestSimpleHttpConfiguration());
                        context.Sitefinity.Add(CreateTestSitefinityConfiguration());
                        context.Diagnostics.Add(CreateTestDiagnosticsConfiguration());
                        context.OpenIdConnect.Add(CreateTestOpenIdConnectConfiguration());

                        // test data
                        CreateTestRelyingParties().ForEach(rp => context.RelyingParties.Add(rp));
                        CreateTestIdentityProviders().ForEach(idp => context.IdentityProviders.Add(idp));
                        CreateTestDelegationSettings().ForEach(d => context.Delegation.Add(d));
                        CreateTestClientCertificateSettings().ForEach(cc => context.ClientCertificates.Add(cc));
                        CreateTestClients().ForEach(c => context.Clients.Add(c));
                        CreateTestOpenIdConnectClients().ForEach(c => context.OpenIdConnectClients.Add(c));

                        return;
                    }
                }
            }

            // default configuration
            if (!context.GlobalConfiguration.Any()) context.GlobalConfiguration.Add(CreateDefaultGlobalConfiguration());
            if (!context.WSFederation.Any()) context.WSFederation.Add(CreateDefaultWSFederationConfiguration());
            if (!context.WSTrust.Any()) context.WSTrust.Add(CreateDefaultWSTrustConfiguration());
            if (!context.FederationMetadata.Any()) context.FederationMetadata.Add(CreateDefaultFederationMetadataConfiguration());
            if (!context.OAuth2.Any()) context.OAuth2.Add(CreateDefaultOAuth2Configuration());
            if (!context.AdfsIntegration.Any()) context.AdfsIntegration.Add(CreateDefaultAdfsIntegrationConfiguration());
            if (!context.SimpleHttp.Any()) context.SimpleHttp.Add(CreateDefaultSimpleHttpConfiguration());
            if (!context.Sitefinity.Any()) context.Sitefinity.Add(CreateDefaultSitefinityConfiguration());
            if (!context.Diagnostics.Any()) context.Diagnostics.Add(CreateDefaultDiagnosticsConfiguration());
            if (!context.OpenIdConnect.Any()) context.OpenIdConnect.Add(CreateOpenIdConnectConfiguration());
        }

        protected override void Seed(IdentityServerConfigurationContext context)
        {
            SeedContext(context, true);
            base.Seed(context);
        }

        #region Default Configuration
        private static GlobalConfiguration CreateDefaultGlobalConfiguration()
        {
            return new GlobalConfiguration
            {
                SiteName = "thinktecture identity server v2",
                IssuerUri = "http://identityserver.v2.thinktecture.com/samples",
                IssuerContactEmail = "office@thinktecture.com",
                DefaultWSTokenType = TokenTypes.Saml2TokenProfile11,
                DefaultHttpTokenType = TokenTypes.JsonWebToken,
                DefaultTokenLifetime = 10,
                MaximumTokenLifetime = 24,
                SsoCookieLifetime = 10,
                RequireEncryption = false,
                EnforceUsersGroupMembership = true,
                HttpPort = 80,
                HttpsPort = 443,
                EnableClientCertificateAuthentication = false,
                RequireRelyingPartyRegistration = true
            };
        }

        private static WSFederationConfiguration CreateDefaultWSFederationConfiguration()
        {
            return new WSFederationConfiguration
            {
                AllowReplyTo = false,
                EnableAuthentication = true,
                Enabled = true,
                EnableFederation = false,
                EnableHrd = false,
                RequireReplyToWithinRealm = true,
                RequireSslForReplyTo = true
            };
        }

        private static WSTrustConfiguration CreateDefaultWSTrustConfiguration()
        {
            return new WSTrustConfiguration
            {
                Enabled = true,

                EnableClientCertificateAuthentication = false,
                EnableDelegation = true,
                EnableFederatedAuthentication = false,
                EnableMessageSecurity = false,
                EnableMixedModeSecurity = true
            };
        }

        private static OAuth2Configuration CreateDefaultOAuth2Configuration()
        {
            return new OAuth2Configuration
            {
                Enabled = false,
                EnableImplicitFlow = false,
                EnableResourceOwnerFlow = false,
                EnableConsent = true
            };
        }

        private static AdfsIntegrationConfiguration CreateDefaultAdfsIntegrationConfiguration()
        {
            return new AdfsIntegrationConfiguration
            {
                Enabled = false,
                UsernameAuthenticationEnabled = false,
                SamlAuthenticationEnabled = false,
                JwtAuthenticationEnabled = false,
                AuthenticationTokenLifetime = 60,
                PassThruAuthenticationToken = false
            };
        }

        private static SimpleHttpConfiguration CreateDefaultSimpleHttpConfiguration()
        {
            return new SimpleHttpConfiguration
            {
                Enabled = false
            };
        }

        private static SitefinityConfiguration CreateDefaultSitefinityConfiguration()
        {
            return new SitefinityConfiguration
            {
                Enabled = false
            };
        }

        private static FederationMetadataConfiguration CreateDefaultFederationMetadataConfiguration()
        {
            return new FederationMetadataConfiguration
            {
                Enabled = true
            };
        }

        private static DiagnosticsConfiguration CreateDefaultDiagnosticsConfiguration()
        {
            return new DiagnosticsConfiguration
            {
                EnableFederationMessageTracing = false
            };
        }

        private static OpenIdConnectConfiguration CreateOpenIdConnectConfiguration()
        {
            return new OpenIdConnectConfiguration
            {
                Enabled = false
            };
        }

        #endregion

        #region Test Configuration
        private static GlobalConfiguration CreateTestGlobalConfiguration()
        {
            return new GlobalConfiguration
            {
                SiteName = "thinktecture identity server v2",
                IssuerUri = "http://identityserver.v2.thinktecture.com/samples",
                IssuerContactEmail = "office@thinktecture.com",
                DefaultWSTokenType = TokenTypes.Saml2TokenProfile11,
                DefaultHttpTokenType = TokenTypes.JsonWebToken,
                DefaultTokenLifetime = 10,
                MaximumTokenLifetime = 24,
                SsoCookieLifetime = 10,
                RequireEncryption = false,
                EnforceUsersGroupMembership = true,
                HttpPort = 80,
                HttpsPort = 443,
                EnableClientCertificateAuthentication = true,
                RequireRelyingPartyRegistration = true
            };
        }

        private static WSFederationConfiguration CreateTestWSFederationConfiguration()
        {
            return new WSFederationConfiguration
            {
                AllowReplyTo = false,
                EnableAuthentication = true,
                Enabled = true,
                EnableFederation = true,
                EnableHrd = true,
                RequireReplyToWithinRealm = true,
                RequireSslForReplyTo = true
            };
        }

        private static WSTrustConfiguration CreateTestWSTrustConfiguration()
        {
            return new WSTrustConfiguration
            {
                Enabled = true,

                EnableClientCertificateAuthentication = true,
                EnableDelegation = true,
                EnableFederatedAuthentication = false,
                EnableMessageSecurity = false,
                EnableMixedModeSecurity = true
            };
        }

        private static OAuth2Configuration CreateTestOAuth2Configuration()
        {
            return new OAuth2Configuration
            {
                Enabled = true,
                EnableImplicitFlow = true,
                EnableResourceOwnerFlow = true,
                EnableCodeFlow = true,
                EnableConsent = true
            };
        }

        private static AdfsIntegrationConfiguration CreateTestAdfsIntegrationConfiguration()
        {
            return new AdfsIntegrationConfiguration
            {
                Enabled = true,
                UsernameAuthenticationEnabled = true,
                SamlAuthenticationEnabled = true,
                JwtAuthenticationEnabled = true,
                AuthenticationTokenLifetime = 60,
                PassThruAuthenticationToken = false,
                UserNameAuthenticationEndpoint = "https://server/adfs/services/trust/13/usernamemixed",
                FederationEndpoint = "https://server/adfs/services/trust/13/issuedtokenmixedsymmetricbasic256",
            };
        }

        private static SimpleHttpConfiguration CreateTestSimpleHttpConfiguration()
        {
            return new SimpleHttpConfiguration
            {
                Enabled = true
            };
        }

        private static SitefinityConfiguration CreateTestSitefinityConfiguration()
        {
            return new SitefinityConfiguration
            {
                Enabled = true
            };
        }

        private static FederationMetadataConfiguration CreateTestFederationMetadataConfiguration()
        {
            return new FederationMetadataConfiguration
            {
                Enabled = true
            };
        }

        private static DiagnosticsConfiguration CreateTestDiagnosticsConfiguration()
        {
            return new DiagnosticsConfiguration
            {
                EnableFederationMessageTracing = true
            };
        }

        private static OpenIdConnectConfiguration CreateTestOpenIdConnectConfiguration()
        {
            return new OpenIdConnectConfiguration
            {
                Enabled = true
            };
        }

        #endregion

        #region Test Data
        private static List<RelyingParties> CreateTestRelyingParties()
        {
            return new List<RelyingParties>
            {
                new RelyingParties
                {
                    Name = "Web API Security Sample",
                    Enabled = true,
                    Realm = "urn:webapisecurity",
                    SymmetricSigningKey = "fWUU28oBOIcaQuwUKiL01KztD/CsZX83C3I0M1MOYN4=",
                },
                new RelyingParties
                {
                    Name = "Local Test RP",
                    Enabled = true,
                    Realm = "urn:testrp",
                    ReplyTo = "https://roadie/idsrvrp/"
                },
                new RelyingParties
                {
                    Name = "Test RP (Symmetric Key)",
                    Enabled = true,
                    Realm = "urn:test:symmetric",
                    SymmetricSigningKey = "fWUU28oBOIcaQuwUKiL01KztD/CsZX83C3I0M1MOYN4=",
                },
                new RelyingParties
                {
                    Name = "Test RP (Asymmetric Key)",
                    Enabled = true,
                    Realm = "urn:test:asymmetric",
                },
                new RelyingParties
                {
                    Name = "Authorization Server",
                    Enabled = true,
                    Realm = "urn:authorizationserver",
                    ReplyTo = "https://as.local"
                },
            };
        }

        private static List<Delegation> CreateTestDelegationSettings()
        {
            return new List<Delegation>
            {
                new Delegation
                {
                    Description = "Test for Local RP",
                    UserName = "middletier",
                    Realm = "urn:testrp"
                }
            };
        }

        private static List<ClientCertificates> CreateTestClientCertificateSettings()
        {
            return new List<ClientCertificates>
            {
                new ClientCertificates
                {
                    Description = "Test Client Cert Mapping",
                    UserName = "dominick",
                    Thumbprint = "D19126617D55DFB5952F5A86C4EB80C5A00CC917"
                }
            };
        }

        private static List<IdentityProvider> CreateTestIdentityProviders()
        {
            return new List<IdentityProvider>
            {
                new IdentityProvider
                {
                    Name = "adfs",
                    DisplayName = "LeastPrivilege ADFS Server",
                    Enabled = true,
                    ShowInHrdSelection = true,
                    Type = 1,
                    WSFederationEndpoint = "https://adfs.leastprivilege.vm/adfs/ls/",
                    IssuerThumbprint = "cad5731ae474b932631e57feb72d810aea6f0220"
                },
                new IdentityProvider
                {
                    Name = "waad",
                    DisplayName = "Windows Azure Active Directory",
                    Enabled = true,
                    ShowInHrdSelection = true,
                    Type = 1,
                    WSFederationEndpoint = "https://accounts.accesscontrol.windows.net/fe132fb5-4843-41b4-bce8-9366bad88b80/v2/wsfederation",
                    IssuerThumbprint = "3464C5BDD2BE7F2B6112E2F08E9C0024E33D9FE0"
                },
                new IdentityProvider
                {
                    Name = "acs",
                    DisplayName = "Access Control Service",
                    Enabled = true,
                    ShowInHrdSelection = true,
                    Type = 1,
                    WSFederationEndpoint = "https://idsrvwebids.accesscontrol.windows.net/v2/wsfederation",
                    IssuerThumbprint = "5AAD3C5CC1A5A715E791BEA85B4445D3CB29F33F"
                },
                new IdentityProvider
                {
                    Name = "Facebook",
                    DisplayName = "Facebook",
                    Enabled = true,
                    ShowInHrdSelection = true,
                    Type = 2,
                    ClientID = "239987582797347",
                    ClientSecret = "c29a33352a739c2263c8f32c699077d6",
                    OAuth2ProviderType = 2
                },
                new IdentityProvider
                {
                    Name = "Live",
                    DisplayName = "Live",
                    Enabled = true,
                    ShowInHrdSelection = true,
                    Type = 2,
                    ClientID = "00000000480DD362",
                    ClientSecret = "gH9ngNoSaxRrupt3UcynwI2aK8qODZvf",
                    OAuth2ProviderType = 3
                },
                new IdentityProvider
                {
                    Name = "LinkedIn",
                    DisplayName = "LinkedIn",
                    Enabled = true,
                    ShowInHrdSelection = true,
                    Type = 2,
                    ClientID = "f8xh60airbta",
                    ClientSecret = "DGY4NpcP8HiFW004",
                    OAuth2ProviderType = 4
                },

            };
        }

        private static List<Client> CreateTestClients()
        {
            return new List<Client>
            {
                new Client
                {
                    Name = "Win8 Test Client",
                    Description = "Test Client for Windows Store App",
                    RedirectUri = "ms-app://s-1-15-2-756967155-51850-665164220-3494723435-3400456802-3915619528-546309680/",
                    ClientId = "test",
                    ClientSecret = Thinktecture.IdentityServer.Helper.CryptoHelper.HashPassword("secret"),
                    AllowImplicitFlow = true,
                    AllowResourceOwnerFlow = false,
                    AllowCodeFlow = false
                },
                new Client
                {
                    Name = "Code Flow Sample Client",
                    Description = "Code Flow Sample Client",
                    RedirectUri = "https://localhost:44303/callback",
                    ClientId = "codeflowclient",
                    ClientSecret = Thinktecture.IdentityServer.Helper.CryptoHelper.HashPassword("secret"),
                    AllowImplicitFlow = false,
                    AllowResourceOwnerFlow = false,
                    AllowCodeFlow = true,
                    AllowRefreshToken = true
                },
                new Client
                {
                    Name = "Test Client (Test Project)",
                    Description = "Test Client",
                    RedirectUri = "https://foo",
                    ClientId = "testclient",
                    ClientSecret = Thinktecture.IdentityServer.Helper.CryptoHelper.HashPassword("secret"),
                    AllowImplicitFlow = true,
                    AllowResourceOwnerFlow = true,
                    AllowCodeFlow = true,
                    AllowRefreshToken = true
                }
            };
        }

        private static List<OpenIdConnectClientEntity> CreateTestOpenIdConnectClients()
        {
            return new List<OpenIdConnectClientEntity>()
            {
                new OpenIdConnectClientEntity{
                    ClientId="oidccode",
                    ClientSecret=Thinktecture.IdentityServer.Helper.CryptoHelper.HashPassword("secret"),
                    Name="oidccode sample",
                    AccessTokenLifetime=60,
                    AllowRefreshToken=true,
                    RefreshTokenLifetime=1440,
                    RequireConsent = false,
                    RedirectUris = new HashSet<OpenIdConnectClientRedirectUri>()
                    {
                        new OpenIdConnectClientRedirectUri { RedirectUri = "https://localhost/CodeFlowClient/oidccallback" },
                        new OpenIdConnectClientRedirectUri { RedirectUri = "https://localhost:44309/oidccallback" }
                    }
                }
            };
        }

        #endregion
    }
}


text:
<!DOCTYPE html>

	<title>PasswordEncoder</title>
	<meta name="keywords" content="cfboom.security.crypto.password.concurrent.Callable interface">

<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">

<link rel ="stylesheet" type="text/css" href="../../../../bootstrap/css/bootstrap.min.css">
<link rel ="stylesheet" type="text/css" href="../../../../stylesheet.css">

<link href='https://fonts.googleapis.com/css?family=Ubuntu:400,300,300italic,400italic,700,700italic|Ubuntu+Mono' rel='stylesheet' type='text/css' />

	<link type="text/css" rel="stylesheet" href="../../../../highlighter/styles/shCoreDefault.css">

			<button type="button" class="navbar-toggle" data-toggle="collapse" data-target="#class-navigation">
				Toggle navigation

			</button>
			&ltcfboom/&gt security

 overview

  package

						 class

Class Definition

Constructor Summary

Constructor Detail

Inherited Methods

Method Summary

Method Detail

Property Summary

Property Detail

					 Frames

	cfboom.security.crypto.password

Interface

 PasswordEncoder

cfboom.security.crypto.password.PasswordEncoder

All Known Implementing Classes:

			BCryptPasswordEncoder

Service interface for encoding passwords.
The preferred implementation is {@code BCryptPasswordEncoder}.

Class Attributes:

				displayname

				: Interface PasswordEncoder

				author

				: Keith Donald

			Method Summary

			string

			encode(string rawPassword)

			     Encode the raw password.

			boolean

			matches([string rawPassword], [string encodedPassword])

			     Verify the encoded password obtained from storage matches the submitted raw.

			Method Detail

encode

	public string encode(string rawPassword)

Encode the raw password. Generally, a good encoding algorithm applies a SHA-1 or
greater hash combined with an 8-byte or greater randomly generated salt.

Parameters:

rawPassword

matches

	public boolean matches([string rawPassword], [string encodedPassword])

Verify the encoded password obtained from storage matches the submitted raw
password after it too is encoded. Returns true if the passwords match, false if
they do not. The stored password itself is never decoded.
storage

Parameters:

rawPassword

encodedPassword

Returns:

true if the raw password, after encoding, matches the encoded password from

redpajama_set_name: RedPajamaGithub


text:
package model.job.result.type;

import io.swagger.annotations.ApiModelProperty;
import model.job.result.ResultType;

/**
 * Represents a File that can be acquired by accessing a REST endpoint on the
 * Gateway. These files are prepared by the Accessor component.
 *
 * @author Patrick.Doody
 *
 */
public class FileResult implements ResultType {
	private static final long serialVersionUID = 1L;

	@ApiModelProperty(value = "The unique Id of the Data resource", required = true)
	public String dataId;

	/**
	 * Default Constructor
	 */
	public FileResult() {
		// Empty constructor required by Jackson\
	}

	/**
	 *
	 * @param url
	 *            The URL, off of the Gateway, that the file can be acquired
	 *            from.
	 * @param dataId
	 *            The Data Id of the resource.
	 */
	public FileResult(String dataId) {
		this.dataId = dataId;
	}

	public String getDataId() {
		return dataId;
	}

}


text:
inline std::string RemoveWhitespace(std::string input) {
	std::string result = "";

	for (uint32_t i = 0; i < input.size(); i++) {
		if (!isspace(input[i])) {
			result += input[i];
		}
	}

	return result;
}

inline std::string RemoveWhitespaceAtend(std::string input) {
	uint32_t begin = 0, end = 0;

	for (uint32_t i = 0; i < input.size(); i++) {
		if (!isspace(input[i])) {
			begin = i;
			break;
		}
	}

	for (uint32_t i = input.size() - 1; i >= begin && i > 0; i--) {
		if (!isspace(input[i])) {
			end = i + 1;
			break;
		}
	}

	return input.substr(begin, end - begin);
}

inline bool contains(std::string input, char c) {
	for (uint32_t i = 0; i < input.size(); i++) {
		if (input[i] == c) {
			return true;
		}
	}

	return false;
}

inline std::vector<std::string> split(const std::string &s, char delimiter, bool skipEmpty = false) {
	std::vector<std::string> elements;
	std::stringstream stream(s);
	std::string item;
	while (getline(stream, item, delimiter)) {
		if (item.size() == 0 && skipEmpty) {
			continue;
		}

		elements.push_back(item);
	}
	return elements;
}

inline std::string combine(std::vector<std::string>& elements, char delimiter = ' ') {
	std::string result;

	for (uint32_t i = 0; i < elements.size(); i++) {
		result += elements[i];
		result += delimiter;
	}

	return result;
}

inline std::string combine(std::vector<std::string>& elements, int from, int to, char delimiter = ' ') {
	std::string result;

	for (int i = from; i <= to; i++) {
		result += elements[i];
		result += delimiter;
	}

	return result;
}

inline int to_int(std::string input, int defaultValue = 0.f) {
	return std::stoi(input);
}

inline bool try_to_int(std::string input, int& result) {
	try {
		result = std::stoi(input);
	} catch (const std::invalid_argument&) {
		return false;
	} catch (const std::out_of_range&) {
		return false;
	}
	return true;
}

inline float to_float(std::string input, float defaultValue = 0.f) {
	return std::stof(input);
}

inline bool try_to_float(std::string input, float& result) {
	try {
		result = std::stof(input);
	} catch (const std::invalid_argument&) {
		return false;
	} catch (const std::out_of_range&) {
		return false;
	}
	return true;
}

// TODO: Implement TryTo...
inline bool to_bool(std::string input) {
	input = RemoveWhitespaceAtend(input);

	if (input == "true") {
		return true;
	} else if (input == "false") {
		return false;
	} else if (input == "1") {
		return true;
	} else if (input == "0") {
		return false;
	} else {
		// error
		return false;
	}
}


text:
Markkasse
=========

A small management system for the bar of a boarding school. The Bar is called "Die Mark"


text:
package com.evolveum.icf.dummy.resource;

import java.io.FileNotFoundException;
import java.net.ConnectException;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
import java.util.Date;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.Set;

import org.apache.commons.lang.StringUtils;

import com.evolveum.midpoint.util.DebugDumpable;
import com.evolveum.midpoint.util.DebugUtil;
import com.evolveum.midpoint.util.PrettyPrinter;

/**
 * @author Radovan Semancik
 *
 */
public abstract class DummyObject implements DebugDumpable {

	private String id;
//	private int internalId = -1;
	private String name;
	private Map<String,Set<Object>> attributes = new HashMap<String, Set<Object>>();
	private boolean enabled = true;
	private Date validFrom = null;
	private Date validTo = null;
	protected DummyResource resource;

	private BreakMode modifyBreakMode = null;

	public DummyObject() {
	}

	public String getId() {
		return id;
	}

	public void setId(String id) {
		this.id = id;
	}

	public DummyObject(String name) {
		this.name = name;
	}

	public DummyResource getResource() {
		return resource;
	}

	public void setResource(DummyResource resource) {
		this.resource = resource;
	}

	public String getName() {
		return name;
	}

	public void setName(String username) {
		this.name = username;
	}

	public boolean isEnabled() {
		return enabled;
	}

	public void setEnabled(boolean enabled) throws ConnectException, FileNotFoundException {
		checkModifyBreak();
		this.enabled = enabled;
	}

	public Date getValidFrom() {
		return validFrom;
	}

	public void setValidFrom(Date validFrom) throws ConnectException, FileNotFoundException {
		checkModifyBreak();
		this.validFrom = validFrom;
	}

	public Date getValidTo() {
		return validTo;
	}

	public void setValidTo(Date validTo) throws ConnectException, FileNotFoundException {
		checkModifyBreak();
		this.validTo = validTo;
	}

	public BreakMode getModifyBreakMode() {
		return modifyBreakMode;
	}

	public void setModifyBreakMode(BreakMode modifyBreakMode) {
		this.modifyBreakMode = modifyBreakMode;
	}

	public Set<String> getAttributeNames() {
		return attributes.keySet();
	}

	public <T> Set<T> getAttributeValues(String attrName, Class<T> type) {
		Set<Object> values = attributes.get(attrName);
		return (Set)values;
	}

	public <T> T getAttributeValue(String attrName, Class<T> type) {
		Set<T> values = getAttributeValues(attrName, type);
		if (values == null || values.isEmpty()) {
			return null;
		}
		if (values.size()>1) {
			throw new IllegalArgumentException("Attempt to fetch single value from a multi-valued attribute "+attrName);
		}
		return values.iterator().next();
	}

	public String getAttributeValue(String attrName) {
		return getAttributeValue(attrName,String.class);
	}

	public void replaceAttributeValue(String name, Object value) throws SchemaViolationException, ConnectException, FileNotFoundException {
		Collection<Object> values = new ArrayList<Object>(1);
		values.add(value);
		replaceAttributeValues(name, values);
	}

	public void replaceAttributeValues(String name, Collection<Object> values) throws SchemaViolationException, ConnectException, FileNotFoundException {
		checkModifyBreak();
		Set<Object> currentValues = attributes.get(name);
		if (currentValues == null) {
			currentValues = new HashSet<Object>();
			attributes.put(name, currentValues);
		} else {
			currentValues.clear();
		}
		currentValues.addAll(values);
		checkSchema(name, values, "replace");
		recordModify();
	}

	public void replaceAttributeValues(String name, Object... values) throws SchemaViolationException, ConnectException, FileNotFoundException {
		checkModifyBreak();
		Set<Object> currentValues = attributes.get(name);
		if (currentValues == null) {
			currentValues = new HashSet<Object>();
			attributes.put(name, currentValues);
		} else {
			currentValues.clear();
		}
		List<Object> valuesList = Arrays.asList(values);
		currentValues.addAll(valuesList);
		checkSchema(name, valuesList, "replace");
		if (valuesList.isEmpty()) {
			attributes.remove(name);
		}
		recordModify();
	}

	public void addAttributeValue(String name, Object value) throws SchemaViolationException, ConnectException, FileNotFoundException {
		Collection<Object> values = new ArrayList<Object>(1);
		values.add(value);
		addAttributeValues(name, values);
	}

	public void addAttributeValues(String name, Collection<Object> valuesToAdd) throws SchemaViolationException, ConnectException, FileNotFoundException {
		checkModifyBreak();
		Set<Object> currentValues = attributes.get(name);
		if (currentValues == null) {
			currentValues = new HashSet<Object>();
			attributes.put(name, currentValues);
		}
		for(Object valueToAdd: valuesToAdd) {
			addAttributeValue(name, currentValues, valueToAdd);
		}
		recordModify();
	}

	public void addAttributeValues(String name, String... valuesToAdd) throws SchemaViolationException, ConnectException, FileNotFoundException {
		checkModifyBreak();
		Set<Object> currentValues = attributes.get(name);
		if (currentValues == null) {
			currentValues = new HashSet<Object>();
			attributes.put(name, currentValues);
		}
		for (Object valueToAdd: valuesToAdd) {
			addAttributeValue(name, currentValues, valueToAdd);
		}
		recordModify();
	}

	private void addAttributeValue(String attrName, Set<Object> currentValues, Object valueToAdd) throws SchemaViolationException, ConnectException, FileNotFoundException {
		checkModifyBreak();
		if (resource != null && !resource.isTolerateDuplicateValues()) {
			for (Object currentValue: currentValues) {
				if (currentValue.equals(valueToAdd)) {
					throw new IllegalArgumentException("The value '"+valueToAdd+"' of attribute '"+attrName+"' conflicts with existing value: Attempt to add value that already exists");
				}
				if (resource.isCaseIgnoreValues() && (valueToAdd instanceof String)) {
					if (StringUtils.equalsIgnoreCase((String)currentValue, (String)valueToAdd)) {
						throw new IllegalArgumentException("The value '"+valueToAdd+"' of attribute '"+attrName+"' conflicts with existing value: Attempt to add value that already exists");
					}
				}
			}
		}

		Set<Object> valuesToCheck = new HashSet<Object>();
		valuesToCheck.addAll(currentValues);
		valuesToCheck.add(valueToAdd);
		checkSchema(attrName, valuesToCheck, "add");

		currentValues.add(valueToAdd);
	}

	public void removeAttributeValue(String name, Object value) throws SchemaViolationException, ConnectException, FileNotFoundException {
		Collection<Object> values = new ArrayList<Object>();
		values.add(value);
		removeAttributeValues(name, values);
	}

	public void removeAttributeValues(String name, Collection<Object> values) throws SchemaViolationException, ConnectException, FileNotFoundException {
		checkModifyBreak();
		Set<Object> currentValues = attributes.get(name);
		if (currentValues == null) {
			currentValues = new HashSet<Object>();
			attributes.put(name, currentValues);
		}

		Set<Object> valuesToCheck = new HashSet<Object>();
		valuesToCheck.addAll(currentValues);
		valuesToCheck.removeAll(values);
		checkSchema(name, valuesToCheck, "remove");

		Iterator<Object> iterator = currentValues.iterator();
		while(iterator.hasNext()) {
			Object currentValue = iterator.next();
			boolean found = false;
			for (Object value: values) {
				if (resource.isCaseIgnoreValues() && currentValue instanceof String && value instanceof String) {
					if (StringUtils.equalsIgnoreCase((String)currentValue, (String)value)) {
						found = true;
						break;
					}
				} else {
					if (currentValue.equals(value)) {
						found = true;
						break;
					}
				}
			}
			if (found) {
				iterator.remove();
			}
		}

		recordModify();
	}

	private void checkModifyBreak() throws ConnectException, FileNotFoundException {
		if (resource == null) {
			return;
		}
		BreakMode modifyBreakMode = this.modifyBreakMode;
		if (modifyBreakMode == null) {
			modifyBreakMode = resource.getModifyBreakMode();
		}
		if (modifyBreakMode == BreakMode.NONE) {
			// go on
		} else if (modifyBreakMode == BreakMode.NETWORK) {
			throw new ConnectException("Network error (simulated error)");
		} else if (modifyBreakMode == BreakMode.IO) {
			throw new FileNotFoundException("IO error (simulated error)");
		} else if (modifyBreakMode == BreakMode.GENERIC) {
			// The connector will react with generic exception
			throw new IllegalArgumentException("Generic error (simulated error)");
		} else if (modifyBreakMode == BreakMode.RUNTIME) {
			// The connector will just pass this up
			throw new IllegalStateException("Generic error (simulated error)");
		} else if (modifyBreakMode == BreakMode.UNSUPPORTED) {
			throw new UnsupportedOperationException("Not supported (simulated error)");
		} else {
			// This is a real error. Use this strange thing to make sure it passes up
			throw new RuntimeException("Unknown schema break mode "+modifyBreakMode);
		}
	}

	private void recordModify() {
		if (resource != null) {
			resource.recordModify(this);
		}
	}

	protected void checkSchema(String attrName, Collection<Object> values, String operationName) throws SchemaViolationException {
		if (resource == null || !resource.isEnforceSchema()) {
			return;
		}
		DummyObjectClass accountObjectClass;
		try {
			accountObjectClass = getObjectClass();
		} catch (Exception e) {
			// No not enforce schema if the schema is broken (simulated)
			return;
		}
		if (accountObjectClass == null) {
			// Nothing to check
			return;
		}
		DummyAttributeDefinition attributeDefinition = accountObjectClass.getAttributeDefinition(attrName);
		if (attributeDefinition == null) {
			throw new SchemaViolationException("Attribute "+attrName+" is not defined in resource schema");
		}
		if (attributeDefinition.isRequired() && (values == null || values.isEmpty())) {
			throw new SchemaViolationException(operationName + " of required attribute "+attrName+" results in no values");
		}
		if (!attributeDefinition.isMulti() && values != null && values.size() > 1) {
			throw new SchemaViolationException(operationName + " of single-valued attribute "+attrName+" results in "+values.size()+" values");
		}
	}

	abstract protected DummyObjectClass getObjectClass() throws ConnectException, FileNotFoundException;

	public abstract String getShortTypeName();

	@Override
	public String toString() {
		return getClass().getSimpleName()+"(" + toStringContent() + ")";
	}

	protected String toStringContent() {
		return "name=" + name + ", attributes=" + attributes + ", enabled=" + enabled;
	}

	@Override
	public String debugDump() {
		return debugDump(0);
	}

	@Override
	public String debugDump(int indent) {
		StringBuilder sb = new StringBuilder();
		DebugUtil.indentDebugDump(sb, indent);
		sb.append("DummyAccount: ").append(name).append("\n");
		DebugUtil.debugDumpWithLabelToString(sb, "Enabled", enabled, indent + 1);
		if (validFrom != null || validTo != null) {
			sb.append("\n");
			DebugUtil.debugDumpLabel(sb, "Validity", indent + 1);
			sb.append(" ").append(PrettyPrinter.prettyPrint(validFrom)).append(" - ").append(PrettyPrinter.prettyPrint(validTo));
		}
		sb.append("\n");
		DebugUtil.debugDumpWithLabel(sb, "Attributes", attributes, indent + 1);
		extendDebugDump(sb, indent);
		return sb.toString();
	}

	protected void extendDebugDump(StringBuilder sb, int indent) {
		// Nothing to do
	}

}


text:
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
  <component name="ChangeListManager">
    <list default="true" id="f1b11b59-9206-4f60-854e-a8a6293b7cea" name="Default" comment="">
      <change type="MODIFICATION" beforePath="$PROJECT_DIR$/Yo Intervengo/Helpers/BottomPager/BottomPager.swift" afterPath="$PROJECT_DIR$/Yo Intervengo/Helpers/BottomPager/BottomPager.swift" />
      <change type="MODIFICATION" beforePath="$PROJECT_DIR$/Yo Intervengo/Base.lproj/Main.storyboard" afterPath="$PROJECT_DIR$/Yo Intervengo/Base.lproj/Main.storyboard" />
    </list>
    <ignored path="YoIntervengoiOS.iws" />
    <ignored path=".idea/workspace.xml" />
    <option name="EXCLUDED_CONVERTED_TO_IGNORED" value="true" />
    <option name="TRACKING_ENABLED" value="true" />
    <option name="SHOW_DIALOG" value="false" />
    <option name="HIGHLIGHT_CONFLICTS" value="true" />
    <option name="HIGHLIGHT_NON_ACTIVE_CHANGELIST" value="false" />
    <option name="LAST_RESOLUTION" value="IGNORE" />
  </component>
  <component name="ChangesViewManager" flattened_view="true" show_ignored="false" />
  <component name="CreatePatchCommitExecutor">
    <option name="PATCH_PATH" value="" />
  </component>
  <component name="DaemonCodeAnalyzer">
    <disable_hints />
  </component>
  <component name="ExecutionTargetManager" SELECTED_TARGET="iphoneos_a63aac340eff8c54440d19ec8d652c698b4dd553" />
  <component name="FavoritesManager">
    <favorites_list name="Yo Intervengo" />
  </component>
  <component name="FileEditorManager">
    <leaf />
  </component>
  <component name="Git.Settings">
    <option name="RECENT_GIT_ROOT_PATH" value="$PROJECT_DIR$" />
  </component>
  <component name="IdeDocumentHistory">
    <option name="CHANGED_PATHS">
      <list>
        <option value="$PROJECT_DIR$/Yo Intervengo/Views/About/AboutVC.swift" />
        <option value="$PROJECT_DIR$/Yo Intervengo/Views/Generic/GenericViewController.swift" />
        <option value="$PROJECT_DIR$/Yo Intervengo/Views/Detail/DetailReportVC.swift" />
        <option value="$PROJECT_DIR$/Yo Intervengo/Helpers/LinkForm/CreateReport.swift" />
        <option value="$PROJECT_DIR$/Yo Intervengo/ViewController.swift" />
        <option value="$PROJECT_DIR$/Yo Intervengo/Views/Report/ReportVC.swift" />
        <option value="$PROJECT_DIR$/Yo Intervengo/Helpers/API/APIManager.swift" />
      </list>
    </option>
  </component>
  <component name="JsGulpfileManager">
    <detection-done>true</detection-done>
  </component>
  <component name="ProjectFrameBounds">
    <option name="width" value="1280" />
    <option name="height" value="800" />
  </component>
  <component name="ProjectLevelVcsManager" settingsEditedManually="true">
    <OptionsSetting value="true" id="Add" />
    <OptionsSetting value="true" id="Remove" />
    <OptionsSetting value="true" id="Checkout" />
    <OptionsSetting value="true" id="Update" />
    <OptionsSetting value="true" id="Status" />
    <OptionsSetting value="true" id="Edit" />
    <ConfirmationsSetting value="0" id="Add" />
    <ConfirmationsSetting value="0" id="Remove" />
  </component>
  <component name="ProjectView">
    <navigator currentView="ProjectPane" proportions="" version="1">
      <flattenPackages />
      <showMembers />
      <showModules />
      <showLibraryContents />
      <hideEmptyPackages />
      <abbreviatePackageNames />
      <autoscrollToSource />
      <autoscrollFromSource />
      <sortByType />
    </navigator>
    <panes>
      <pane id="Cidr.FilesView">
        <subPane>
          <PATH>
            <PATH_ELEMENT>
              <option name="myItemId" value="Yo Intervengo" />
              <option name="myItemType" value="com.jetbrains.cidr.projectView.CidrFilesViewHelper$1$1" />
            </PATH_ELEMENT>
          </PATH>
          <PATH>
            <PATH_ELEMENT>
              <option name="myItemId" value="Yo Intervengo" />
              <option name="myItemType" value="com.jetbrains.cidr.projectView.CidrFilesViewHelper$1$1" />
            </PATH_ELEMENT>
            <PATH_ELEMENT>
              <option name="myItemId" value="YoIntervengoiOS" />
              <option name="myItemType" value="com.intellij.ide.projectView.impl.nodes.ProjectViewModuleNode" />
            </PATH_ELEMENT>
          </PATH>
        </subPane>
      </pane>
      <pane id="ProjectPane">
        <subPane>
          <PATH>
            <PATH_ELEMENT>
              <option name="myItemId" />
              <option name="myItemType" value="com.jetbrains.cidr.projectView.XcodeRootNode" />
            </PATH_ELEMENT>
            <PATH_ELEMENT>
              <option name="myItemId" value="Yo Intervengo" />
              <option name="myItemType" value="com.jetbrains.cidr.projectView.XcodeProjectNode" />
            </PATH_ELEMENT>
          </PATH>
          <PATH>
            <PATH_ELEMENT>
              <option name="myItemId" />
              <option name="myItemType" value="com.jetbrains.cidr.projectView.XcodeRootNode" />
            </PATH_ELEMENT>
            <PATH_ELEMENT>
              <option name="myItemId" value="Yo Intervengo" />
              <option name="myItemType" value="com.jetbrains.cidr.projectView.XcodeProjectNode" />
            </PATH_ELEMENT>
            <PATH_ELEMENT>
              <option name="myItemId" value="Yo Intervengo" />
              <option name="myItemType" value="com.jetbrains.cidr.projectView.XcodeViewNode" />
            </PATH_ELEMENT>
          </PATH>
          <PATH>
            <PATH_ELEMENT>
              <option name="myItemId" />
              <option name="myItemType" value="com.jetbrains.cidr.projectView.XcodeRootNode" />
            </PATH_ELEMENT>
            <PATH_ELEMENT>
              <option name="myItemId" value="Yo Intervengo" />
              <option name="myItemType" value="com.jetbrains.cidr.projectView.XcodeProjectNode" />
            </PATH_ELEMENT>
            <PATH_ELEMENT>
              <option name="myItemId" value="Yo Intervengo" />
              <option name="myItemType" value="com.jetbrains.cidr.projectView.XcodeViewNode" />
            </PATH_ELEMENT>
            <PATH_ELEMENT>
              <option name="myItemId" value="Views" />
              <option name="myItemType" value="com.jetbrains.cidr.projectView.XcodeViewNode" />
            </PATH_ELEMENT>
          </PATH>
          <PATH>
            <PATH_ELEMENT>
              <option name="myItemId" />
              <option name="myItemType" value="com.jetbrains.cidr.projectView.XcodeRootNode" />
            </PATH_ELEMENT>
            <PATH_ELEMENT>
              <option name="myItemId" value="Yo Intervengo" />
              <option name="myItemType" value="com.jetbrains.cidr.projectView.XcodeProjectNode" />
            </PATH_ELEMENT>
            <PATH_ELEMENT>
              <option name="myItemId" value="Yo Intervengo" />
              <option name="myItemType" value="com.jetbrains.cidr.projectView.XcodeViewNode" />
            </PATH_ELEMENT>
            <PATH_ELEMENT>
              <option name="myItemId" value="Views" />
              <option name="myItemType" value="com.jetbrains.cidr.projectView.XcodeViewNode" />
            </PATH_ELEMENT>
            <PATH_ELEMENT>
              <option name="myItemId" value="Report" />
              <option name="myItemType" value="com.jetbrains.cidr.projectView.XcodeViewNode" />
            </PATH_ELEMENT>
          </PATH>
          <PATH>
            <PATH_ELEMENT>
              <option name="myItemId" />
              <option name="myItemType" value="com.jetbrains.cidr.projectView.XcodeRootNode" />
            </PATH_ELEMENT>
            <PATH_ELEMENT>
              <option name="myItemId" value="Yo Intervengo" />
              <option name="myItemType" value="com.jetbrains.cidr.projectView.XcodeProjectNode" />
            </PATH_ELEMENT>
            <PATH_ELEMENT>
              <option name="myItemId" value="Yo Intervengo" />
              <option name="myItemType" value="com.jetbrains.cidr.projectView.XcodeViewNode" />
            </PATH_ELEMENT>
            <PATH_ELEMENT>
              <option name="myItemId" value="Views" />
              <option name="myItemType" value="com.jetbrains.cidr.projectView.XcodeViewNode" />
            </PATH_ELEMENT>
            <PATH_ELEMENT>
              <option name="myItemId" value="Generic" />
              <option name="myItemType" value="com.jetbrains.cidr.projectView.XcodeViewNode" />
            </PATH_ELEMENT>
          </PATH>
          <PATH>
            <PATH_ELEMENT>
              <option name="myItemId" />
              <option name="myItemType" value="com.jetbrains.cidr.projectView.XcodeRootNode" />
            </PATH_ELEMENT>
            <PATH_ELEMENT>
              <option name="myItemId" value="Yo Intervengo" />
              <option name="myItemType" value="com.jetbrains.cidr.projectView.XcodeProjectNode" />
            </PATH_ELEMENT>
            <PATH_ELEMENT>
              <option name="myItemId" value="Yo Intervengo" />
              <option name="myItemType" value="com.jetbrains.cidr.projectView.XcodeViewNode" />
            </PATH_ELEMENT>
            <PATH_ELEMENT>
              <option name="myItemId" value="Views" />
              <option name="myItemType" value="com.jetbrains.cidr.projectView.XcodeViewNode" />
            </PATH_ELEMENT>
            <PATH_ELEMENT>
              <option name="myItemId" value="About" />
              <option name="myItemType" value="com.jetbrains.cidr.projectView.XcodeViewNode" />
            </PATH_ELEMENT>
          </PATH>
          <PATH>
            <PATH_ELEMENT>
              <option name="myItemId" />
              <option name="myItemType" value="com.jetbrains.cidr.projectView.XcodeRootNode" />
            </PATH_ELEMENT>
            <PATH_ELEMENT>
              <option name="myItemId" value="Yo Intervengo" />
              <option name="myItemType" value="com.jetbrains.cidr.projectView.XcodeProjectNode" />
            </PATH_ELEMENT>
            <PATH_ELEMENT>
              <option name="myItemId" value="Yo Intervengo" />
              <option name="myItemType" value="com.jetbrains.cidr.projectView.XcodeViewNode" />
            </PATH_ELEMENT>
            <PATH_ELEMENT>
              <option name="myItemId" value="Helpers" />
              <option name="myItemType" value="com.jetbrains.cidr.projectView.XcodeViewNode" />
            </PATH_ELEMENT>
          </PATH>
          <PATH>
            <PATH_ELEMENT>
              <option name="myItemId" />
              <option name="myItemType" value="com.jetbrains.cidr.projectView.XcodeRootNode" />
            </PATH_ELEMENT>
            <PATH_ELEMENT>
              <option name="myItemId" value="Yo Intervengo" />
              <option name="myItemType" value="com.jetbrains.cidr.projectView.XcodeProjectNode" />
            </PATH_ELEMENT>
            <PATH_ELEMENT>
              <option name="myItemId" value="Yo Intervengo" />
              <option name="myItemType" value="com.jetbrains.cidr.projectView.XcodeViewNode" />
            </PATH_ELEMENT>
            <PATH_ELEMENT>
              <option name="myItemId" value="Helpers" />
              <option name="myItemType" value="com.jetbrains.cidr.projectView.XcodeViewNode" />
            </PATH_ELEMENT>
            <PATH_ELEMENT>
              <option name="myItemId" value="API" />
              <option name="myItemType" value="com.jetbrains.cidr.projectView.XcodeViewNode" />
            </PATH_ELEMENT>
          </PATH>
          <PATH>
            <PATH_ELEMENT>
              <option name="myItemId" />
              <option name="myItemType" value="com.jetbrains.cidr.projectView.XcodeRootNode" />
            </PATH_ELEMENT>
          </PATH>
        </subPane>
      </pane>
    </panes>
  </component>
  <component name="PropertiesComponent">
    <property name="FullScreen" value="true" />
    <property name="recentsLimit" value="5" />
  </component>
  <component name="RunManager" selected="Application.Yo Intervengo">
    <configuration default="true" type="AppleRunConfiguration" factoryName="Application" PASS_PARENT_ENVS="FALSE" PROJECT_NAME="Yo Intervengo" TARGET_NAME="Yo Intervengo" CONFIG_NAME="Debug" RUN_TARGET_PROJECT_NAME="Yo Intervengo" RUN_TARGET_NAME="Yo Intervengo" MAKE_ACTIVE="TRUE" WAIT_FOR="FALSE">
      <envs />
      <EXTENSION ID="org.jetbrains.appcode.reveal.RevealRunConfigurationExtension">
        <REVEAL_SETTINGS autoInject="false" autoInstall="true" askToEnableAutoInstall="true" />
      </EXTENSION>
      <method />
    </configuration>
    <configuration default="true" type="OCUnitRunConfiguration" factoryName="XCTest/Kiwi" PASS_PARENT_ENVS="FALSE" PROJECT_NAME="Yo Intervengo" TARGET_NAME="Yo IntervengoTests" CONFIG_NAME="Debug" TEST_MODE="SUITE_TEST">
      <envs />
      <method />
    </configuration>
    <configuration default="true" type="OCGoogleTestRunConfigurationType" factoryName="Google Test" PASS_PARENT_ENVS="FALSE" PROJECT_NAME="Yo Intervengo" TARGET_NAME="Yo Intervengo" CONFIG_NAME="Debug" TEST_MODE="SUITE_TEST">
      <envs />
      <method />
    </configuration>
    <configuration default="true" type="js.build_tools.gulp" factoryName="Gulp.js">
      <node-options />
      <gulpfile />
      <tasks />
      <arguments />
      <pass-parent-envs>true</pass-parent-envs>
      <envs />
      <method />
    </configuration>
    <configuration default="false" name="Yo Intervengo" type="AppleRunConfiguration" factoryName="Application" WORKING_DIR="" PASS_PARENT_ENVS="FALSE" PROJECT_NAME="Yo Intervengo" TARGET_NAME="Yo Intervengo" CONFIG_NAME="Debug" SCHEME_NAME="Yo Intervengo" RUN_TARGET_PROJECT_NAME="Yo Intervengo" RUN_TARGET_NAME="Yo Intervengo" MAKE_ACTIVE="TRUE" WAIT_FOR="FALSE">
      <envs />
      <EXTENSION ID="org.jetbrains.appcode.reveal.RevealRunConfigurationExtension">
        <REVEAL_SETTINGS autoInject="false" autoInstall="true" askToEnableAutoInstall="true" />
      </EXTENSION>
      <RunnerSettings RunnerId="AppRunner" />
      <ConfigurationWrapper RunnerId="AppRunner" />
      <method />
    </configuration>
    <configuration default="false" name="Pods-AFNetworking" type="AppleRunConfiguration" factoryName="Application" WORKING_DIR="" PASS_PARENT_ENVS="FALSE" PROJECT_NAME="Pods" TARGET_NAME="Pods-AFNetworking" CONFIG_NAME="Debug" SCHEME_NAME="Pods-AFNetworking" MAKE_ACTIVE="TRUE" WAIT_FOR="FALSE">
      <envs />
      <EXTENSION ID="org.jetbrains.appcode.reveal.RevealRunConfigurationExtension">
        <REVEAL_SETTINGS autoInject="false" autoInstall="true" askToEnableAutoInstall="true" />
      </EXTENSION>
      <method />
    </configuration>
    <configuration default="false" name="Pods-Canvas" type="AppleRunConfiguration" factoryName="Application" WORKING_DIR="" PASS_PARENT_ENVS="FALSE" PROJECT_NAME="Pods" TARGET_NAME="Pods-Canvas" CONFIG_NAME="Debug" SCHEME_NAME="Pods-Canvas" MAKE_ACTIVE="TRUE" WAIT_FOR="FALSE">
      <envs />
      <EXTENSION ID="org.jetbrains.appcode.reveal.RevealRunConfigurationExtension">
        <REVEAL_SETTINGS autoInject="false" autoInstall="true" askToEnableAutoInstall="true" />
      </EXTENSION>
      <method />
    </configuration>
    <configuration default="false" name="Pods-ESDateHelper" type="AppleRunConfiguration" factoryName="Application" WORKING_DIR="" PASS_PARENT_ENVS="FALSE" PROJECT_NAME="Pods" TARGET_NAME="Pods-ESDateHelper" CONFIG_NAME="Debug" SCHEME_NAME="Pods-ESDateHelper" MAKE_ACTIVE="TRUE" WAIT_FOR="FALSE">
      <envs />
      <EXTENSION ID="org.jetbrains.appcode.reveal.RevealRunConfigurationExtension">
        <REVEAL_SETTINGS autoInject="false" autoInstall="true" askToEnableAutoInstall="true" />
      </EXTENSION>
      <method />
    </configuration>
    <configuration default="false" name="Pods-ESDatePicker" type="AppleRunConfiguration" factoryName="Application" WORKING_DIR="" PASS_PARENT_ENVS="FALSE" PROJECT_NAME="Pods" TARGET_NAME="Pods-ESDatePicker" CONFIG_NAME="Debug" SCHEME_NAME="Pods-ESDatePicker" MAKE_ACTIVE="TRUE" WAIT_FOR="FALSE">
      <envs />
      <EXTENSION ID="org.jetbrains.appcode.reveal.RevealRunConfigurationExtension">
        <REVEAL_SETTINGS autoInject="false" autoInstall="true" askToEnableAutoInstall="true" />
      </EXTENSION>
      <method />
    </configuration>
    <configuration default="false" name="Pods-ESObjectPool" type="AppleRunConfiguration" factoryName="Application" WORKING_DIR="" PASS_PARENT_ENVS="FALSE" PROJECT_NAME="Pods" TARGET_NAME="Pods-ESObjectPool" CONFIG_NAME="Debug" SCHEME_NAME="Pods-ESObjectPool" MAKE_ACTIVE="TRUE" WAIT_FOR="FALSE">
      <envs />
      <EXTENSION ID="org.jetbrains.appcode.reveal.RevealRunConfigurationExtension">
        <REVEAL_SETTINGS autoInject="false" autoInstall="true" askToEnableAutoInstall="true" />
      </EXTENSION>
      <method />
    </configuration>
    <configuration default="false" name="Pods-FMDB" type="AppleRunConfiguration" factoryName="Application" WORKING_DIR="" PASS_PARENT_ENVS="FALSE" PROJECT_NAME="Pods" TARGET_NAME="Pods-FMDB" CONFIG_NAME="Debug" SCHEME_NAME="Pods-FMDB" MAKE_ACTIVE="TRUE" WAIT_FOR="FALSE">
      <envs />
      <EXTENSION ID="org.jetbrains.appcode.reveal.RevealRunConfigurationExtension">
        <REVEAL_SETTINGS autoInject="false" autoInstall="true" askToEnableAutoInstall="true" />
      </EXTENSION>
      <method />
    </configuration>
    <configuration default="false" name="Pods-GRMustache" type="AppleRunConfiguration" factoryName="Application" WORKING_DIR="" PASS_PARENT_ENVS="FALSE" PROJECT_NAME="Pods" TARGET_NAME="Pods-GRMustache" CONFIG_NAME="Debug" SCHEME_NAME="Pods-GRMustache" MAKE_ACTIVE="TRUE" WAIT_FOR="FALSE">
      <envs />
      <EXTENSION ID="org.jetbrains.appcode.reveal.RevealRunConfigurationExtension">
        <REVEAL_SETTINGS autoInject="false" autoInstall="true" askToEnableAutoInstall="true" />
      </EXTENSION>
      <method />
    </configuration>
    <configuration default="false" name="Pods-JRSwizzle" type="AppleRunConfiguration" factoryName="Application" WORKING_DIR="" PASS_PARENT_ENVS="FALSE" PROJECT_NAME="Pods" TARGET_NAME="Pods-JRSwizzle" CONFIG_NAME="Debug" SCHEME_NAME="Pods-JRSwizzle" MAKE_ACTIVE="TRUE" WAIT_FOR="FALSE">
      <envs />
      <EXTENSION ID="org.jetbrains.appcode.reveal.RevealRunConfigurationExtension">
        <REVEAL_SETTINGS autoInject="false" autoInstall="true" askToEnableAutoInstall="true" />
      </EXTENSION>
      <method />
    </configuration>
    <configuration default="false" name="Pods-Mapbox-iOS-SDK-Mapbox" type="AppleRunConfiguration" factoryName="Application" WORKING_DIR="" PASS_PARENT_ENVS="FALSE" PROJECT_NAME="Pods" TARGET_NAME="Pods-Mapbox-iOS-SDK-Mapbox" CONFIG_NAME="Debug" SCHEME_NAME="Pods-Mapbox-iOS-SDK-Mapbox" MAKE_ACTIVE="TRUE" WAIT_FOR="FALSE">
      <envs />
      <EXTENSION ID="org.jetbrains.appcode.reveal.RevealRunConfigurationExtension">
        <REVEAL_SETTINGS autoInject="false" autoInstall="true" askToEnableAutoInstall="true" />
      </EXTENSION>
      <method />
    </configuration>
    <configuration default="false" name="Pods-Mapbox-iOS-SDK" type="AppleRunConfiguration" factoryName="Application" WORKING_DIR="" PASS_PARENT_ENVS="FALSE" PROJECT_NAME="Pods" TARGET_NAME="Pods-Mapbox-iOS-SDK" CONFIG_NAME="Debug" SCHEME_NAME="Pods-Mapbox-iOS-SDK" MAKE_ACTIVE="TRUE" WAIT_FOR="FALSE">
      <envs />
      <EXTENSION ID="org.jetbrains.appcode.reveal.RevealRunConfigurationExtension">
        <REVEAL_SETTINGS autoInject="false" autoInstall="true" askToEnableAutoInstall="true" />
      </EXTENSION>
      <method />
    </configuration>
    <configuration default="false" name="Pods-Masonry" type="AppleRunConfiguration" factoryName="Application" WORKING_DIR="" PASS_PARENT_ENVS="FALSE" PROJECT_NAME="Pods" TARGET_NAME="Pods-Masonry" CONFIG_NAME="Debug" SCHEME_NAME="Pods-Masonry" MAKE_ACTIVE="TRUE" WAIT_FOR="FALSE">
      <envs />
      <EXTENSION ID="org.jetbrains.appcode.reveal.RevealRunConfigurationExtension">
        <REVEAL_SETTINGS autoInject="false" autoInstall="true" askToEnableAutoInstall="true" />
      </EXTENSION>
      <method />
    </configuration>
    <configuration default="false" name="Pods-NSObject-ObjectMap" type="AppleRunConfiguration" factoryName="Application" WORKING_DIR="" PASS_PARENT_ENVS="FALSE" PROJECT_NAME="Pods" TARGET_NAME="Pods-NSObject-ObjectMap" CONFIG_NAME="Debug" SCHEME_NAME="Pods-NSObject-ObjectMap" MAKE_ACTIVE="TRUE" WAIT_FOR="FALSE">
      <envs />
      <EXTENSION ID="org.jetbrains.appcode.reveal.RevealRunConfigurationExtension">
        <REVEAL_SETTINGS autoInject="false" autoInstall="true" askToEnableAutoInstall="true" />
      </EXTENSION>
      <method />
    </configuration>
    <configuration default="false" name="Pods-pop" type="AppleRunConfiguration" factoryName="Application" WORKING_DIR="" PASS_PARENT_ENVS="FALSE" PROJECT_NAME="Pods" TARGET_NAME="Pods-pop" CONFIG_NAME="Debug" SCHEME_NAME="Pods-pop" MAKE_ACTIVE="TRUE" WAIT_FOR="FALSE">
      <envs />
      <EXTENSION ID="org.jetbrains.appcode.reveal.RevealRunConfigurationExtension">
        <REVEAL_SETTINGS autoInject="false" autoInstall="true" askToEnableAutoInstall="true" />
      </EXTENSION>
      <method />
    </configuration>
    <configuration default="false" name="Pods-SMCalloutView" type="AppleRunConfiguration" factoryName="Application" WORKING_DIR="" PASS_PARENT_ENVS="FALSE" PROJECT_NAME="Pods" TARGET_NAME="Pods-SMCalloutView" CONFIG_NAME="Debug" SCHEME_NAME="Pods-SMCalloutView" MAKE_ACTIVE="TRUE" WAIT_FOR="FALSE">
      <envs />
      <EXTENSION ID="org.jetbrains.appcode.reveal.RevealRunConfigurationExtension">
        <REVEAL_SETTINGS autoInject="false" autoInstall="true" askToEnableAutoInstall="true" />
      </EXTENSION>
      <method />
    </configuration>
    <configuration default="false" name="Pods-SwiftTryCatch" type="AppleRunConfiguration" factoryName="Application" WORKING_DIR="" PASS_PARENT_ENVS="FALSE" PROJECT_NAME="Pods" TARGET_NAME="Pods-SwiftTryCatch" CONFIG_NAME="Debug" SCHEME_NAME="Pods-SwiftTryCatch" MAKE_ACTIVE="TRUE" WAIT_FOR="FALSE">
      <envs />
      <EXTENSION ID="org.jetbrains.appcode.reveal.RevealRunConfigurationExtension">
        <REVEAL_SETTINGS autoInject="false" autoInstall="true" askToEnableAutoInstall="true" />
      </EXTENSION>
      <method />
    </configuration>
    <configuration default="false" name="Pods" type="AppleRunConfiguration" factoryName="Application" WORKING_DIR="" PASS_PARENT_ENVS="FALSE" PROJECT_NAME="Pods" TARGET_NAME="Pods" CONFIG_NAME="Debug" SCHEME_NAME="Pods" MAKE_ACTIVE="TRUE" WAIT_FOR="FALSE">
      <envs />
      <EXTENSION ID="org.jetbrains.appcode.reveal.RevealRunConfigurationExtension">
        <REVEAL_SETTINGS autoInject="false" autoInstall="true" askToEnableAutoInstall="true" />
      </EXTENSION>
      <method />
    </configuration>
    <list size="17">
      <item index="0" class="java.lang.String" itemvalue="Application.Yo Intervengo" />
      <item index="1" class="java.lang.String" itemvalue="Application.Pods-AFNetworking" />
      <item index="2" class="java.lang.String" itemvalue="Application.Pods-Canvas" />
      <item index="3" class="java.lang.String" itemvalue="Application.Pods-ESDateHelper" />
      <item index="4" class="java.lang.String" itemvalue="Application.Pods-ESDatePicker" />
      <item index="5" class="java.lang.String" itemvalue="Application.Pods-ESObjectPool" />
      <item index="6" class="java.lang.String" itemvalue="Application.Pods-FMDB" />
      <item index="7" class="java.lang.String" itemvalue="Application.Pods-GRMustache" />
      <item index="8" class="java.lang.String" itemvalue="Application.Pods-JRSwizzle" />
      <item index="9" class="java.lang.String" itemvalue="Application.Pods-Mapbox-iOS-SDK-Mapbox" />
      <item index="10" class="java.lang.String" itemvalue="Application.Pods-Mapbox-iOS-SDK" />
      <item index="11" class="java.lang.String" itemvalue="Application.Pods-Masonry" />
      <item index="12" class="java.lang.String" itemvalue="Application.Pods-NSObject-ObjectMap" />
      <item index="13" class="java.lang.String" itemvalue="Application.Pods-pop" />
      <item index="14" class="java.lang.String" itemvalue="Application.Pods-SMCalloutView" />
      <item index="15" class="java.lang.String" itemvalue="Application.Pods-SwiftTryCatch" />
      <item index="16" class="java.lang.String" itemvalue="Application.Pods" />
    </list>
  </component>
  <component name="ShelveChangesManager" show_recycled="false" />
  <component name="SvnConfiguration">
    <configuration />
  </component>
  <component name="TaskManager">
    <task active="true" id="Default" summary="Default task">
      <changelist id="f1b11b59-9206-4f60-854e-a8a6293b7cea" name="Default" comment="" />
      <created>1432762800088</created>
      <option name="number" value="Default" />
      <updated>1432762800088</updated>
    </task>
    <servers />
  </component>
  <component name="ToolWindowManager">
    <frame x="0" y="0" width="1280" height="800" extended-state="0" />
    <editor active="false" />
    <layout>
      <window_info id="Palette	" active="false" anchor="right" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" weight="0.33" sideWeight="0.5" order="3" side_tool="false" content_ui="tabs" />
      <window_info id="Changes" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" weight="0.33" sideWeight="0.5" order="7" side_tool="false" content_ui="tabs" />
      <window_info id="Designer" active="false" anchor="left" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" weight="0.33" sideWeight="0.5" order="2" side_tool="false" content_ui="tabs" />
      <window_info id="Terminal" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" weight="0.33" sideWeight="0.5" order="7" side_tool="false" content_ui="tabs" />
      <window_info id="TODO" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" weight="0.33" sideWeight="0.5" order="6" side_tool="false" content_ui="tabs" />
      <window_info id="Structure" active="false" anchor="left" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" weight="0.24960506" sideWeight="0.5" order="1" side_tool="false" content_ui="tabs" />
      <window_info id="Project" active="false" anchor="left" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" weight="0.18268467" sideWeight="0.5" order="0" side_tool="false" content_ui="combo" />
      <window_info id="Favorites" active="false" anchor="left" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" weight="0.33" sideWeight="0.5" order="2" side_tool="true" content_ui="tabs" />
      <window_info id="Event Log" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" weight="0.33" sideWeight="0.5" order="7" side_tool="true" content_ui="tabs" />
      <window_info id="Version Control" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" weight="0.33" sideWeight="0.5" order="7" side_tool="false" content_ui="tabs" />
      <window_info id="Cvs" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" weight="0.25" sideWeight="0.5" order="4" side_tool="false" content_ui="tabs" />
      <window_info id="Message" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" weight="0.33" sideWeight="0.5" order="0" side_tool="false" content_ui="tabs" />
      <window_info id="Ant Build" active="false" anchor="right" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" weight="0.25" sideWeight="0.5" order="1" side_tool="false" content_ui="tabs" />
      <window_info id="Find" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" weight="0.33" sideWeight="0.5" order="1" side_tool="false" content_ui="tabs" />
      <window_info id="Debug" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" weight="0.4" sideWeight="0.5" order="3" side_tool="false" content_ui="tabs" />
      <window_info id="Messages" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" weight="0.32913843" sideWeight="0.5" order="7" side_tool="false" content_ui="tabs" />
      <window_info id="Commander" active="false" anchor="right" auto_hide="false" internal_type="SLIDING" type="SLIDING" visible="false" weight="0.4" sideWeight="0.5" order="0" side_tool="false" content_ui="tabs" />
      <window_info id="Run" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="true" weight="0.33663365" sideWeight="0.5" order="2" side_tool="false" content_ui="tabs" />
      <window_info id="Inspection" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" weight="0.4" sideWeight="0.5" order="5" side_tool="false" content_ui="tabs" />
      <window_info id="Hierarchy" active="false" anchor="right" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" weight="0.25" sideWeight="0.5" order="2" side_tool="false" content_ui="combo" />
    </layout>
  </component>
  <component name="Vcs.Log.UiProperties">
    <option name="RECENTLY_FILTERED_USER_GROUPS">
      <collection />
    </option>
    <option name="RECENTLY_FILTERED_BRANCH_GROUPS">
      <collection />
    </option>
  </component>
  <component name="VcsContentAnnotationSettings">
    <option name="myLimit" value="2678400000" />
  </component>
  <component name="VcsManagerConfiguration">
    <option name="myTodoPanelSettings">
      <TodoPanelSettings />
    </option>
  </component>
  <component name="XDebuggerManager">
    <breakpoint-manager />
    <watches-manager />
  </component>
  <component name="editorHistoryManager">
    <entry file="file://$PROJECT_DIR$/Yo Intervengo/Views/Report/ReportVC.swift">
      <provider selected="true" editor-type-id="text-editor">
        <state vertical-scroll-proportion="0.0" vertical-offset="0" max-vertical-offset="100">
          <caret line="0" column="0" selection-start-line="0" selection-start-column="0" selection-end-line="0" selection-end-column="0" />
        </state>
      </provider>
    </entry>
    <entry file="file://$PROJECT_DIR$/Yo Intervengo/Views/Report/ReportVC.swift">
      <provider selected="true" editor-type-id="text-editor">
        <state vertical-scroll-proportion="0.0" vertical-offset="0" max-vertical-offset="100">
          <caret line="0" column="0" selection-start-line="0" selection-start-column="0" selection-end-line="0" selection-end-column="0" />
        </state>
      </provider>
    </entry>
    <entry file="file://$PROJECT_DIR$/Yo Intervengo/ViewController.swift">
      <provider selected="true" editor-type-id="text-editor">
        <state vertical-scroll-proportion="0.0" vertical-offset="0" max-vertical-offset="100">
          <caret line="0" column="0" selection-start-line="0" selection-start-column="0" selection-end-line="0" selection-end-column="0" />
        </state>
      </provider>
    </entry>
    <entry file="file://$PROJECT_DIR$/Yo Intervengo/Helpers/API/APIManager.swift">
      <provider selected="true" editor-type-id="text-editor">
        <state vertical-scroll-proportion="0.0" vertical-offset="465" max-vertical-offset="2415">
          <caret line="31" column="8" selection-start-line="31" selection-start-column="8" selection-end-line="31" selection-end-column="8" />
        </state>
      </provider>
    </entry>
    <entry file="file://$PROJECT_DIR$/Yo Intervengo/Views/About/AboutVC.swift">
      <provider selected="true" editor-type-id="text-editor">
        <state vertical-scroll-proportion="0.0" vertical-offset="285" max-vertical-offset="945">
          <caret line="19" column="41" selection-start-line="19" selection-start-column="41" selection-end-line="19" selection-end-column="41" />
        </state>
      </provider>
    </entry>
    <entry file="file://$PROJECT_DIR$/Yo Intervengo/Views/Generic/GenericViewController.swift">
      <provider selected="true" editor-type-id="text-editor">
        <state vertical-scroll-proportion="0.0" vertical-offset="1995" max-vertical-offset="2340">
          <caret line="133" column="32" selection-start-line="133" selection-start-column="32" selection-end-line="133" selection-end-column="32" />
        </state>
      </provider>
    </entry>
    <entry file="file://$PROJECT_DIR$/Yo Intervengo/Views/Detail/DetailReportVC.swift">
      <provider selected="true" editor-type-id="text-editor">
        <state vertical-scroll-proportion="0.0" vertical-offset="0" max-vertical-offset="100">
          <caret line="0" column="0" selection-start-line="0" selection-start-column="0" selection-end-line="0" selection-end-column="0" />
        </state>
      </provider>
    </entry>
    <entry file="file://$PROJECT_DIR$/Yo Intervengo/Views/About/AboutVC.swift">
      <provider selected="true" editor-type-id="text-editor">
        <state vertical-scroll-proportion="0.0" vertical-offset="285" max-vertical-offset="945">
          <caret line="19" column="41" selection-start-line="19" selection-start-column="41" selection-end-line="19" selection-end-column="41" />
        </state>
      </provider>
    </entry>
    <entry file="file://$PROJECT_DIR$/Yo Intervengo/Views/Generic/GenericViewController.swift">
      <provider selected="true" editor-type-id="text-editor">
        <state vertical-scroll-proportion="0.0" vertical-offset="1995" max-vertical-offset="2340">
          <caret line="133" column="32" selection-start-line="133" selection-start-column="32" selection-end-line="133" selection-end-column="32" />
        </state>
      </provider>
    </entry>
    <entry file="file://$PROJECT_DIR$/Yo Intervengo/Views/Detail/DetailReportVC.swift">
      <provider selected="true" editor-type-id="text-editor">
        <state vertical-scroll-proportion="-5.321429" vertical-offset="1427" max-vertical-offset="4050">
          <caret line="115" column="8" selection-start-line="115" selection-start-column="8" selection-end-line="115" selection-end-column="8" />
        </state>
      </provider>
    </entry>
    <entry file="file://$PROJECT_DIR$/Yo Intervengo/Helpers/LinkForm/CreateReport.swift">
      <provider selected="true" editor-type-id="text-editor">
        <state vertical-scroll-proportion="1.9512196" vertical-offset="0" max-vertical-offset="4980">
          <caret line="80" column="23" selection-start-line="80" selection-start-column="19" selection-end-line="80" selection-end-column="23" />
        </state>
      </provider>
    </entry>
    <entry file="file://$PROJECT_DIR$/Yo Intervengo/ViewController.swift">
      <provider selected="true" editor-type-id="text-editor">
        <state vertical-scroll-proportion="0.8119658" vertical-offset="45" max-vertical-offset="4140">
          <caret line="41" column="18" selection-start-line="41" selection-start-column="18" selection-end-line="41" selection-end-column="18" />
        </state>
      </provider>
    </entry>
    <entry file="file://$PROJECT_DIR$/Yo Intervengo/Views/Report/ReportVC.swift">
      <provider selected="true" editor-type-id="text-editor">
        <state vertical-scroll-proportion="0.0" vertical-offset="300" max-vertical-offset="1080">
          <caret line="20" column="27" selection-start-line="20" selection-start-column="27" selection-end-line="20" selection-end-column="27" />
        </state>
      </provider>
    </entry>
    <entry file="file://$PROJECT_DIR$/Yo Intervengo/Helpers/API/APIManager.swift">
      <provider selected="true" editor-type-id="text-editor">
        <state vertical-scroll-proportion="0.51111114" vertical-offset="900" max-vertical-offset="2610">
          <caret line="83" column="50" selection-start-line="83" selection-start-column="50" selection-end-line="83" selection-end-column="50" />
        </state>
      </provider>
    </entry>
  </component>
</project>


text:
import { createStore, combineReducers } from '../src/index'
import { addTodo, dispatchInMiddle, throwError, unknownAction } from './helpers/actionCreators'
import * as reducers from './helpers/reducers'
import * as Rx from 'rxjs'
import $$observable from 'symbol-observable'

describe('createStore', () => {
  it('exposes the public API', () => {
    const store = createStore(combineReducers(reducers))
    const methods = Object.keys(store)

    expect(methods.length).toBe(4)
    expect(methods).toContain('subscribe')
    expect(methods).toContain('dispatch')
    expect(methods).toContain('getState')
    expect(methods).toContain('replaceReducer')
  })

  it('throws if reducer is not a function', () => {
    expect(() =>
      createStore()
    ).toThrow()

    expect(() =>
      createStore('test')
    ).toThrow()

    expect(() =>
      createStore({})
    ).toThrow()

    expect(() =>
      createStore(() => {})
    ).not.toThrow()
  })

  it('passes the initial action and the initial state', () => {
    const store = createStore(reducers.todos, [
      {
        id: 1,
        text: 'Hello'
      }
    ])
    expect(store.getState()).toEqual([
      {
        id: 1,
        text: 'Hello'
      }
    ])
  })

  it('applies the reducer to the previous state', () => {
    const store = createStore(reducers.todos)
    expect(store.getState()).toEqual([])

    store.dispatch(unknownAction())
    expect(store.getState()).toEqual([])

    store.dispatch(addTodo('Hello'))
    expect(store.getState()).toEqual([
      {
        id: 1,
        text: 'Hello'
      }
    ])

    store.dispatch(addTodo('World'))
    expect(store.getState()).toEqual([
      {
        id: 1,
        text: 'Hello'
      }, {
        id: 2,
        text: 'World'
      }
    ])
  })

  it('applies the reducer to the initial state', () => {
    const store = createStore(reducers.todos, [
      {
        id: 1,
        text: 'Hello'
      }
    ])
    expect(store.getState()).toEqual([
      {
        id: 1,
        text: 'Hello'
      }
    ])

    store.dispatch(unknownAction())
    expect(store.getState()).toEqual([
      {
        id: 1,
        text: 'Hello'
      }
    ])

    store.dispatch(addTodo('World'))
    expect(store.getState()).toEqual([
      {
        id: 1,
        text: 'Hello'
      }, {
        id: 2,
        text: 'World'
      }
    ])
  })

  it('preserves the state when replacing a reducer', () => {
    const store = createStore(reducers.todos)
    store.dispatch(addTodo('Hello'))
    store.dispatch(addTodo('World'))
    expect(store.getState()).toEqual([
      {
        id: 1,
        text: 'Hello'
      },
      {
        id: 2,
        text: 'World'
      }
    ])

    store.replaceReducer(reducers.todosReverse)
    expect(store.getState()).toEqual([
      {
        id: 1,
        text: 'Hello'
      }, {
        id: 2,
        text: 'World'
      }
    ])

    store.dispatch(addTodo('Perhaps'))
    expect(store.getState()).toEqual([
      {
        id: 3,
        text: 'Perhaps'
      },
      {
        id: 1,
        text: 'Hello'
      },
      {
        id: 2,
        text: 'World'
      }
    ])

    store.replaceReducer(reducers.todos)
    expect(store.getState()).toEqual([
      {
        id: 3,
        text: 'Perhaps'
      },
      {
        id: 1,
        text: 'Hello'
      },
      {
        id: 2,
        text: 'World'
      }
    ])

    store.dispatch(addTodo('Surely'))
    expect(store.getState()).toEqual([
      {
        id: 3,
        text: 'Perhaps'
      },
      {
        id: 1,
        text: 'Hello'
      },
      {
        id: 2,
        text: 'World'
      },
      {
        id: 4,
        text: 'Surely'
      }
    ])
  })

  it('supports multiple subscriptions', () => {
    const store = createStore(reducers.todos)
    const listenerA = jest.fn()
    const listenerB = jest.fn()

    let unsubscribeA = store.subscribe(listenerA)
    store.dispatch(unknownAction())
    expect(listenerA.mock.calls.length).toBe(1)
    expect(listenerB.mock.calls.length).toBe(0)

    store.dispatch(unknownAction())
    expect(listenerA.mock.calls.length).toBe(2)
    expect(listenerB.mock.calls.length).toBe(0)

    const unsubscribeB = store.subscribe(listenerB)
    expect(listenerA.mock.calls.length).toBe(2)
    expect(listenerB.mock.calls.length).toBe(0)

    store.dispatch(unknownAction())
    expect(listenerA.mock.calls.length).toBe(3)
    expect(listenerB.mock.calls.length).toBe(1)

    unsubscribeA()
    expect(listenerA.mock.calls.length).toBe(3)
    expect(listenerB.mock.calls.length).toBe(1)

    store.dispatch(unknownAction())
    expect(listenerA.mock.calls.length).toBe(3)
    expect(listenerB.mock.calls.length).toBe(2)

    unsubscribeB()
    expect(listenerA.mock.calls.length).toBe(3)
    expect(listenerB.mock.calls.length).toBe(2)

    store.dispatch(unknownAction())
    expect(listenerA.mock.calls.length).toBe(3)
    expect(listenerB.mock.calls.length).toBe(2)

    unsubscribeA = store.subscribe(listenerA)
    expect(listenerA.mock.calls.length).toBe(3)
    expect(listenerB.mock.calls.length).toBe(2)

    store.dispatch(unknownAction())
    expect(listenerA.mock.calls.length).toBe(4)
    expect(listenerB.mock.calls.length).toBe(2)
  })

  it('only removes listener once when unsubscribe is called', () => {
    const store = createStore(reducers.todos)
    const listenerA = jest.fn()
    const listenerB = jest.fn()

    const unsubscribeA = store.subscribe(listenerA)
    store.subscribe(listenerB)

    unsubscribeA()
    unsubscribeA()

    store.dispatch(unknownAction())
    expect(listenerA.mock.calls.length).toBe(0)
    expect(listenerB.mock.calls.length).toBe(1)
  })

  it('only removes relevant listener when unsubscribe is called', () => {
    const store = createStore(reducers.todos)
    const listener = jest.fn()

    store.subscribe(listener)
    const unsubscribeSecond = store.subscribe(listener)

    unsubscribeSecond()
    unsubscribeSecond()

    store.dispatch(unknownAction())
    expect(listener.mock.calls.length).toBe(1)
  })

  it('supports removing a subscription within a subscription', () => {
    const store = createStore(reducers.todos)
    const listenerA = jest.fn()
    const listenerB = jest.fn()
    const listenerC = jest.fn()

    store.subscribe(listenerA)
    const unSubB = store.subscribe(() => {
      listenerB()
      unSubB()
    })
    store.subscribe(listenerC)

    store.dispatch(unknownAction())
    store.dispatch(unknownAction())

    expect(listenerA.mock.calls.length).toBe(2)
    expect(listenerB.mock.calls.length).toBe(1)
    expect(listenerC.mock.calls.length).toBe(2)
  })

  it('delays unsubscribe until the end of current dispatch', () => {
    const store = createStore(reducers.todos)

    const unsubscribeHandles = []
    const doUnsubscribeAll = () => unsubscribeHandles.forEach(
      unsubscribe => unsubscribe()
    )

    const listener1 = jest.fn()
    const listener2 = jest.fn()
    const listener3 = jest.fn()

    unsubscribeHandles.push(store.subscribe(() => listener1()))
    unsubscribeHandles.push(store.subscribe(() => {
      listener2()
      doUnsubscribeAll()
    }))
    unsubscribeHandles.push(store.subscribe(() => listener3()))

    store.dispatch(unknownAction())
    expect(listener1.mock.calls.length).toBe(1)
    expect(listener2.mock.calls.length).toBe(1)
    expect(listener3.mock.calls.length).toBe(1)

    store.dispatch(unknownAction())
    expect(listener1.mock.calls.length).toBe(1)
    expect(listener2.mock.calls.length).toBe(1)
    expect(listener3.mock.calls.length).toBe(1)
  })

  it('delays subscribe until the end of current dispatch', () => {
    const store = createStore(reducers.todos)

    const listener1 = jest.fn()
    const listener2 = jest.fn()
    const listener3 = jest.fn()

    let listener3Added = false
    const maybeAddThirdListener = () => {
      if (!listener3Added) {
        listener3Added = true
        store.subscribe(() => listener3())
      }
    }

    store.subscribe(() => listener1())
    store.subscribe(() => {
      listener2()
      maybeAddThirdListener()
    })

    store.dispatch(unknownAction())
    expect(listener1.mock.calls.length).toBe(1)
    expect(listener2.mock.calls.length).toBe(1)
    expect(listener3.mock.calls.length).toBe(0)

    store.dispatch(unknownAction())
    expect(listener1.mock.calls.length).toBe(2)
    expect(listener2.mock.calls.length).toBe(2)
    expect(listener3.mock.calls.length).toBe(1)
  })

  it('uses the last snapshot of subscribers during nested dispatch', () => {
    const store = createStore(reducers.todos)

    const listener1 = jest.fn()
    const listener2 = jest.fn()
    const listener3 = jest.fn()
    const listener4 = jest.fn()

    let unsubscribe4
    const unsubscribe1 = store.subscribe(() => {
      listener1()
      expect(listener1.mock.calls.length).toBe(1)
      expect(listener2.mock.calls.length).toBe(0)
      expect(listener3.mock.calls.length).toBe(0)
      expect(listener4.mock.calls.length).toBe(0)

      unsubscribe1()
      unsubscribe4 = store.subscribe(listener4)
      store.dispatch(unknownAction())

      expect(listener1.mock.calls.length).toBe(1)
      expect(listener2.mock.calls.length).toBe(1)
      expect(listener3.mock.calls.length).toBe(1)
      expect(listener4.mock.calls.length).toBe(1)
    })
    store.subscribe(listener2)
    store.subscribe(listener3)

    store.dispatch(unknownAction())
    expect(listener1.mock.calls.length).toBe(1)
    expect(listener2.mock.calls.length).toBe(2)
    expect(listener3.mock.calls.length).toBe(2)
    expect(listener4.mock.calls.length).toBe(1)

    unsubscribe4()
    store.dispatch(unknownAction())
    expect(listener1.mock.calls.length).toBe(1)
    expect(listener2.mock.calls.length).toBe(3)
    expect(listener3.mock.calls.length).toBe(3)
    expect(listener4.mock.calls.length).toBe(1)
  })

  it('provides an up-to-date state when a subscriber is notified', done => {
    const store = createStore(reducers.todos)
    store.subscribe(() => {
      expect(store.getState()).toEqual([
        {
          id: 1,
          text: 'Hello'
        }
      ])
      done()
    })
    store.dispatch(addTodo('Hello'))
  })

  it('does not leak private listeners array', done => {
    const store = createStore(reducers.todos)
    store.subscribe(function () {
      expect(this).toBe(undefined)
      done()
    })
    store.dispatch(addTodo('Hello'))
  })

  it('accepts plain objects and class instances actions', () => {
    const store = createStore(reducers.todos)
    expect(() =>
      store.dispatch(unknownAction())
    ).not.toThrow()

    function AwesomeMap() { }
    expect(() =>
      store.dispatch(new AwesomeMap())
    ).not.toThrow()

    expect(() =>
      store.dispatch(null)
    ).toThrow(/objects/)

    expect(() =>
      store.dispatch(undefined)
    ).toThrow(/objects/)

    expect(() =>
      store.dispatch(42)
    ).toThrow(/objects/)

    expect(() =>
      store.dispatch('hey')
    ).toThrow(/objects/)
  })

  it('handles nested dispatches gracefully', () => {
    function foo(state = 0, action) {
      return action.type === 'foo' ? 1 : state
    }

    function bar(state = 0, action) {
      return action.type === 'bar' ? 2 : state
    }

    const store = createStore(combineReducers({ foo, bar }))

    store.subscribe(function kindaComponentDidUpdate() {
      const state = store.getState()
      if (state.bar === 0) {
        store.dispatch({ type: 'bar' })
      }
    })

    store.dispatch({ type: 'foo' })
    expect(store.getState()).toEqual({
      foo: 1,
      bar: 2
    })
  })

  it('does not allow dispatch() from within a reducer', () => {
    const store = createStore(reducers.dispatchInTheMiddleOfReducer)

    expect(() =>
      store.dispatch(dispatchInMiddle(store.dispatch.bind(store, unknownAction())))
    ).toThrow(/may not dispatch/)
  })

  it('recovers from an error within a reducer', () => {
    const store = createStore(reducers.errorThrowingReducer)
    expect(() =>
      store.dispatch(throwError())
    ).toThrow()

    expect(() =>
      store.dispatch(unknownAction())
    ).not.toThrow()
  })

  it('does not throw if action type is falsy', () => {
    const store = createStore(reducers.todos)
    expect(() =>
      store.dispatch({ type: false })
    ).not.toThrow()
    expect(() =>
      store.dispatch({ type: 0 })
    ).not.toThrow()
    expect(() =>
      store.dispatch({ type: null })
    ).not.toThrow()
    expect(() =>
      store.dispatch({ type: '' })
    ).not.toThrow()
  })

  it('accepts enhancer as the third argument', () => {
    const emptyArray = []
    const spyEnhancer = vanillaCreateStore => (...args) => {
      expect(args[0]).toBe(reducers.todos)
      expect(args[1]).toBe(emptyArray)
      expect(args.length).toBe(2)
      const vanillaStore = vanillaCreateStore(...args)
      return {
        ...vanillaStore,
        dispatch: jest.fn(vanillaStore.dispatch)
      }
    }

    const store = createStore(reducers.todos, emptyArray, spyEnhancer)
    const action = addTodo('Hello')
    store.dispatch(action)
    expect(store.dispatch).toBeCalledWith(action)
    expect(store.getState()).toEqual([
      {
        id: 1,
        text: 'Hello'
      }
    ])
  })

  it('accepts enhancer as the second argument if initial state is missing', () => {
    const spyEnhancer = vanillaCreateStore => (...args) => {
      expect(args[0]).toBe(reducers.todos)
      expect(args[1]).toBe(undefined)
      expect(args.length).toBe(2)
      const vanillaStore = vanillaCreateStore(...args)
      return {
        ...vanillaStore,
        dispatch: jest.fn(vanillaStore.dispatch)
      }
    }

    const store = createStore(reducers.todos, spyEnhancer)
    const action = addTodo('Hello')
    store.dispatch(action)
    expect(store.dispatch).toBeCalledWith(action)
    expect(store.getState()).toEqual([
      {
        id: 1,
        text: 'Hello'
      }
    ])
  })

  it('throws if enhancer is neither undefined nor a function', () => {
    expect(() =>
      createStore(reducers.todos, undefined, {})
    ).toThrow()

    expect(() =>
      createStore(reducers.todos, undefined, [])
    ).toThrow()

    expect(() =>
      createStore(reducers.todos, undefined, null)
    ).toThrow()

    expect(() =>
      createStore(reducers.todos, undefined, false)
    ).toThrow()

    expect(() =>
      createStore(reducers.todos, undefined, undefined)
    ).not.toThrow()

    expect(() =>
      createStore(reducers.todos, undefined, x => x)
    ).not.toThrow()

    expect(() =>
      createStore(reducers.todos, x => x)
    ).not.toThrow()

    expect(() =>
      createStore(reducers.todos, [])
    ).not.toThrow()

    expect(() =>
      createStore(reducers.todos, {})
    ).not.toThrow()
  })

  it('throws if nextReducer is not a function', () => {
    const store = createStore(reducers.todos)

    expect(() =>
      store.replaceReducer()
    ).toThrow('Expected the nextReducer to be a function.')

    expect(() =>
      store.replaceReducer(() => {})
    ).not.toThrow()
  })

  it('throws if listener is not a function', () => {
    const store = createStore(reducers.todos)

    expect(() =>
      store.subscribe()
    ).toThrow()

    expect(() =>
      store.subscribe('')
    ).toThrow()

    expect(() =>
      store.subscribe(null)
    ).toThrow()

    expect(() =>
      store.subscribe(undefined)
    ).toThrow()
  })

  describe('Symbol.observable interop point', () => {
    it('should exist', () => {
      const store = createStore(() => {})
      expect(typeof store[$$observable]).toBe('function')
    })

    describe('returned value', () => {
      it('should be subscribable', () => {
        const store = createStore(() => {})
        const obs = store[$$observable]()
        expect(typeof obs.subscribe).toBe('function')
      })

      it('should throw a TypeError if an observer object is not supplied to subscribe', () => {
        const store = createStore(() => {})
        const obs = store[$$observable]()

        expect(function () {
          obs.subscribe()
        }).toThrow()

        expect(function () {
          obs.subscribe(() => {})
        }).toThrow()

        expect(function () {
          obs.subscribe({})
        }).not.toThrow()
      })

      it('should return a subscription object when subscribed', () => {
        const store = createStore(() => {})
        const obs = store[$$observable]()
        const sub = obs.subscribe({})
        expect(typeof sub.unsubscribe).toBe('function')
      })
    })

    it('should pass an integration test with no unsubscribe', () => {
      function foo(state = 0, action) {
        return action.type === 'foo' ? 1 : state
      }

      function bar(state = 0, action) {
        return action.type === 'bar' ? 2 : state
      }

      const store = createStore(combineReducers({ foo, bar }))
      const observable = store[$$observable]()
      const results = []

      observable.subscribe({
        next(state) {
          results.push(state)
        }
      })

      store.dispatch({ type: 'foo' })
      store.dispatch({ type: 'bar' })

      expect(results).toEqual([ { foo: 0, bar: 0 }, { foo: 1, bar: 0 }, { foo: 1, bar: 2 } ])
    })

    it('should pass an integration test with an unsubscribe', () => {
      function foo(state = 0, action) {
        return action.type === 'foo' ? 1 : state
      }

      function bar(state = 0, action) {
        return action.type === 'bar' ? 2 : state
      }

      const store = createStore(combineReducers({ foo, bar }))
      const observable = store[$$observable]()
      const results = []

      const sub = observable.subscribe({
        next(state) {
          results.push(state)
        }
      })

      store.dispatch({ type: 'foo' })
      sub.unsubscribe()
      store.dispatch({ type: 'bar' })

      expect(results).toEqual([ { foo: 0, bar: 0 }, { foo: 1, bar: 0 } ])
    })

    it('should pass an integration test with a common library (RxJS)', () => {
      function foo(state = 0, action) {
        return action.type === 'foo' ? 1 : state
      }

      function bar(state = 0, action) {
        return action.type === 'bar' ? 2 : state
      }

      const store = createStore(combineReducers({ foo, bar }))
      const observable = Rx.Observable.from(store)
      const results = []

      const sub = observable
        .map(state => ({ fromRx: true, ...state }))
        .subscribe(state => results.push(state))

      store.dispatch({ type: 'foo' })
      sub.unsubscribe()
      store.dispatch({ type: 'bar' })

      expect(results).toEqual([ { foo: 0, bar: 0, fromRx: true }, { foo: 1, bar: 0, fromRx: true } ])
    })
  })
})


text:
Dieses Repo enthält alle Folien und Übungen des PvS Repetitorium im Sommersemester 2018 an der Universität Ulm.
Wenn du irgendwelche Fehler finden solltest, erstelle gerne einen [Issue](https://github.com/onc/PvS-Repetitorium/issues/new).

Bitte beachte: Die Markdown-Dateien in `content/` müssen unix line-endings haben!

## PDF-Export

- Klicke auf diesen [Link](https://onc.github.io/PvS-Repetitorium/?print-pdf#/)
- Strg-P um in die Druck-Vorschau zu kommen
- `Speichern als PDF` als "Drucker" auswählen und speichern

## Inhalt

| Ordner       | Inhalt                                                      |
| ------------ | ----------------------------------------------------------- |
| checks       | Checkstyle-Konfiguration und Google Style-Guide für Eclipse |
| code/PvS-Rep | Eclipse-Projekt für die Übungen                             |
| content      | Folien                                                      |
| exercises    | Übungsblätter und Lösungen                                  |

## Setup

- `Node.js` installieren
- Das Repo clonen
- In den projekt-ordner wechseln
- Abhängigkeiten installieren

    ```
    $ npm install
    ```

- Startet die Präsentation und läd sie neu, sobald eine Datei in `content/` verändert wird

    ```
    $ npm start
    ```

## Keybindings

S - Speaker-View


text:
'use strict';

import { Constraint } from './Constraint';
import { Vec3 } from '../../math/Vec3';

var NORMAL_REGISTER = new Vec3();
var IMPULSE_REGISTER = new Vec3();
var V_REGISTER = new Vec3();
var P_REGISTER = new Vec3();
var DIRECTION_REGISTER = new Vec3();

/** @const */
const PI = Math.PI;

/**
 * A constraint that maintains the direction of one body from another.
 *
 * @class Direction
 * @extends Constraint
 * @param {Particle} a One of the bodies.
 * @param {Particle} b The other body.
 * @param {Object} options An object of configurable options.
 */
class Direction extends Constraint {
  constructor(a, b, options) {
    super(options);

    this.a = a;
    this.b = b;

    this.impulse = 0;
    this.distance = 0;
    this.normal = new Vec3();
    this.velocityBias = 0;
    this.divisor = 0;

    this.initLocals();
  }

  /**
   * Initialize passing the Options.
   *
   * @method
   * @return {undefined} undefined
   */
  init(options) {};

  /**
   * Initialize the Direction. Sets defaults if a property was not already set.
   *
   * @method
   * @return {undefined} undefined
   */
  initLocals() {
    this.direction = this.direction || Vec3.subtract(this.b.position, this.a.position, new Vec3());
    this.direction.normalize();
    this.minLength = this.minLength || 0;
    this.period = this.period || 0.2;
    this.dampingRatio = this.dampingRatio || 0.5;

    this.stiffness = 4 * PI * PI / (this.period * this.period);
    this.damping = 4 * PI * this.dampingRatio / this.period;
  };

  /**
   * Warmstart the constraint and prepare calculations used in .resolve.
   *
   * @method
   * @param {Number} time The current time in the physics engine.
   * @param {Number} dt The physics engine frame delta.
   * @return {undefined} undefined
   */
  update(time, dt) {
    var a = this.a;
    var b = this.b;

    var n = NORMAL_REGISTER;
    var diffP = P_REGISTER;
    var impulse = IMPULSE_REGISTER;
    var directionVector = DIRECTION_REGISTER;

    var p1 = a.position;
    var w1 = a.inverseMass;

    var p2 = b.position;
    var w2 = b.inverseMass;

    var direction = this.direction;

    Vec3.subtract(p2, p1, diffP);
    Vec3.scale(direction, Vec3.dot(direction, diffP), directionVector);
    var goal = directionVector.add(p1);

    Vec3.subtract(p2, goal, n);
    var dist = n.length();
    n.normalize();

    var invEffectiveMass = w1 + w2;
    var effectiveMass = 1 / invEffectiveMass;
    var gamma;
    var beta;

    if (this.period === 0) {
      gamma = 0;
      beta = 1;
    } else {
      var c = this.damping * effectiveMass;
      var k = this.stiffness * effectiveMass;

      gamma = 1 / (dt * (c + dt * k));
      beta = dt * k / (c + dt * k);
    }

    var baumgarte = beta * dist / dt;
    var divisor = gamma + invEffectiveMass;

    var lambda = this.impulse;
    Vec3.scale(n, lambda, impulse);
    b.applyImpulse(impulse);
    a.applyImpulse(impulse.invert());

    this.normal.copy(n);
    this.distance = dist;
    this.velocityBias = baumgarte;
    this.divisor = divisor;
    this.impulse = 0;
  };

  /**
   * Adds an impulse to a physics body's velocity due to the constraint
   *
   * @method
   * @return {undefined} undefined
   */
  resolve() {
    var a = this.a;
    var b = this.b;

    var impulse = IMPULSE_REGISTER;
    var diffV = V_REGISTER;

    var minLength = this.minLength;

    var dist = this.distance;
    if (Math.abs(dist) < minLength) return;

    var v1 = a.velocity;
    var v2 = b.velocity;
    var n = this.normal;

    Vec3.subtract(v2, v1, diffV);

    var lambda = -(Vec3.dot(n, diffV) + this.velocityBias) / this.divisor;
    Vec3.scale(n, lambda, impulse);
    b.applyImpulse(impulse);
    a.applyImpulse(impulse.invert());

    this.impulse += lambda;
  };

}

export { Direction };