text:
<dom-module id="finding-travelers">

	<template>

	    <firebase-collection
				id="fcRequests"
	          location="https://flamingo365.firebaseio.com/requests"
	          ></firebase-collection>

			<paper-material elevation="1">

City

						<paper-button id="btnSelCity" data-dialog="dlogCity" on-tap="showCityDlog">Select<paper-button>

Date

						<paper-input id="piPickDate" label="Select" on-tap="showDateDlog"></paper-input>

Activity

						<paper-button id="btnSelActivity" data-dialog="dlogActivity" on-tap="showActivityDlog">Select</paper-button>

						<paper-button id="btnSearch" raised on-tap="search" class="colorful ripple"><iron-icon icon="search"></iron-icon>Search</paper-button>

			</paper-material>

				<template is="dom-repeat" items="[[schedules]]" filter="filterStatus" sort="_sort" as="schedule">

{{schedule.schedule_title}}

						<iron-image src="[[schedule.userpic]]" style="width:100px; height:100px;"></iron-image>

[[schedule.username]]

						<paper-fab id="btnRequest" on-tap="request" data-key$="{{schedule.__firebaseKey__}}" data-schedule-userid$="{{schedule.userid}}"
						data-schedule-userlink$="{{schedule.userlink}}" data-schedule-username$="{{schedule.username}}"
						data-schedule-userpic$="{{schedule.userpic}}"
						 data-schedule-title$="{{schedule.schedule_title}}" icon="arrow-forward"></paper-fab>

				</template>

		<city-dialog id="cityDlog" on-select-city="onSelectCity"></city-dialog>
		<activity-dialog id="activityDlog" on-select-activity="onSelectActivity"></activity-dialog>

		<paper-dialog id="dpDlog" class="paper-date-picker-dialog" on-iron-overlay-closed="dateValueChanged">

	          <paper-button dialog-dismiss>Cancel</paper-button>
	          <paper-button dialog-confirm>OK</paper-button>

	        <paper-date-picker id="datePicker" date="{{pickerDate}}" responsive-width="655px"></paper-date-picker>
	      </paper-dialog>

	</template>
</dom-module>


text:
package org.apache.ambari.server.controller.spi;

import java.util.Set;

/**
 * The cluster controller is the main access point for accessing resources
 * from the backend sources.  A cluster controller maintains a mapping of
 * resource providers keyed by resource types.
 */
public interface ClusterController extends SchemaFactory {

  // ----- Monitoring ------------------------------------------------------

  /**
   * Get the resources of the given type filtered by the given request and
   * predicate objects.
   *
   * @param type        the type of the requested resources
   * @param request     the request object which defines the desired set of properties
   * @param predicate   the predicate object which filters which resources are returned
   *
   * @return the query response
   *
   * @throws UnsupportedPropertyException thrown if the request or predicate contain
   *                                      unsupported property ids
   * @throws SystemException an internal exception occurred
   * @throws NoSuchResourceException no matching resource(s) found
   * @throws NoSuchParentResourceException a specified parent resource doesn't exist
   */
  QueryResponse getResources(Resource.Type type, Request request, Predicate predicate)
      throws UnsupportedPropertyException,
      NoSuchResourceException,
      NoSuchParentResourceException,
      SystemException;

  /**
   * Populate the given resources from the associated property providers.  This
   * method may filter the resources based on the predicate and return a subset
   * of the given resources.
   *
   * @param type       the resource type
   * @param resources  the resources to be populated
   * @param request    the request
   * @param predicate  the predicate
   *
   * @return the set of resources that were successfully populated
   *
   * @throws SystemException if unable to populate the resources
   */
  public Set<Resource> populateResources(Resource.Type type,
                                            Set<Resource> resources,
                                            Request request,
                                            Predicate predicate) throws SystemException;

  /**
   * Get an iterable set of resources from the given set of resources filtered by the
   * given request and predicate objects.
   *
   * @param type           type of resources
   * @param queryResponse  the response from the resource query
   * @param request        the request
   * @param predicate      the predicate object which filters which resources are returned
   * @param pageRequest    the page request for a paginated response
   * @param sortRequest    the sortRequest object which defines if the resources need to be sorted
   *
   * @return a page response representing the requested page of resources
   *
   * @throws UnsupportedPropertyException thrown if the request or predicate contain
   *                                      unsupported property ids
   * @throws SystemException an internal exception occurred
   * @throws NoSuchResourceException no matching resource(s) found
   * @throws NoSuchParentResourceException a specified parent resource doesn't exist
   */
  Iterable<Resource> getIterable(Resource.Type type, QueryResponse queryResponse,
                                 Request request, Predicate predicate,
                                 PageRequest pageRequest,
                                 SortRequest sortRequest)
      throws NoSuchParentResourceException,
      UnsupportedPropertyException,
      NoSuchResourceException,
      SystemException;

  /**
   * Get a page of resources from the given set filtered by the given request,
   * predicate objects and page request.
   *
   * @param type           type of resources
   * @param queryResponse  the response from the resource query
   * @param request        the request
   * @param predicate      the predicate object which filters which resources are returned
   * @param pageRequest    the page request for a paginated response
   *
   * @return a page response representing the requested page of resources
   *
   * @throws UnsupportedPropertyException thrown if the request or predicate contain
   *                                      unsupported property ids
   * @throws SystemException an internal exception occurred
   * @throws NoSuchResourceException no matching resource(s) found
   * @throws NoSuchParentResourceException a specified parent resource doesn't exist
   */
  PageResponse getPage(Resource.Type type, QueryResponse queryResponse,
                       Request request, Predicate predicate,
                       PageRequest pageRequest, SortRequest sortRequest)
      throws UnsupportedPropertyException,
      SystemException,
      NoSuchResourceException,
      NoSuchParentResourceException;

  /**
   * Get the {@link Schema schema} for the given resource type.  The schema
   * for a given resource type describes the properties and categories provided
   * by that type of resource.
   *
   * @param type the resource type
   * @return the schema object for the given resource
   */
  public Schema getSchema(Resource.Type type);

  /**
   * Get the resource provider for the given type, creating it if required.
   *
   * @param type  the resource type
   *
   * @return the resource provider
   */
  public ResourceProvider ensureResourceProvider(Resource.Type type);

  // ----- Management -------------------------------------------------------

  /**
   * Create the resources defined by the properties in the given request object.
   *
   * @param type     the type of the resources
   * @param request  the request object which defines the set of properties
   *                 for the resources to be created
   *
   * @throws UnsupportedPropertyException thrown if the request contains
   *                                      unsupported property ids
   * @throws SystemException an internal exception occurred
   * @throws ResourceAlreadyExistsException attempted to create a resource that already exists
   * @throws NoSuchParentResourceException a specified parent resource doesn't exist
   */
  public RequestStatus createResources(Resource.Type type, Request request)
      throws UnsupportedPropertyException,
             SystemException,
             ResourceAlreadyExistsException,
             NoSuchParentResourceException;

  /**
   * Update the resources selected by the given predicate with the properties
   * from the given request object.
   *
   *
   * @param type       the type of the resources
   * @param request    the request object which defines the set of properties
   *                   for the resources to be updated
   * @param predicate  the predicate object which can be used to filter which
   *                   resources are updated
   *
   * @throws UnsupportedPropertyException thrown if the request or predicate
   *                                      contain unsupported property ids
   * @throws SystemException an internal exception occurred
   * @throws NoSuchResourceException no matching resource(s) found
   * @throws NoSuchParentResourceException a specified parent resource doesn't exist
   */
  public RequestStatus updateResources(Resource.Type type,
                                       Request request,
                                       Predicate predicate)
      throws UnsupportedPropertyException,
             SystemException,
             NoSuchResourceException,
             NoSuchParentResourceException;

  /**
   * Delete the resources selected by the given predicate.
   *
   * @param type      the type of the resources
   * @param predicate the predicate object which can be used to filter which
   *                  resources are deleted
   *
   * @throws UnsupportedPropertyException thrown if the predicate contains
   *                                      unsupported property ids
   * @throws SystemException an internal exception occurred
   * @throws NoSuchResourceException no matching resource(s) found
   * @throws NoSuchParentResourceException a specified parent resource doesn't exist
   */
  public RequestStatus deleteResources(Resource.Type type, Predicate predicate)
      throws UnsupportedPropertyException,
             SystemException,
             NoSuchResourceException,
             NoSuchParentResourceException ;
}

redpajama_set_name: RedPajamaGithub


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

<TITLE>
GameMovable
</TITLE>

<META NAME="date" CONTENT="2008-12-19">

<LINK REL ="stylesheet" TYPE="text/css" HREF="../../stylesheet.css" TITLE="Style">

      Overview
      Package
    Class
      Use
      Tree
      Deprecated
      Index
      Help

 PREV CLASS
 NEXT CLASS

  FRAMES
 NO FRAMES

  All Classes

  SUMMARY: NESTED | FIELD | CONSTR | METHOD

