forked from projectlombok/lombok
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request projectlombok#3 from mplushnikov/simple_version_check
Simple version check
- Loading branch information
Showing
6 changed files
with
164 additions
and
35 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,10 @@ | ||
package de.plushnikov.intellij.plugin; | ||
|
||
public interface Version { | ||
String PLUGIN_NAME = "Lombok plugin"; | ||
/** | ||
* Current plugin version. | ||
*/ | ||
String PLUGIN_VERSION = "0.12"; | ||
String LAST_LOMBOK_VERSION = "1.16.8"; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
75 changes: 75 additions & 0 deletions
75
src/test/java/de/plushnikov/intellij/plugin/LombokPluginProjectValidatorComponentTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,75 @@ | ||
package de.plushnikov.intellij.plugin; | ||
|
||
import com.intellij.openapi.roots.OrderEntry; | ||
import org.junit.Before; | ||
import org.junit.Test; | ||
|
||
import static org.junit.Assert.assertEquals; | ||
import static org.junit.Assert.assertNull; | ||
import static org.mockito.Mockito.mock; | ||
import static org.mockito.Mockito.when; | ||
|
||
public class LombokPluginProjectValidatorComponentTest { | ||
|
||
private LombokPluginProjectValidatorComponent component; | ||
private OrderEntry orderEntry; | ||
|
||
@Before | ||
public void setUp() throws Exception { | ||
component = new LombokPluginProjectValidatorComponent(null); | ||
orderEntry = mock(OrderEntry.class); | ||
} | ||
|
||
@Test | ||
public void parseLombokVersionFromGradle() throws Exception { | ||
when(orderEntry.getPresentableName()).thenReturn("Gradle: org.projectlombok:lombok:1.16.8"); | ||
assertEquals("1.16.8", component.parseLombokVersion(orderEntry)); | ||
} | ||
|
||
@Test | ||
public void parseLombokVersionFromMaven() throws Exception { | ||
when(orderEntry.getPresentableName()).thenReturn("Maven: org.projectlombok:lombok:1.16.6"); | ||
assertEquals("1.16.6", component.parseLombokVersion(orderEntry)); | ||
} | ||
|
||
@Test | ||
public void parseLombokVersionFromUnknown() throws Exception { | ||
when(orderEntry.getPresentableName()).thenReturn("lombok"); | ||
assertNull(component.parseLombokVersion(orderEntry)); | ||
} | ||
|
||
@Test | ||
public void compareVersionString1_2() throws Exception { | ||
assertEquals(-1, component.compareVersionString("1", "2")); | ||
} | ||
|
||
@Test | ||
public void compareVersionString__2() throws Exception { | ||
assertEquals(-1, component.compareVersionString("", "2")); | ||
} | ||
|
||
@Test | ||
public void compareVersionString123_121() throws Exception { | ||
assertEquals(1, component.compareVersionString("1.2.3", "1.2.1")); | ||
} | ||
|
||
@Test | ||
public void compareVersionString1166_1168() throws Exception { | ||
assertEquals(-1, component.compareVersionString("1.16.6", "1.16.8")); | ||
} | ||
|
||
@Test | ||
public void compareVersionString1168_1168() throws Exception { | ||
assertEquals(0, component.compareVersionString("1.16.8", "1.16.8")); | ||
} | ||
|
||
@Test | ||
public void compareVersionString0102_1168() throws Exception { | ||
assertEquals(-1, component.compareVersionString("0.10.2", "1.16.8")); | ||
} | ||
|
||
@Test | ||
public void compareVersionString1169_1168() throws Exception { | ||
assertEquals(1, component.compareVersionString("1.16.9", "1.16.8")); | ||
} | ||
} |