Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

lambdaj joins select

  • Loading branch information...
commit 83f11de694783e7fa7d522f544b51a53ffd0b960 1 parent b790ab5
@mileschet mileschet authored
View
119 .idea/workspace.xml
@@ -11,6 +11,11 @@
<option name="LAST_RESOLUTION" value="IGNORE" />
</component>
<component name="ChangesViewManager" flattened_view="true" show_ignored="false" />
+ <component name="Commander">
+ <leftPanel url="file://$PROJECT_DIR$" />
+ <rightPanel />
+ <splitter proportion="0.5" />
+ </component>
<component name="CreatePatchCommitExecutor">
<option name="PATCH_PATH" value="" />
</component>
@@ -58,31 +63,42 @@
</component>
<component name="FileEditorManager">
<leaf>
- <file leaf-file-name="SyncCoreTest.java" pinned="false" current="true" current-in-tab="true">
- <entry file="file://$PROJECT_DIR$/src-test/bravado/sync/test/SyncCoreTest.java">
+ <file leaf-file-name="SyncCore.java" pinned="false" current="false" current-in-tab="false">
+ <entry file="file://$PROJECT_DIR$/src/bravado/sync/core/SyncCore.java">
<provider selected="true" editor-type-id="text-editor">
- <state line="70" column="38" selection-start="2240" selection-end="2240" vertical-scroll-proportion="0.593949">
+ <state line="8" column="0" selection-start="178" selection-end="212" vertical-scroll-proportion="0.0">
<folding>
- <element signature="imports" expanded="true" />
- <element signature="e#1330#1345#0" expanded="true" />
- <element signature="e#2013#2028#0" expanded="true" />
+ <element signature="e#669#684#0" expanded="true" />
</folding>
</state>
</provider>
</entry>
</file>
- <file leaf-file-name="SyncCore.java" pinned="false" current="false" current-in-tab="false">
- <entry file="file://$PROJECT_DIR$/src/bravado/sync/core/SyncCore.java">
+ <file leaf-file-name="SyncCoreTest.java" pinned="false" current="true" current-in-tab="true">
+ <entry file="file://$PROJECT_DIR$/src-test/bravado/sync/test/SyncCoreTest.java">
<provider selected="true" editor-type-id="text-editor">
- <state line="30" column="0" selection-start="825" selection-end="825" vertical-scroll-proportion="0.0">
+ <state line="122" column="27" selection-start="3993" selection-end="3993" vertical-scroll-proportion="0.5048544">
<folding>
<element signature="imports" expanded="true" />
- <element signature="e#669#684#0" expanded="true" />
+ <element signature="e#1366#1381#0" expanded="true" />
+ <element signature="e#2049#2064#0" expanded="true" />
+ <element signature="e#2955#2970#0" expanded="true" />
+ <element signature="e#3882#3893#0" expanded="true" />
+ <element signature="e#3942#3953#0" expanded="true" />
</folding>
</state>
</provider>
</entry>
</file>
+ <file leaf-file-name="FileEntry.java" pinned="false" current="false" current-in-tab="false">
+ <entry file="file://$PROJECT_DIR$/src/bravado/sync/core/FileEntry.java">
+ <provider selected="true" editor-type-id="text-editor">
+ <state line="43" column="67" selection-start="919" selection-end="919" vertical-scroll-proportion="0.0">
+ <folding />
+ </state>
+ </provider>
+ </entry>
+ </file>
</leaf>
</component>
<component name="FindManager">
@@ -104,7 +120,6 @@
<option value="$PROJECT_DIR$/src-test/bravado/sync/test/SyncCoreMock.java" />
<option value="$PROJECT_DIR$/src-test/bravado/sync/test/FileEntry.java" />
<option value="$PROJECT_DIR$/src-test/bravado/sync/test/MockRepository.java" />
- <option value="$PROJECT_DIR$/src/bravado/sync/core/FileEntry.java" />
<option value="$PROJECT_DIR$/src/bravado/sync/core/SyncOperation.java" />
<option value="$PROJECT_DIR$/src/bravado/sync/core/SyncMock1.java" />
<option value="$PROJECT_DIR$/bsync.iml" />
@@ -114,6 +129,7 @@
<option value="$PROJECT_DIR$/src-test/bravado/sync/test/MockSyncToken.java" />
<option value="$PROJECT_DIR$/src/bravado/sync/core/SyncCore.java" />
<option value="$PROJECT_DIR$/src-test/bravado/sync/test/SyncCoreTest.java" />
+ <option value="$PROJECT_DIR$/src/bravado/sync/core/FileEntry.java" />
</list>
</option>
</component>
@@ -279,7 +295,7 @@
<recent name="bravado.sync.core" />
</key>
</component>
- <component name="RunManager" selected="JUnit.SyncCoreTest.testBobPutAllFiles">
+ <component name="RunManager" selected="JUnit.SyncCoreTest.testNotIn">
<configuration default="false" name="SyncCoreTest" type="JUnit" factoryName="JUnit" temporary="true">
<extension name="coverage" enabled="false" merge="false" runner="idea">
<pattern>
@@ -364,6 +380,34 @@
<ConfigurationWrapper RunnerId="Run" />
<method />
</configuration>
+ <configuration default="false" name="SyncCoreTest.testNotIn" type="JUnit" factoryName="JUnit" temporary="true">
+ <extension name="coverage" enabled="false" merge="false" runner="idea">
+ <pattern>
+ <option name="PATTERN" value="bravado.sync.test.*" />
+ <option name="ENABLED" value="true" />
+ </pattern>
+ </extension>
+ <module name="bsync" />
+ <option name="ALTERNATIVE_JRE_PATH_ENABLED" value="false" />
+ <option name="ALTERNATIVE_JRE_PATH" />
+ <option name="PACKAGE_NAME" value="bravado.sync.test" />
+ <option name="MAIN_CLASS_NAME" value="bravado.sync.test.SyncCoreTest" />
+ <option name="METHOD_NAME" value="testNotIn" />
+ <option name="TEST_OBJECT" value="method" />
+ <option name="VM_PARAMETERS" />
+ <option name="PARAMETERS" />
+ <option name="WORKING_DIRECTORY" value="$PROJECT_DIR$" />
+ <option name="ENV_VARIABLES" />
+ <option name="PASS_PARENT_ENVS" value="true" />
+ <option name="TEST_SEARCH_SCOPE">
+ <value defaultName="moduleWithDependencies" />
+ </option>
+ <envs />
+ <patterns />
+ <RunnerSettings RunnerId="Run" />
+ <ConfigurationWrapper RunnerId="Run" />
+ <method />
+ </configuration>
<configuration default="true" type="MavenRunConfiguration" factoryName="Maven">
<MavenSettings>
<option name="myGeneralSettings">
@@ -499,10 +543,11 @@
<option name="PhingTarget" enabled="false" />
</method>
</configuration>
- <list size="3">
+ <list size="4">
<item index="0" class="java.lang.String" itemvalue="JUnit.SyncCoreTest" />
<item index="1" class="java.lang.String" itemvalue="JUnit.SyncCoreTest.testReposirotyGetAllFiles" />
<item index="2" class="java.lang.String" itemvalue="JUnit.SyncCoreTest.testBobPutAllFiles" />
+ <item index="3" class="java.lang.String" itemvalue="JUnit.SyncCoreTest.testNotIn" />
</list>
<configuration name="&lt;template&gt;" type="WebApp" default="true" selected="false">
<Host>localhost</Host>
@@ -575,9 +620,9 @@
<window_info id="TODO" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" weight="0.32977098" sideWeight="0.5" order="7" 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.25" sideWeight="0.5" order="1" side_tool="true" content_ui="tabs" />
<window_info id="Maven Projects" active="false" anchor="right" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" weight="0.33522728" sideWeight="0.5" order="5" side_tool="false" content_ui="tabs" />
- <window_info id="Commander" active="false" anchor="right" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" weight="0.4" sideWeight="0.5" order="0" side_tool="false" content_ui="tabs" />
+ <window_info id="Commander" active="false" anchor="right" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" weight="0.39935064" sideWeight="0.5" order="0" side_tool="false" content_ui="tabs" />
<window_info id="Project" active="false" anchor="left" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="true" weight="0.23863636" sideWeight="0.670229" 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="false" weight="0.32977098" sideWeight="0.5" order="3" side_tool="false" content_ui="tabs" />
+ <window_info id="Run" active="true" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="true" weight="0.32977098" sideWeight="0.5" order="3" 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="5" 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="1" 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" />
@@ -660,13 +705,6 @@
</state>
</provider>
</entry>
- <entry file="file://$PROJECT_DIR$/pom.xml">
- <provider selected="true" editor-type-id="text-editor">
- <state line="21" column="21" selection-start="784" selection-end="784" vertical-scroll-proportion="0.50159234">
- <folding />
- </state>
- </provider>
- </entry>
<entry file="file://$PROJECT_DIR$/bsync.iml">
<provider selected="true" editor-type-id="text-editor">
<state line="17" column="0" selection-start="839" selection-end="839" vertical-scroll-proportion="0.61893207">
@@ -685,13 +723,6 @@
</state>
</provider>
</entry>
- <entry file="file://$PROJECT_DIR$/src/bravado/sync/core/FileEntry.java">
- <provider selected="true" editor-type-id="text-editor">
- <state line="9" column="26" selection-start="152" selection-end="152" vertical-scroll-proportion="0.21496816">
- <folding />
- </state>
- </provider>
- </entry>
<entry file="file://$PROJECT_DIR$/src/bravado/sync/core/SyncOperation.java">
<provider selected="true" editor-type-id="text-editor">
<state line="14" column="4" selection-start="274" selection-end="274" vertical-scroll-proportion="0.3343949">
@@ -716,30 +747,46 @@
</state>
</provider>
</entry>
+ <entry file="file://$PROJECT_DIR$/pom.xml">
+ <provider selected="true" editor-type-id="text-editor">
+ <state line="21" column="21" selection-start="784" selection-end="784" vertical-scroll-proportion="0.50159234">
+ <folding />
+ </state>
+ </provider>
+ </entry>
+ <entry file="file://$PROJECT_DIR$/src/bravado/sync/core/SyncMock1.java">
+ <provider selected="true" editor-type-id="text-editor">
+ <state line="189" column="82" selection-start="6315" selection-end="6315" vertical-scroll-proportion="0.46341464">
+ <folding />
+ </state>
+ </provider>
+ </entry>
<entry file="file://$PROJECT_DIR$/src/bravado/sync/core/SyncCore.java">
<provider selected="true" editor-type-id="text-editor">
- <state line="30" column="0" selection-start="825" selection-end="825" vertical-scroll-proportion="0.0">
+ <state line="8" column="0" selection-start="178" selection-end="212" vertical-scroll-proportion="0.0">
<folding>
- <element signature="imports" expanded="true" />
<element signature="e#669#684#0" expanded="true" />
</folding>
</state>
</provider>
</entry>
- <entry file="file://$PROJECT_DIR$/src/bravado/sync/core/SyncMock1.java">
+ <entry file="file://$PROJECT_DIR$/src/bravado/sync/core/FileEntry.java">
<provider selected="true" editor-type-id="text-editor">
- <state line="189" column="82" selection-start="6315" selection-end="6315" vertical-scroll-proportion="0.46341464">
+ <state line="43" column="67" selection-start="919" selection-end="919" vertical-scroll-proportion="0.0">
<folding />
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/src-test/bravado/sync/test/SyncCoreTest.java">
<provider selected="true" editor-type-id="text-editor">
- <state line="70" column="38" selection-start="2240" selection-end="2240" vertical-scroll-proportion="0.593949">
+ <state line="122" column="27" selection-start="3993" selection-end="3993" vertical-scroll-proportion="0.5048544">
<folding>
<element signature="imports" expanded="true" />
- <element signature="e#1330#1345#0" expanded="true" />
- <element signature="e#2013#2028#0" expanded="true" />
+ <element signature="e#1366#1381#0" expanded="true" />
+ <element signature="e#2049#2064#0" expanded="true" />
+ <element signature="e#2955#2970#0" expanded="true" />
+ <element signature="e#3882#3893#0" expanded="true" />
+ <element signature="e#3942#3953#0" expanded="true" />
</folding>
</state>
</provider>
View
57 src-test/bravado/sync/test/SyncCoreTest.java
@@ -9,6 +9,8 @@
import java.util.ArrayList;
import java.util.List;
+import static ch.lambdaj.Lambda.*;
+
import static bravado.sync.core.SyncOperation.*;
/**
@@ -77,5 +79,60 @@ public void testRepo1PutDeleteAndPut() {
}
+ public void testRepo1Delete() {
+
+ MockSyncToken repo1 = new MockSyncToken("repo1", "~/");
+ MockSyncToken repo2 = new MockSyncToken("repo2", "~/");
+
+ MockServer server = new MockServer();
+
+ // repo1 add file
+ repo1.addFile(new FileEntry("file2.txt", "2343"));
+
+ List<SyncOperation> operations = server.sync(repo1, repo1.repositoryFiles);
+
+ List<SyncOperation> operationsExpected = new ArrayList<SyncOperation>();
+ operationsExpected.add(new SyncOperation(new FileEntry("file2.txt", "2343"), PUT));
+
+ Assert.assertTrue(operations.containsAll(operationsExpected));
+
+ operations = server.sync(repo2, repo2.repositoryFiles);
+ operationsExpected.clear();
+ operationsExpected.add(new SyncOperation(new FileEntry("file2.txt", "2343"), GET));
+
+ Assert.assertTrue(operations.containsAll(operationsExpected));
+
+ repo1.repositoryFiles.clear();
+ operations = server.sync(repo1, repo1.repositoryFiles);
+
+ operations = server.sync(repo2, repo1.repositoryFiles);
+
+ operationsExpected.clear();
+ operationsExpected.add(new SyncOperation(new FileEntry("file2.txt", "2343"), DELETE));
+
+ Assert.assertTrue(operations.containsAll(operationsExpected));
+
+ }
+
+ @Test
+ public void testNotIn() {
+
+ List<FileEntry> list1 = new ArrayList<FileEntry>();
+ List<FileEntry> list2 = new ArrayList<FileEntry>();
+
+ list1.add(new FileEntry("lalala", "123"));
+ list1.add(new FileEntry("lalala2", "123"));
+
+ list2.add(new FileEntry("lalala", "123"));
+ list2.add(new FileEntry("lalala3", "123"));
+
+ System.out.println("inner join");
+ System.out.println(select(list1, org.hamcrest.Matchers.isIn(list2)));
+ System.out.println("left join");
+ System.out.println(select(list1, org.hamcrest.Matchers.not(org.hamcrest.Matchers.isIn(list2))));
+ System.out.println("right join");
+ System.out.println(select(list2, org.hamcrest.Matchers.not(org.hamcrest.Matchers.isIn(list1))));
+
+ }
}
View
5 src/bravado/sync/core/FileEntry.java
@@ -38,4 +38,9 @@ public boolean equals(Object o) {
}
return false;
}
+
+ @Override
+ public String toString() {
+ return "Filename: " + getFilename() + " Hash: " + getHash();
+ }
}
View
2  src/bravado/sync/core/SyncCore.java
@@ -28,8 +28,6 @@
List<SyncOperation> operations = new ArrayList<SyncOperation>();
List<FileEntry> repositoryFilesAndServerJoin = select(getServerRepositoryFiles(), org.hamcrest.Matchers.isIn(repositoryFiles));
-
-
// TODO filter only files found on server and syncToken (join ?)
for (FileEntry fileEntry : repositoryFilesAndServerJoin) {
operations.add(new SyncOperation(fileEntry, canRepositoryUpdateFile(syncToken, fileEntry) ? SyncOperation.PUT : SyncOperation.GET));
Please sign in to comment.
Something went wrong with that request. Please try again.