DETAIL: FIELD | CONSTR | METHOD

gameframework.game

Class GameMovable

java.lang.Object
  gameframework.game.GameMovable

All Implemented Interfaces:
Movable, ObjectWithBoundedBox

Direct Known Subclasses:
Ghost, Pacman

public abstract class GameMovable
extends java.lang.Object
implements Movable

Field Summary

(package private)  SpeedVector
direction

(package private)  GameMovableDriver
moveDriver

(package private)  java.awt.Point
position

Constructor Summary

GameMovable()

Method Summary

 GameMovableDriver
getDriver()

 java.awt.Point
getPosition()

 SpeedVector
getSpeedVector()

 void
oneStepMove()

abstract  void
oneStepMoveHandler()

          Add some behavior to oneStepMove

 void
setDriver(GameMovableDriver drv)

 void
setPosition(java.awt.Point p)

 void
setSpeedVector(SpeedVector speedVector)

Methods inherited from class java.lang.Object

clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait

Methods inherited from interface gameframework.base.ObjectWithBoundedBox

getBoundingBox

Field Detail

moveDriver

GameMovableDriver moveDriver

position

java.awt.Point position

direction

SpeedVector direction

Constructor Detail

GameMovable

public GameMovable()

Method Detail

setPosition

public void setPosition(java.awt.Point p)

getPosition

public java.awt.Point getPosition()

Specified by:
getPosition in interface Movable

setSpeedVector

public void setSpeedVector(SpeedVector speedVector)

Specified by:
setSpeedVector in interface Movable

getSpeedVector

public SpeedVector getSpeedVector()

Specified by:
getSpeedVector in interface Movable

setDriver

public void setDriver(GameMovableDriver drv)

getDriver

public GameMovableDriver getDriver()

oneStepMove

public void oneStepMove()

Specified by:
oneStepMove in interface Movable

oneStepMoveHandler

public abstract void oneStepMoveHandler()

Add some behavior to oneStepMove

      Overview
      Package
    Class
      Use
      Tree
      Deprecated
      Index
      Help

 PREV CLASS
 NEXT CLASS

  FRAMES
 NO FRAMES

  All Classes

  SUMMARY: NESTED | FIELD | CONSTR | METHOD

DETAIL: FIELD | CONSTR | METHOD


text:
namespace IoerContentBusinessEntities
{
    using System;
    using System.Collections.Generic;

    public partial class Library_SectionType
    {
        public Library_SectionType()
        {
            this.Library_Section = new HashSet<Library_Section>();
        }

        public int Id { get; set; }
        public string Title { get; set; }
        public Nullable<bool> AreContentsReadOnly { get; set; }
        public string Decription { get; set; }
        public string SectionCode { get; set; }
        public Nullable<System.DateTime> Created { get; set; }

        public virtual ICollection<Library_Section> Library_Section { get; set; }
    }
}


text:
package com.vladsch.flexmark.ext.anchorlink;

import com.vladsch.flexmark.core.test.util.RendererSpecTest;
import com.vladsch.flexmark.html.HtmlRenderer;
import com.vladsch.flexmark.parser.Parser;
import com.vladsch.flexmark.test.util.spec.ResourceLocation;
import com.vladsch.flexmark.test.util.spec.SpecExample;
import com.vladsch.flexmark.util.data.DataHolder;
import com.vladsch.flexmark.util.data.MutableDataSet;
import org.jetbrains.annotations.NotNull;
import org.junit.runners.Parameterized;

import java.util.Collections;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

public class ComboAnchorLinkSpecTest extends RendererSpecTest {
    final private static String SPEC_RESOURCE = "/ext_anchorlink_ast_spec.md";
    final public static @NotNull ResourceLocation RESOURCE_LOCATION = ResourceLocation.of(SPEC_RESOURCE);
    final private static DataHolder OPTIONS = new MutableDataSet()
            .set(Parser.EXTENSIONS, Collections.singleton(AnchorLinkExtension.create()))
            .set(AnchorLinkExtension.ANCHORLINKS_ANCHOR_CLASS, "anchor")
            .set(AnchorLinkExtension.ANCHORLINKS_NO_BLOCK_QUOTE, true)
            .set(HtmlRenderer.RENDER_HEADER_ID, false)
            .set(HtmlRenderer.GENERATE_HEADER_ID, true)
            .toImmutable();

    final private static Map<String, DataHolder> optionsMap = new HashMap<>();
    static {
        optionsMap.put("no-wrap", new MutableDataSet().set(AnchorLinkExtension.ANCHORLINKS_WRAP_TEXT, false));
        optionsMap.put("set-name", new MutableDataSet().set(AnchorLinkExtension.ANCHORLINKS_SET_NAME, true));
        optionsMap.put("no-id", new MutableDataSet().set(AnchorLinkExtension.ANCHORLINKS_SET_ID, false));
        optionsMap.put("no-class", new MutableDataSet().set(AnchorLinkExtension.ANCHORLINKS_ANCHOR_CLASS, ""));
        optionsMap.put("prefix-suffix", new MutableDataSet()
                .set(AnchorLinkExtension.ANCHORLINKS_TEXT_PREFIX, "")
                .set(AnchorLinkExtension.ANCHORLINKS_TEXT_SUFFIX, "")
        );
    }
    public ComboAnchorLinkSpecTest(@NotNull SpecExample example) {
        super(example, optionsMap, OPTIONS);
    }

    @Parameterized.Parameters(name = "{0}")
    public static List<Object[]> data() {
        return getTestData(RESOURCE_LOCATION);
    }
}


text:
exports.name = 'ejs';
exports.category = 'template';
exports.homepage = 'https://github.com/visionmedia/ejs';


text:
package com.atlassian.jira.plugin.ext.subversion.revisions;

import com.atlassian.core.ofbiz.test.mock.MockGenericValue;
import com.atlassian.core.util.map.EasyMap;
import com.atlassian.jira.config.util.IndexPathManager;
import com.atlassian.jira.issue.Issue;
import com.atlassian.jira.issue.IssueManager;
import com.atlassian.jira.issue.MutableIssue;
import com.atlassian.jira.issue.changehistory.ChangeHistoryManager;
import com.atlassian.jira.issue.index.IndexException;
import com.atlassian.jira.plugin.ext.subversion.MultipleSubversionRepositoryManager;
import com.atlassian.jira.plugin.ext.subversion.SubversionManager;
import com.atlassian.jira.project.version.Version;
import com.atlassian.jira.project.version.VersionManager;
import com.atlassian.jira.security.PermissionManager;
import com.atlassian.jira.security.Permissions;
import com.atlassian.jira.service.ServiceManager;
import com.atlassian.jira.util.EasyList;
import com.atlassian.jira.util.LuceneUtils;
import org.apache.commons.io.FileUtils;
import org.apache.commons.lang.RandomStringUtils;
import org.apache.commons.lang.StringUtils;
import org.apache.commons.lang.SystemUtils;
import org.apache.lucene.document.DateField;
import org.apache.lucene.document.Document;
import org.apache.lucene.document.Field;
import org.apache.lucene.index.IndexReader;
import org.apache.lucene.index.IndexWriter;
import org.apache.lucene.index.Term;
import org.apache.lucene.index.TermDocs;
import org.jmock.Mock;
import org.jmock.cglib.MockObjectTestCase;
import org.jmock.core.constraint.IsAnything;
import org.ofbiz.core.entity.GenericValue;
import org.tmatesoft.svn.core.SVNException;
import org.tmatesoft.svn.core.SVNLogEntry;

import java.io.File;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Date;
import java.util.List;
import java.util.Map;

/**
 *
 */
public class TestRevisionIndexer extends MockObjectTestCase
{

    private static final String MY_BS_INDEX_PATH = "mybsindexpath";

    private static final String MY_NEW_BS_INDEX_PATH = "mynewbsindexpath";

    private Mock mockMultipleSubversionRepositoryManager;

    private MultipleSubversionRepositoryManager multipleSubversionRepositoryManager;

    private Mock mockSvnMgr;

    private SubversionManager svnMgr;

    private Mock mockPermissionManager;

    private PermissionManager permissionManager;

    private ChangeHistoryManager changeHistoryManager;

    private Mock mockChangeHistoryManager;

    private Mock mockIssueManager;

    private IssueManager issueManager;

    private Mock mockVersionManager;

    private VersionManager versionManager;

    private Mock mockServiceManager;

    private ServiceManager serviceManager;

    private File temporaryIndexDirectory;

    private IndexPathManager indexPathManager;

    private Mock mockIndexPathManager;

    private String getIndexPath()
    {
        return new StringBuffer(temporaryIndexDirectory.getAbsolutePath()).append(SystemUtils.FILE_SEPARATOR).append(RevisionIndexer.REVISIONS_INDEX_DIRECTORY).toString();
    }

    protected void setUp() throws Exception
    {
        super.setUp();

        /* Setup temporary index directory */
        do
        {
            temporaryIndexDirectory = new File(SystemUtils.JAVA_IO_TMPDIR, RandomStringUtils.randomAlphanumeric(16));
        }
        while (temporaryIndexDirectory.exists());
        temporaryIndexDirectory.mkdirs();

        mockIndexPathManager = new Mock(IndexPathManager.class);
        mockIndexPathManager.expects(atLeastOnce()).method("getPluginIndexRootPath").withNoArguments().will(returnValue(temporaryIndexDirectory.getAbsolutePath()));
        indexPathManager = (IndexPathManager) mockIndexPathManager.proxy();

        mockMultipleSubversionRepositoryManager = new Mock(MultipleSubversionRepositoryManager.class);
        mockMultipleSubversionRepositoryManager
                .expects(atLeastOnce())
                .method("getRepositoryList")
                .withNoArguments()
                .will(returnValue(Collections.EMPTY_LIST));
        multipleSubversionRepositoryManager = (MultipleSubversionRepositoryManager) mockMultipleSubversionRepositoryManager.proxy();

        mockSvnMgr = new Mock(SubversionManager.class);
        svnMgr = (SubversionManager) mockSvnMgr.proxy();

        mockPermissionManager = new Mock(PermissionManager.class);
        permissionManager = (PermissionManager) mockPermissionManager.proxy();

        List<String> previousIssueKeys = new ArrayList<String>();
        previousIssueKeys.add("APR-137");
        previousIssueKeys.add("FPR-49");
        mockChangeHistoryManager = new Mock(ChangeHistoryManager.class);
        mockChangeHistoryManager
                .expects(atMostOnce())
                .method("getPreviousIssueKeys")
                .will(returnValue(previousIssueKeys));
        changeHistoryManager = (ChangeHistoryManager) mockChangeHistoryManager.proxy();

        mockIssueManager = new Mock(IssueManager.class);
        issueManager = (IssueManager) mockIssueManager.proxy();

        mockVersionManager = new Mock(VersionManager.class);
        versionManager = (VersionManager) mockVersionManager.proxy();

        mockServiceManager = new Mock(ServiceManager.class);
        serviceManager = (ServiceManager) mockServiceManager.proxy();
    }

    protected void tearDown() throws Exception
    {
        if (temporaryIndexDirectory.exists())
        {
            try
            {
                FileUtils.deleteDirectory(temporaryIndexDirectory);
            }
            catch (final IOException ioe)
            {
                ioe.printStackTrace();
            }
        }
        super.tearDown();
    }

    protected RevisionIndexer getRevisionIndexer()
    {
        return new RevisionIndexer(
                multipleSubversionRepositoryManager,
                versionManager, issueManager, permissionManager, changeHistoryManager, serviceManager, indexPathManager);
    }

    // This is here for the fix for SVN-123
    public void testIndexDirectoryNotCached()
    {
        mockIndexPathManager.reset();
        mockIndexPathManager.expects(exactly(3)).method("getPluginIndexRootPath").withNoArguments().will(
                onConsecutiveCalls(
                        returnValue(MY_BS_INDEX_PATH),
                        returnValue(MY_NEW_BS_INDEX_PATH), // Updated index path
                        returnValue(MY_NEW_BS_INDEX_PATH) // Updated index path
                )
        );

        RevisionIndexer revisionIndexer = getRevisionIndexer();
        assertEquals(MY_BS_INDEX_PATH + System.getProperty("file.separator") + RevisionIndexer.REVISIONS_INDEX_DIRECTORY, revisionIndexer.getIndexPath());

        assertEquals(MY_NEW_BS_INDEX_PATH + System.getProperty("file.separator") + RevisionIndexer.REVISIONS_INDEX_DIRECTORY, revisionIndexer.getIndexPath());
        assertNotSame(MY_BS_INDEX_PATH + System.getProperty("file.separator") + RevisionIndexer.REVISIONS_INDEX_DIRECTORY, revisionIndexer.getIndexPath());
    }

    public void testUpdateIndexWithNoIndexDirectorWhenEverythingIsOk() throws IOException, IndexException
    {
        SVNLogEntry svnLogEntry;
        RevisionIndexer revisionIndexer;

        /* Setup the repository to return one svn entry (revision 0) */
        svnLogEntry = new SVNLogEntry(Collections.EMPTY_MAP, 0, "dchui", new Date(), "TST-1");

        mockSvnMgr.expects(atLeastOnce()).method("getId").withNoArguments().will(returnValue(1L));
        mockSvnMgr.expects(atLeastOnce()).method("isActive").withNoArguments().will(returnValue(true));
        mockSvnMgr.expects(atLeastOnce()).method("getLogEntries").with(eq(-1L)).will(returnValue(EasyList.build(svnLogEntry)));

        mockMultipleSubversionRepositoryManager.reset();
        mockMultipleSubversionRepositoryManager
                .expects(atLeastOnce())
                .method("getRepositoryList")
                .withNoArguments()
                .will(returnValue(EasyList.build(svnMgr)));

        revisionIndexer = new RevisionIndexer(multipleSubversionRepositoryManager,
                null, null, null, null, null, indexPathManager)
        {
            protected boolean isKeyInString(SVNLogEntry logEntry)
            {
                return true;
            }

            protected List<String> getIssueKeysFromString(SVNLogEntry logEntry)
            {
                return EasyList.build("TST-1");
            }

            protected String getProjectKeyFromIssueKey(String issueKey)
            {
                return "TST";
            }
        };
        revisionIndexer.updateIndex();

        /* Check if a document gets indexed */
        IndexReader indexReader = LuceneUtils.getIndexReader(revisionIndexer.getIndexPath());
        assertEquals(1, indexReader.numDocs());
        indexReader.close();
    }

    public void testUpdateIndexWithNoIndexDirectoryWhenEntryHasEmptyCommitMessage() throws IOException, IndexException
    {
        SVNLogEntry svnLogEntry;
        RevisionIndexer revisionIndexer;

        /* Setup the repository to return one svn entry (revision 0) */
        svnLogEntry = new SVNLogEntry(Collections.EMPTY_MAP, 0, "dchui", new Date(), StringUtils.EMPTY);

        mockSvnMgr.expects(atLeastOnce()).method("getId").withNoArguments().will(returnValue(1L));
        mockSvnMgr.expects(atLeastOnce()).method("isActive").withNoArguments().will(returnValue(true));
        mockSvnMgr.expects(atLeastOnce()).method("getLogEntries").with(eq(-1L)).will(returnValue(EasyList.build(svnLogEntry)));

        mockMultipleSubversionRepositoryManager.reset();
        mockMultipleSubversionRepositoryManager
                .expects(atLeastOnce())
                .method("getRepositoryList")
                .withNoArguments()
                .will(returnValue(EasyList.build(svnMgr)));

        revisionIndexer = getRevisionIndexer();
        revisionIndexer.updateIndex();

        /* Check nothing gets indexed */
        IndexReader indexReader = LuceneUtils.getIndexReader(revisionIndexer.getIndexPath());
        assertEquals(0, indexReader.numDocs());
        indexReader.close();
    }

    public void testUpdateIndexWithNoIndexDirectoryWhenEntryCommitMessageHasNoJiraKeys() throws IOException, IndexException
    {
        SVNLogEntry svnLogEntry;
        RevisionIndexer revisionIndexer;

        /* Setup the repository to return one svn entry (revision 0) */
        svnLogEntry = new SVNLogEntry(Collections.EMPTY_MAP, 0, "dchui", new Date(), "There is no JIRA key here.");

        mockSvnMgr.expects(atLeastOnce()).method("getId").withNoArguments().will(returnValue(1L));
        mockSvnMgr.expects(atLeastOnce()).method("isActive").withNoArguments().will(returnValue(true));
        mockSvnMgr.expects(atLeastOnce()).method("getLogEntries").with(eq(-1L)).will(returnValue(EasyList.build(svnLogEntry)));

        mockMultipleSubversionRepositoryManager.reset();
        mockMultipleSubversionRepositoryManager
                .expects(atLeastOnce())
                .method("getRepositoryList")
                .withNoArguments()
                .will(returnValue(EasyList.build(svnMgr)));

        revisionIndexer = new RevisionIndexer(multipleSubversionRepositoryManager,
                null, null, null, null, null, indexPathManager)
        {
            protected boolean isKeyInString(SVNLogEntry logEntry)
            {
                return false;
            }
        };
        revisionIndexer.updateIndex();

        /* Check nothing gets indexed */
        IndexReader indexReader = LuceneUtils.getIndexReader(revisionIndexer.getIndexPath());
        assertEquals(0, indexReader.numDocs());
        indexReader.close();
    }

    /**
     * Tests that the RevisionIndexer will handle each repository even if method calls on prior repositories throw
     * exceptions.
     *
     * @throws Exception wheneva
     */
    public void testUpdateIndexRepositoryThrowsException() throws Exception
    {
        Mock mockSubversionManagerExploding;
        Mock mockSubversionManagerNonExploding;

        /* The exploding SubversionManager */
        mockSubversionManagerExploding = new Mock(SubversionManager.class);
        mockSubversionManagerExploding.expects(atLeastOnce()).method("getId").withNoArguments().will(returnValue(1L));
        mockSubversionManagerExploding.expects(atLeastOnce()).method("isActive").withNoArguments().will(returnValue(true));
        mockSubversionManagerExploding.expects(atLeastOnce()).method("getDisplayName").withNoArguments().will(returnValue("Repository 1"));
        mockSubversionManagerExploding
                .expects(once())
                .method("getLogEntries")
                .withAnyArguments()
                .will(throwException(new RuntimeException("Exploding MockSubversionManager has exploded.")));

        /* The non exploding SubversionManager */
        mockSubversionManagerNonExploding = new Mock(SubversionManager.class);
        mockSubversionManagerNonExploding.expects(atLeastOnce()).method("getId").withNoArguments().will(returnValue(1L));
        mockSubversionManagerNonExploding.expects(atLeastOnce()).method("isActive").withNoArguments().will(returnValue(true));
//        mockSubversionManagerNonExploding.expects(atLeastOnce()).method("getDisplayName").withNoArguments().will(returnValue("Repository 2"));
        mockSubversionManagerNonExploding
                .expects(once())
                .method("getLogEntries")
                .withAnyArguments()
                .will(returnValue(Collections.EMPTY_LIST));

        mockMultipleSubversionRepositoryManager.reset();
        mockMultipleSubversionRepositoryManager
                .expects(atLeastOnce())
                .method("getRepositoryList")
                .withNoArguments()
                .will(returnValue(EasyList.build(mockSubversionManagerExploding.proxy(), mockSubversionManagerNonExploding.proxy())));

        // instantiate class under test
        RevisionIndexer ri = new RevisionIndexer(
                (MultipleSubversionRepositoryManager) mockMultipleSubversionRepositoryManager.proxy(),
                null, null, null, null, null, indexPathManager)
        {
            protected Long getLatestIndexedRevision(long repoId)
            {
                return 123L;
            }
        };

        try
        {
            ri.updateIndex();
        }
        catch (RuntimeException e)
        {
            fail("The exception thrown from one repository should not propagate out of the all-repo index update method.");
        }
        // from this test point of view we don't really care which methods are called on the repo, if any were called,
        // then the RevisionIndexer didn't catch exceptions outside the while loop
//        assertTrue("The RevisionIndexer probably blew up attempting to index the first repo (SVN-158)", mildManneredRepo.isMethodsCalled());
        mockSubversionManagerNonExploding.verify();
        mockMultipleSubversionRepositoryManager.verify();
    }

    public void testGetLogEntriesByRepositoryWhenIndexDirectoryDoesNotExist() throws IOException, IndexException
    {
        Mock mockIssue;
        Issue issue;
        RevisionIndexer revisionIndexer;

        mockIssue = new Mock(Issue.class);
        mockIssue.expects(atLeastOnce()).method("getKey").withNoArguments().will(returnValue("TSTS-1"));
        issue = (Issue) mockIssue.proxy();

        mockIndexPathManager.reset();
        mockIndexPathManager
                .expects(atLeastOnce())
                .method("getPluginIndexRootPath")
                .withNoArguments()
                .will(returnValue(temporaryIndexDirectory.getAbsolutePath() + "-aPrefixMakingItAnInvalidDirectory"));

        revisionIndexer = getRevisionIndexer();
        assertNull(revisionIndexer.getLogEntriesByRepository(issue));
    }

    public void testGetLogEntriesByRepositoryWhenIssueKeyDoesNotMatch() throws IOException, IndexException
    {
        Mock mockIssue;
        Issue issue;
        RevisionIndexer revisionIndexer;
        IndexWriter indexWriter;
        Document doc;

        /* Setup the issue to be used in the query */
        mockIssue = new Mock(Issue.class);
        mockIssue.expects(atLeastOnce()).method("getId").withNoArguments().will(returnValue(new Long(10000L)));
        mockIssue.expects(atLeastOnce()).method("getKey").withNoArguments().will(returnValue("TST-1"));
        issue = (Issue) mockIssue.proxy();

        /* Populate the search index */
        indexWriter = LuceneUtils.getIndexWriter(getIndexPath(), true, RevisionIndexer.ANALYZER);

        doc = new Document();
        doc.add(new Field(RevisionIndexer.FIELD_ISSUEKEY, "TST-2", Field.Store.YES, Field.Index.UN_TOKENIZED));
        doc.add(new Field(RevisionIndexer.FIELD_DATE, DateField.dateToString(new Date()), Field.Store.YES, Field.Index.UN_TOKENIZED));
        indexWriter.addDocument(doc);
        indexWriter.flush();
        indexWriter.close();

        revisionIndexer = getRevisionIndexer();
        assertEquals(0, revisionIndexer.getLogEntriesByRepository(issue).size());
    }

    public void testGetLogEntriesByRepositoryWhenRevisionCannotBeFoundInRepository() throws IOException, IndexException
    {
        Mock mockIssue;
        Issue issue;
        RevisionIndexer revisionIndexer;
        IndexWriter indexWriter;
        Document doc;

        /* Setup the issue to be used in the query */
        mockIssue = new Mock(Issue.class);
        mockIssue.expects(atLeastOnce()).method("getId").withNoArguments().will(returnValue(new Long(10000L)));
        mockIssue.expects(atLeastOnce()).method("getKey").withNoArguments().will(returnValue("TST-1"));
        issue = (Issue) mockIssue.proxy();

        /* Populate the search index */
        indexWriter = LuceneUtils.getIndexWriter(getIndexPath(), true, RevisionIndexer.ANALYZER);

        doc = new Document();
        doc.add(new Field(RevisionIndexer.FIELD_ISSUEKEY, "TST-1", Field.Store.YES, Field.Index.UN_TOKENIZED));
        doc.add(new Field(RevisionIndexer.FIELD_REPOSITORY, "1", Field.Store.YES, Field.Index.UN_TOKENIZED));
        doc.add(new Field(RevisionIndexer.FIELD_REVISIONNUMBER, "0", Field.Store.YES, Field.Index.UN_TOKENIZED));
        doc.add(new Field(RevisionIndexer.FIELD_DATE, DateField.dateToString(new Date()), Field.Store.YES, Field.Index.UN_TOKENIZED));
        indexWriter.addDocument(doc);
        indexWriter.flush();
        indexWriter.close();

        mockSvnMgr.expects(once()).method("getLogEntry").with(eq(0L)).will(returnValue(null));
        mockMultipleSubversionRepositoryManager
                .expects(once())
                .method("getRepository")
                .with(eq(1L))
                .will(returnValue(svnMgr));

        revisionIndexer = getRevisionIndexer();
        assertEquals(0, revisionIndexer.getLogEntriesByRepository(issue).size());
    }

    public void testGetLogEntriesByRepositorySorted() throws IOException, IndexException
    {
        Mock mockIssue;
        Issue issue;
        RevisionIndexer revisionIndexer;
        IndexWriter indexWriter;
        Document doc;

        /* Setup the issue to be used in the query */
        mockIssue = new Mock(Issue.class);
        mockIssue.expects(atLeastOnce()).method("getId").withNoArguments().will(returnValue(new Long(10000L)));
        mockIssue.expects(atLeastOnce()).method("getKey").withNoArguments().will(returnValue("TST-1"));
        issue = (Issue) mockIssue.proxy();

        /* Populate the search index */
        indexWriter = LuceneUtils.getIndexWriter(getIndexPath(), true, RevisionIndexer.ANALYZER);

        long nowInMillis = System.currentTimeMillis();

        /* This is the first matching document with revision 1 */
        doc = new Document();
        doc.add(new Field(RevisionIndexer.FIELD_ISSUEKEY, "TST-1", Field.Store.YES, Field.Index.UN_TOKENIZED));
        doc.add(new Field(RevisionIndexer.FIELD_REPOSITORY, "1", Field.Store.YES, Field.Index.UN_TOKENIZED));
        doc.add(new Field(RevisionIndexer.FIELD_REVISIONNUMBER, "1", Field.Store.YES, Field.Index.UN_TOKENIZED));
        doc.add(new Field(RevisionIndexer.FIELD_DATE, DateField.dateToString(new Date(nowInMillis + 1000)), Field.Store.YES, Field.Index.UN_TOKENIZED));
        indexWriter.addDocument(doc);

        /* This is the second matching document with revision 0 */
        doc = new Document();
        doc.add(new Field(RevisionIndexer.FIELD_ISSUEKEY, "TST-1", Field.Store.YES, Field.Index.UN_TOKENIZED));
        doc.add(new Field(RevisionIndexer.FIELD_REPOSITORY, "1", Field.Store.YES, Field.Index.UN_TOKENIZED));
        doc.add(new Field(RevisionIndexer.FIELD_REVISIONNUMBER, "0", Field.Store.YES, Field.Index.UN_TOKENIZED));
        doc.add(new Field(RevisionIndexer.FIELD_DATE, DateField.dateToString(new Date(nowInMillis)), Field.Store.YES, Field.Index.UN_TOKENIZED));
        indexWriter.addDocument(doc);

        indexWriter.flush();
        indexWriter.close();

        SVNLogEntry firstCommit = new SVNLogEntry(Collections.EMPTY_MAP, 0, "dchui", new Date(), "TST-1 First commit");
        SVNLogEntry secondCommit = new SVNLogEntry(Collections.EMPTY_MAP, 1, "dchui", new Date(), "TST-1 Second commmit");

        mockSvnMgr.expects(exactly(2)).method("getLogEntry").with(isA(Long.class)).will(
                onConsecutiveCalls(
                        returnValue(firstCommit),
                        returnValue(secondCommit)
                )
        );
        mockMultipleSubversionRepositoryManager
                .expects(exactly(2))
                .method("getRepository")
                .with(eq(1L))
                .will(returnValue(svnMgr));

        Map entriesMap;
        List entries;
        revisionIndexer = getRevisionIndexer();

        entriesMap = revisionIndexer.getLogEntriesByRepository(issue);
        assertEquals(1, entriesMap.size());

        entries = (List) entriesMap.get(1L); /* Get entries from repository with ID 1 */

        assertEquals(2, entries.size());
        /* Earlier commits go on top */
        assertSame(firstCommit, entries.get(0));
        assertSame(secondCommit, entries.get(1));
    }

    public void testGetLogEntriesByProjectWhenUserHasNoPermissionToViewAnyIssuesMentionedInSvnCommit() throws IOException, IndexException
    {
        Mock mockIssue;
        Issue issue;
        IndexWriter indexWriter;
        Document doc;
        RevisionIndexer revisionIndexer;

        /* Populate the search index */
        indexWriter = LuceneUtils.getIndexWriter(getIndexPath(), true, RevisionIndexer.ANALYZER);

        /* This is the first matching document with revision 1 */
        doc = new Document();
        doc.add(new Field(RevisionIndexer.FIELD_PROJECTKEY, "TST", Field.Store.YES, Field.Index.UN_TOKENIZED));
        doc.add(new Field(RevisionIndexer.FIELD_ISSUEKEY, "TST-1", Field.Store.YES, Field.Index.UN_TOKENIZED));
        doc.add(new Field(RevisionIndexer.FIELD_REPOSITORY, "1", Field.Store.YES, Field.Index.UN_TOKENIZED));
        doc.add(new Field(RevisionIndexer.FIELD_REVISIONNUMBER, "1", Field.Store.YES, Field.Index.UN_TOKENIZED));
        doc.add(new Field(RevisionIndexer.FIELD_DATE, DateField.dateToString(new Date()), Field.Store.YES, Field.Index.UN_TOKENIZED));
        indexWriter.addDocument(doc);

        indexWriter.close();

        mockIssue = new Mock(MutableIssue.class);
        issue = (Issue) mockIssue.proxy();

        mockIssueManager.expects(once()).method("getIssueObject").with(eq("TST-1")).will(returnValue(issue));
        mockPermissionManager.expects(once()).method("hasPermission")
                .with(eq(Permissions.VIEW_VERSION_CONTROL), same(issue), new IsAnything())
                .will(returnValue(false));

        Map entriesMap;

        revisionIndexer = getRevisionIndexer();
        entriesMap = revisionIndexer.getLogEntriesByProject("TST", null, 0, Integer.MAX_VALUE);

        assertEquals(0, entriesMap.size());
    }

    public void testGetLogEntriesByProjectWhenUserHasPermissionToViewTheIssuesMentionedInSvnCommitButRevisionCannotBeFoundInAnyRepository() throws IOException, IndexException
    {
        Mock mockIssue;
        Issue issue;
        IndexWriter indexWriter;
        Document doc;
        RevisionIndexer revisionIndexer;

        /* Populate the search index */
        indexWriter = LuceneUtils.getIndexWriter(getIndexPath(), true, RevisionIndexer.ANALYZER);

        /* This is the first matching document with revision 1 */
        doc = new Document();
        doc.add(new Field(RevisionIndexer.FIELD_PROJECTKEY, "TST", Field.Store.YES, Field.Index.UN_TOKENIZED));
        doc.add(new Field(RevisionIndexer.FIELD_ISSUEKEY, "TST-1", Field.Store.YES, Field.Index.UN_TOKENIZED));
        doc.add(new Field(RevisionIndexer.FIELD_REPOSITORY, "1", Field.Store.YES, Field.Index.UN_TOKENIZED));
        doc.add(new Field(RevisionIndexer.FIELD_REVISIONNUMBER, "1", Field.Store.YES, Field.Index.UN_TOKENIZED));
        doc.add(new Field(RevisionIndexer.FIELD_DATE, DateField.dateToString(new Date()), Field.Store.YES, Field.Index.UN_TOKENIZED));
        indexWriter.addDocument(doc);

        indexWriter.close();

        mockIssue = new Mock(MutableIssue.class);
        issue = (Issue) mockIssue.proxy();

        mockIssueManager.expects(once()).method("getIssueObject").with(eq("TST-1")).will(returnValue(issue));
        mockPermissionManager.expects(once()).method("hasPermission")
                .with(eq(Permissions.VIEW_VERSION_CONTROL), same(issue), new IsAnything())
                .will(returnValue(true));

        mockSvnMgr.expects(once()).method("getLogEntry").with(eq(1L)).will(returnValue(null));
        mockMultipleSubversionRepositoryManager.expects(once()).method("getRepository").with(eq(1L)).will(returnValue(svnMgr));

        Map entriesMap;

        revisionIndexer = getRevisionIndexer();
        entriesMap = revisionIndexer.getLogEntriesByProject("TST", null, 0, Integer.MAX_VALUE);

        assertEquals(0, entriesMap.size());
    }

    public void testGetLogEntriesByProjectWhenEverythingIsOk() throws IOException, IndexException
    {
        Mock mockIssue;
        Issue issue;
        IndexWriter indexWriter;
        Document doc;
        RevisionIndexer revisionIndexer;
        SVNLogEntry svnLogEntry;

        /* Populate the search index */
        indexWriter = LuceneUtils.getIndexWriter(getIndexPath(), true, RevisionIndexer.ANALYZER);

        /* This is the first matching document with revision 1 */
        doc = new Document();
        doc.add(new Field(RevisionIndexer.FIELD_PROJECTKEY, "TST", Field.Store.YES, Field.Index.UN_TOKENIZED));
        doc.add(new Field(RevisionIndexer.FIELD_ISSUEKEY, "TST-1", Field.Store.YES, Field.Index.UN_TOKENIZED));
        doc.add(new Field(RevisionIndexer.FIELD_REPOSITORY, "1", Field.Store.YES, Field.Index.UN_TOKENIZED));
        doc.add(new Field(RevisionIndexer.FIELD_REVISIONNUMBER, "1", Field.Store.YES, Field.Index.UN_TOKENIZED));
        doc.add(new Field(RevisionIndexer.FIELD_DATE, DateField.dateToString(new Date()), Field.Store.YES, Field.Index.UN_TOKENIZED));
        indexWriter.addDocument(doc);

        indexWriter.close();

        mockIssue = new Mock(MutableIssue.class);
        issue = (Issue) mockIssue.proxy();

        mockIssueManager.expects(once()).method("getIssueObject").with(eq("TST-1")).will(returnValue(issue));
        mockPermissionManager.expects(once()).method("hasPermission")
                .with(eq(Permissions.VIEW_VERSION_CONTROL), same(issue), new IsAnything())
                .will(returnValue(true));

        svnLogEntry = new SVNLogEntry(Collections.EMPTY_MAP, 1L, "dchui", new Date(), "TST-1");
        mockSvnMgr.expects(once()).method("getLogEntry").with(eq(1L)).will(returnValue(svnLogEntry));
        mockMultipleSubversionRepositoryManager.expects(once()).method("getRepository").with(eq(1L)).will(returnValue(svnMgr));

        Map entriesMap;
        List entries;

        revisionIndexer = getRevisionIndexer();
        entriesMap = revisionIndexer.getLogEntriesByProject("TST", null, 0, Integer.MAX_VALUE);
        entries = (List) entriesMap.get(1L);

        assertEquals(1, entriesMap.size()); /* There should be 1 entry because it matches repository 1 */
        assertEquals(1, entries.size()); /* There should be 1 entry because it matches revision 1 */
        assertSame(svnLogEntry, entries.get(0));
    }

    public void testGetLogEntriesByVersionWhenUserHasNoPermissionToViewAnyIssuesOfVersionSpecified() throws IOException, IndexException
    {
        Mock mockIssue;
        Issue issueObject;
        GenericValue issue;
        IndexWriter indexWriter;
        Document doc;

        issue = new MockGenericValue("Issue", EasyMap.build("key", "TST-1"));

        mockVersionManager.expects(once()).method("getFixIssues").withAnyArguments().will(returnValue(EasyList.build(issue)));
        mockVersionManager.expects(once()).method("getAffectsIssues").withAnyArguments().will(returnValue(EasyList.build(issue)));

        /* Populate the search index */
        indexWriter = LuceneUtils.getIndexWriter(getIndexPath(), true, RevisionIndexer.ANALYZER);

        /* This is the first matching document with revision 1 */
        doc = new Document();
        doc.add(new Field(RevisionIndexer.FIELD_ISSUEKEY, "TST-1", Field.Store.YES, Field.Index.UN_TOKENIZED));
        doc.add(new Field(RevisionIndexer.FIELD_REPOSITORY, "1", Field.Store.YES, Field.Index.UN_TOKENIZED));
        doc.add(new Field(RevisionIndexer.FIELD_REVISIONNUMBER, "1", Field.Store.YES, Field.Index.UN_TOKENIZED));
        doc.add(new Field(RevisionIndexer.FIELD_DATE, DateField.dateToString(new Date()), Field.Store.YES, Field.Index.UN_TOKENIZED));
        indexWriter.addDocument(doc);

        indexWriter.close();

        mockIssue = new Mock(MutableIssue.class);
        issueObject = (Issue) mockIssue.proxy();

        mockIssueManager.expects(once()).method("getIssueObject").with(eq("TST-1")).will(returnValue(issueObject));
        mockPermissionManager.expects(once()).method("hasPermission")
                .with(eq(Permissions.VIEW_VERSION_CONTROL), same(issueObject), new IsAnything())
                .will(returnValue(false));

        Map entriesMap;

        RevisionIndexer revisionIndexer = getRevisionIndexer();
        entriesMap = revisionIndexer.getLogEntriesByVersion((Version) new Mock(Version.class).proxy(), null, 0, Integer.MAX_VALUE);

        assertEquals(0, entriesMap.size()); /* No matches */
    }

    public void testGetLogEntriesByVersionWhenEverythingIsOk() throws IOException, IndexException
    {
        Mock mockIssue;
        Issue issueObject;
        GenericValue issue;
        IndexWriter indexWriter;
        Document doc;
        SVNLogEntry svnLogEntry;

        issue = new MockGenericValue("Issue", EasyMap.build("key", "TST-1"));

        mockVersionManager.expects(once()).method("getFixIssues").withAnyArguments().will(returnValue(EasyList.build(issue)));
        mockVersionManager.expects(once()).method("getAffectsIssues").withAnyArguments().will(returnValue(EasyList.build(issue)));

        /* Populate the search index */
        indexWriter = LuceneUtils.getIndexWriter(getIndexPath(), true, RevisionIndexer.ANALYZER);

        /* This is the first matching document with revision 1 */
        doc = new Document();
        doc.add(new Field(RevisionIndexer.FIELD_ISSUEKEY, "TST-1", Field.Store.YES, Field.Index.UN_TOKENIZED));
        doc.add(new Field(RevisionIndexer.FIELD_REPOSITORY, "1", Field.Store.YES, Field.Index.UN_TOKENIZED));
        doc.add(new Field(RevisionIndexer.FIELD_REVISIONNUMBER, "1", Field.Store.YES, Field.Index.UN_TOKENIZED));
        doc.add(new Field(RevisionIndexer.FIELD_DATE, DateField.dateToString(new Date()), Field.Store.YES, Field.Index.UN_TOKENIZED));
        indexWriter.addDocument(doc);

        indexWriter.close();

        mockIssue = new Mock(MutableIssue.class);
        issueObject = (Issue) mockIssue.proxy();

        mockIssueManager.expects(once()).method("getIssueObject").with(eq("TST-1")).will(returnValue(issueObject));
        mockPermissionManager.expects(once()).method("hasPermission")
                .with(eq(Permissions.VIEW_VERSION_CONTROL), same(issueObject), new IsAnything())
                .will(returnValue(true));

        svnLogEntry = new SVNLogEntry(Collections.EMPTY_MAP, 1L, "dchui", new Date(), "TST-1");
        mockSvnMgr.expects(once()).method("getLogEntry").with(eq(1L)).will(returnValue(svnLogEntry));
        mockMultipleSubversionRepositoryManager.expects(once()).method("getRepository").with(eq(1L)).will(returnValue(svnMgr));

        Map entriesMap;
        List entries;

        RevisionIndexer revisionIndexer = getRevisionIndexer();
        entriesMap = revisionIndexer.getLogEntriesByVersion((Version) new Mock(Version.class).proxy(), null, 0, Integer.MAX_VALUE);
        entries = (List) entriesMap.get(1L);

        assertEquals(1, entriesMap.size()); /* There should be 1 entry because it matches repository 1 */
        assertEquals(1, entries.size()); /* There should be 1 entry because it matches revision 1 */
        assertSame(svnLogEntry, entries.get(0));
    }

    public void testAddRepository() throws IOException, IndexException
    {
        /* We'll start off with an empty index */
        IndexWriter indexWriter;
        IndexReader indexReader;
        RevisionIndexer revisionIndexer;
        SVNLogEntry entry;

        indexWriter = LuceneUtils.getIndexWriter(getIndexPath(), true, RevisionIndexer.ANALYZER);
        indexWriter.close();

        /* Create a SubversionManager which will contain one entry to be indexed */
        entry = new SVNLogEntry(Collections.EMPTY_MAP, 0, "dchui", new Date(), "TST-1");
        mockSvnMgr.expects(atLeastOnce()).method("getId").withNoArguments().will(returnValue(1L));
        mockSvnMgr.expects(atLeastOnce()).method("isActive").withNoArguments().will(returnValue(true));
        mockSvnMgr.expects(once()).method("getLogEntries").withAnyArguments().will(returnValue(EasyList.build(entry)));

        mockMultipleSubversionRepositoryManager.reset();
        mockMultipleSubversionRepositoryManager.expects(exactly(2)).method("getRepositoryList").withNoArguments().will(
                onConsecutiveCalls(
                        returnValue(Collections.EMPTY_LIST),
                        returnValue(EasyList.build(svnMgr))
                )
        );

        revisionIndexer = new RevisionIndexer(multipleSubversionRepositoryManager,
                versionManager, issueManager, permissionManager, changeHistoryManager, serviceManager, indexPathManager)
        {
            protected boolean isKeyInString(SVNLogEntry logEntry)
            {
                return true;
            }

            protected String getProjectKeyFromIssueKey(String issueKey)
            {
                return "TST";
            }

            protected List<String> getIssueKeysFromString(SVNLogEntry logEntry)
            {
                return EasyList.build("TST-1");
            }
        };
        revisionIndexer.addRepository(svnMgr);

        indexReader = LuceneUtils.getIndexReader(getIndexPath());

        final TermDocs termDocs = indexReader.termDocs(new Term(RevisionIndexer.FIELD_REPOSITORY, Long.toString(1L)));

        assertTrue(termDocs.next()); /* Contains one entry only */
        assertFalse(termDocs.next()); /* Should return false if there is only one entry */

        indexReader.close();
    }

    public void testRemoveEntries() throws IOException, IndexException, SVNException
    {
        /* We'll start off with an empty index */
        IndexWriter indexWriter;
        IndexReader indexReader;
        RevisionIndexer revisionIndexer;
        SVNLogEntry entry;

        indexWriter = LuceneUtils.getIndexWriter(getIndexPath(), true, RevisionIndexer.ANALYZER);
        indexWriter.close();

        /* Create a SubversionManager which will contain one entry to be indexed */
        entry = new SVNLogEntry(Collections.EMPTY_MAP, 0, "dchui", new Date(), "TST-1");
        mockSvnMgr.expects(atMostOnce()).method("getRoot").withNoArguments().will(returnValue(System.getProperty("svn.root")));
        mockSvnMgr.expects(atLeastOnce()).method("getId").withNoArguments().will(returnValue(1L));
        mockSvnMgr.expects(atLeastOnce()).method("isActive").withNoArguments().will(returnValue(true));
        mockSvnMgr.expects(atLeastOnce()).method("getLogEntries").withAnyArguments().will(returnValue(EasyList.build(entry)));

        mockMultipleSubversionRepositoryManager.reset();
        mockMultipleSubversionRepositoryManager.expects(atLeastOnce()).method("getRepositoryList").withNoArguments().will(
                returnValue(EasyList.build(svnMgr))
        );

        revisionIndexer = new RevisionIndexer(multipleSubversionRepositoryManager,
                versionManager, issueManager, permissionManager, changeHistoryManager, serviceManager, indexPathManager)
        {
            protected boolean isKeyInString(SVNLogEntry logEntry)
            {
                return true;
            }

            protected String getProjectKeyFromIssueKey(String issueKey)
            {
                return "TST";
            }

            protected List<String> getIssueKeysFromString(SVNLogEntry logEntry)
            {
                return EasyList.build("TST-1");
            }
        };
        revisionIndexer.updateIndex();

        indexReader = LuceneUtils.getIndexReader(getIndexPath());
        assertEquals(1, indexReader.numDocs()); /* Contains one entry only. This is what we are going to change */
        indexReader.close();

        revisionIndexer.removeEntries(svnMgr);
        indexReader = LuceneUtils.getIndexReader(getIndexPath());
        assertEquals(0, indexReader.numDocs()); /* There should be no matches */
        indexReader.close();
    }
}


text:
using System;
using System.Collections.Generic;

namespace Azure.Search.Documents.Indexes.Models
{
    /// <summary> Tokenizes the input into n-grams of the given size(s). This tokenizer is implemented using Apache Lucene. </summary>
    public partial class NGramTokenizer : LexicalTokenizer
    {
        /// <summary> Initializes a new instance of NGramTokenizer. </summary>
        /// <param name="name"> The name of the tokenizer. It must only contain letters, digits, spaces, dashes or underscores, can only start and end with alphanumeric characters, and is limited to 128 characters. </param>
        public NGramTokenizer(string name) : base(name)
        {
            if (name == null)
            {
                throw new ArgumentNullException(nameof(name));
            }

            ODataType = "#Microsoft.Azure.Search.NGramTokenizer";
        }

        /// <summary> Initializes a new instance of NGramTokenizer. </summary>
        /// <param name="oDataType"> Identifies the concrete type of the tokenizer. </param>
        /// <param name="name"> The name of the tokenizer. It must only contain letters, digits, spaces, dashes or underscores, can only start and end with alphanumeric characters, and is limited to 128 characters. </param>
        /// <param name="minGram"> The minimum n-gram length. Default is 1. Maximum is 300. Must be less than the value of maxGram. </param>
        /// <param name="maxGram"> The maximum n-gram length. Default is 2. Maximum is 300. </param>
        /// <param name="tokenChars"> Character classes to keep in the tokens. </param>
        internal NGramTokenizer(string oDataType, string name, int? minGram, int? maxGram, IList<TokenCharacterKind> tokenChars) : base(oDataType, name)
        {
            MinGram = minGram;
            MaxGram = maxGram;
            TokenChars = tokenChars;
            ODataType = oDataType ?? "#Microsoft.Azure.Search.NGramTokenizer";
        }

        /// <summary> The minimum n-gram length. Default is 1. Maximum is 300. Must be less than the value of maxGram. </summary>
        public int? MinGram { get; set; }
        /// <summary> The maximum n-gram length. Default is 2. Maximum is 300. </summary>
        public int? MaxGram { get; set; }
        /// <summary> Character classes to keep in the tokens. </summary>
        public IList<TokenCharacterKind> TokenChars { get; set; }
    }
}


text:
RSpec.shared_context "shared stuff", :shared_context => :metadata do
  let(:options) { { namespace: "app_v1", compress: true } }
  let(:dalli_client) { Dalli::Client.new("localhost:11211", options) }
  let(:filename) { File.expand_path("test.pdf", File.dirname(__FILE__)) }
  let(:basename) { File.basename(filename) }
  let(:fake_file) { "fake.qw" }

  after(:each) { dalli_client.delete(basename) }
end

RSpec.configure do |rspec|
  rspec.include_context "shared stuff", :include_shared => true
end


text:
class Sprite;
class Drawable {
public:
  Drawable(const std::string& n, const Vector2f& pos, const Vector2f& vel):
    name(n), position(pos), velocity(vel) {}

  Drawable(const Drawable& s) :
    name(s.name), position(s.position), velocity(s.velocity)
    { }

  virtual ~Drawable() {}

  const std::string& getName() const { return name; }
  void setName(const std::string& n) { name = n; }
  virtual const Frame* getFrame() const = 0;
  virtual unsigned getPixel(Uint32, Uint32) const = 0;

  virtual void draw() const = 0;
  virtual void update(Uint32 ticks) = 0;

  float X() const { return position[0]; }
  void X(float x) { position[0] = x; }

  float Y() const { return position[1]; }
  void Y(float y) { position[1] = y; }

  float velocityX() const { return velocity[0]; }
  void velocityX(float vx) { velocity[0] = vx; }
  float velocityY() const { return velocity[1]; }
  void velocityY(float vy) { velocity[1] = vy; }
  const Vector2f& getVelocity() const { return velocity; }
  void setVelocity(const Vector2f& vel) { velocity = vel; }

  const Vector2f& getPosition() const { return position; }
  void setPosition(const Vector2f& pos) { position = pos; }

private:
  std::string name;
  Vector2f position;
  Vector2f velocity;
};
#endif


text:
#!/usr/bin/env node

/**
 * takeoff-up command
 * To install this command run `npm link`
 * Triggers docker-compose up to run with the specified file name
 * Usage:
 *  takeoff-up --env [env] -d [name] -h
 *
 * Parameters
 *  --env   [env]   The name of the docker-compose environment file to use
 *  -d      [name]  Names of service to start, for example db
 *  -h              Hide the verbose information from docker
 */

const argv = require('minimist')(process.argv.slice(2));
const { spawn } = require('child_process');

let env = argv.env || 'dev';

const command = 'docker-compose';

const args = ['-f', `docker/docker-compose.${env}.yml`, 'up'];

if (argv.d && typeof argv.d === 'string') {
    args.push('-d');
    args.push(argv.d);
}

console.log('Running Docker Up Script');
console.log('---------------------------');

let result = spawn(command, args);

if (!argv.h) {
    result.stdout.on('data', message => {
        console.log(`${message}`.trim());
    });
}

result.stderr.on('data', message => {
    console.error(`${message}`.trim());
});

result.on('exit', () => {
    console.log('Docker Up Done');
});


text:
layout: page-fullwidth
title:  "Via Markelbach"
teaser: ""
categories:
    - works
tags:
    - post format
    - projects
header: no
image:
   thumb: "MARK_00002-thumb.jpg"
gallery:
    - image_url: MARK_00001.jpg
    #caption: generated caption for MARK_00001.jpg
    - image_url: MARK_00002.jpg
    #caption: generated caption for MARK_00002.jpg
    - image_url: MARK_00003.jpg
    #caption: generated caption for MARK_00003.jpg
    - image_url: MARK_00004.jpg
    #caption: generated caption for MARK_00004.jpg
    - image_url: MARK_00005.jpg
    #caption: generated caption for MARK_00005.jpg
    - image_url: MARK_00006.jpg
    #caption: generated caption for MARK_00006.jpg
    - image_url: MARK_00007.jpg
    #caption: generated caption for MARK_00007.jpg
    - image_url: MARK_00008.jpg
    #caption: generated caption for MARK_00008.jpg
    - image_url: MARK_00009.jpg
    #caption: generated caption for MARK_00009.jpg
    - image_url: MARK_00010.jpg
    #caption: generated caption for MARK_00010.jpg
    - image_url: MARK_00011.jpg
    #caption: generated caption for MARK_00011.jpg
    - image_url: MARK_00012.jpg
    #caption: generated caption for MARK_00012.jpg
---

{% include gallery %}

## Other Projects
{: .t60 }
{% include list-posts tag='projects' %}


text:
package scans

import (
	"encoding/json"
	"testing"
	"time"

	"github.com/franela/goblin"
	. "github.com/onsi/gomega"
)

func TestSummary(t *testing.T) {
	g := goblin.Goblin(t)
	RegisterFailHandler(func(m string, _ ...int) { g.Fail(m) })

	g.Describe("Scan Summary", func() {
		g.Describe("Translating", func() {
			g.It("should translate an untranslated summary", func() {
				ss := &Summary{
					UntranslatedResults: &UntranslatedResults{
						License: &LicenseResults{},
					},
				}
				Expect(ss.UntranslatedResults).NotTo(BeNil())
				Expect(ss.TranslatedResults).To(BeNil())

				err := ss.Translate()
				Expect(err).To(BeNil())
				Expect(ss.UntranslatedResults).To(BeNil())
				Expect(ss.TranslatedResults).NotTo(BeNil())
				Expect(ss.TranslatedResults.Type).To(Equal("license"))
				Expect(ss.Results).NotTo(BeNil())
				Expect(len(ss.Results)).NotTo(Equal(0))
			})

			g.It("should not translate an already translated summary", func() {
				ss := &Summary{
					UntranslatedResults: &UntranslatedResults{
						License: &LicenseResults{},
					},
				}
				Expect(ss.UntranslatedResults).NotTo(BeNil())
				Expect(ss.TranslatedResults).To(BeNil())

				err := ss.Translate()
				Expect(err).To(BeNil())
				Expect(ss.UntranslatedResults).To(BeNil())
				Expect(ss.TranslatedResults).NotTo(BeNil())
				Expect(ss.TranslatedResults.Type).To(Equal("license"))
				Expect(ss.Results).NotTo(BeNil())
				Expect(len(ss.Results)).NotTo(Equal(0))

				err = ss.Translate()
				Expect(err).To(BeNil())
				Expect(ss.UntranslatedResults).To(BeNil())
				Expect(ss.TranslatedResults).NotTo(BeNil())
				Expect(ss.TranslatedResults.Type).To(Equal("license"))
				Expect(ss.Results).NotTo(BeNil())
				Expect(len(ss.Results)).NotTo(Equal(0))
			})
		})

		g.Describe("Unmarshalling", func() {
			g.It("should populate results with untranslated result", func() {
				var ss Summary
				err := json.Unmarshal([]byte(sampleUntranslatedResults), &ss)

				Expect(err).To(BeNil())
				Expect(ss.TeamID).To(Equal("cuketest"))
				Expect(ss.TranslatedResults).To(BeNil())
				Expect(ss.UntranslatedResults).NotTo(BeNil())
				Expect(ss.UntranslatedResults.License).NotTo(BeNil())
				Expect(ss.UntranslatedResults.License.Name).To(Equal("some license"))
			})

			g.It("should populate results with translated result", func() {
				var ss Summary
				err := json.Unmarshal([]byte(sampleTranslatedResults), &ss)

				Expect(err).To(BeNil())
				Expect(ss.TeamID).To(Equal("cuketest"))
				Expect(ss.UntranslatedResults).To(BeNil())
				Expect(ss.TranslatedResults).NotTo(BeNil())
				Expect(ss.TranslatedResults.Type).To(Equal("community"))
			})
			g.It("should unmarshal a scan summary with a bad, list-ified community results member", func() {
				var ss Summary
				err := json.Unmarshal([]byte(badCommunityResults), &ss)
				Expect(err).NotTo(HaveOccurred())
			})
		})

		g.Describe("Marshalling", func() {
			g.It("should output results with untranslated result", func() {
				s := &Summary{
					summary: &summary{
						ID:          "41e6905a-a16d-45a7-9d2c-2794840ca03e",
						TeamID:      "cuketest",
						AnalysisID:  "c2a79402-e3bf-4069-89c8-7a4ecb10d33f",
						CreatedAt:   time.Now(),
						Description: "This scan data has not been evaluated against a rule.",
						Duration:    1000.1,
						Name:        "license",
						ProjectID:   "35b06118-da91-4ac8-a3d0-db25a3e554c5",
						Summary:     "oh hi",
						UpdatedAt:   time.Now(),
					},
					UntranslatedResults: &UntranslatedResults{
						License: &LicenseResults{
							&License{
								Name: "some license",
								Type: []LicenseType{
									LicenseType{Name: "a license"},
								},
							},
						},
					},
				}

				b, err := json.MarshalIndent(s, "", "  ")
				Expect(err).To(BeNil())

				body := string(b)
				Expect(body).To(ContainSubstring("team_id\": \"cuketest\""))
				Expect(body).NotTo(ContainSubstring("about_yml"))
				Expect(body).NotTo(ContainSubstring("community"))
				Expect(body).NotTo(ContainSubstring("coverage"))
				Expect(body).NotTo(ContainSubstring("dependency"))
				Expect(body).NotTo(ContainSubstring("difference"))
				Expect(body).NotTo(ContainSubstring("ecosystem"))
				Expect(body).NotTo(ContainSubstring("external_vulnerability"))
				Expect(body).NotTo(ContainSubstring("virus"))
				Expect(body).NotTo(ContainSubstring("vulnerability"))
			})

			g.It("should output results with translated result", func() {
				s := &Summary{
					summary: &summary{
						ID:          "41e6905a-a16d-45a7-9d2c-2794840ca03e",
						TeamID:      "cuketest",
						AnalysisID:  "c2a79402-e3bf-4069-89c8-7a4ecb10d33f",
						CreatedAt:   time.Now(),
						Description: "This scan data has not been evaluated against a rule.",
						Duration:    1000.1,
						Name:        "community",
						ProjectID:   "35b06118-da91-4ac8-a3d0-db25a3e554c5",
						Summary:     "oh hi",
						UpdatedAt:   time.Now(),
					},
					TranslatedResults: &TranslatedResults{
						Type: "community",
						Data: &CommunityResults{
							CommittersTotalCount: 5,
							Name:                 "reponame",
							URL:                  "http://github.com/reponame",
						},
					},
				}

				b, err := json.MarshalIndent(s, "", "  ")
				Expect(err).To(BeNil())

				body := string(b)
				Expect(body).To(ContainSubstring("team_id\": \"cuketest\""))
				Expect(body).To(ContainSubstring("committers_total_count\": 5"))
				Expect(body).NotTo(ContainSubstring("about_yml"))
				Expect(body).NotTo(ContainSubstring("coverage"))
				Expect(body).NotTo(ContainSubstring("dependency"))
				Expect(body).NotTo(ContainSubstring("difference"))
				Expect(body).NotTo(ContainSubstring("ecosystem"))
				Expect(body).NotTo(ContainSubstring("external_vulnerability"))
				Expect(body).NotTo(ContainSubstring("license"))
				Expect(body).NotTo(ContainSubstring("virus"))
				Expect(body).NotTo(ContainSubstring("vulnerability"))
			})
		})
	})
}

const (
	badCommunityResults = `{
                "description": "This scan data has not been evaluated against a rule.",
                "created_at": "2018-01-11T05:38:49.478Z",
                "results": {
                    "data": [
                        {
                            "url": "https://github.com/simon/putty",
                            "committers_total_count": 0,
                            "name": "simon/putty"
                        }
                    ],
                    "type": "community"
                },
                "updated_at": "2018-01-11T05:38:49.478Z",
                "summary": "Finished community scan for Putty-Source, community data was detected.",
                "team_id": "78536455-a13c-4661-890a-785197f6d9d4",
                "analysis_id": "7f19b79d-5c5f-4c4a-99b3-86c2b0483785",
                "duration": 493.197211995721,
                "project_id": "474b67d8-4817-4209-b614-09c74f3d6c12",
                "id": "6ff786fc-8374-cf33-3a7b-eb5168dc9105",
                "name": "community"
            }`
	sampleUntranslatedResults = `{
  "id": "41e6905a-a16d-45a7-9d2c-2794840ca03e",
  "team_id": "cuketest",
  "project_id": "35b06118-da91-4ac8-a3d0-db25a3e554c5",
  "analysis_id": "c2a79402-e3bf-4069-89c8-7a4ecb10d33f",
  "summary": "oh hi",
  "results": {
    "license": {
      "license": {
        "name": "some license",
        "type": [
          {
            "name": "a license",
						"confidence": 1.0
          }
        ]
      }
    }
  },
  "created_at": "2018-03-29T13:33:45.924135248-07:00",
  "updated_at": "2018-03-29T13:33:45.924135258-07:00",
  "duration": 1000.1,
  "passed": false,
  "risk": "",
  "name": "license",
  "description": "This scan data has not been evaluated against a rule.",
  "type": ""
}`
	sampleTranslatedResults = `{
  "id": "41e6905a-a16d-45a7-9d2c-2794840ca03e",
  "team_id": "cuketest",
  "project_id": "35b06118-da91-4ac8-a3d0-db25a3e554c5",
  "analysis_id": "c2a79402-e3bf-4069-89c8-7a4ecb10d33f",
  "summary": "oh hi",
  "results": {
    "type": "community",
    "data": {
      "_total_count": 5,
      "name": "reponame",
      "url": "http://github.com/reponame"
    }
  },
  "created_at": "2018-03-29T13:50:18.273379563-07:00",
  "updated_at": "2018-03-29T13:50:18.273379579-07:00",
  "duration": 1000.1,
  "passed": false,
  "risk": "",
  "name": "license",
  "description": "This scan data has not been evaluated against a rule.",
  "type": ""
}`
)