Skip to content

Commit

Permalink
Merge pull request #77 from BigBadE/v1.15
Browse files Browse the repository at this point in the history
Fixed #76, deprecated build.gradle, and incomplete javadocs
  • Loading branch information
seeseemelk committed Jun 17, 2020
2 parents d952559 + dbef2f6 commit 2129b74
Show file tree
Hide file tree
Showing 6 changed files with 68 additions and 61 deletions.
89 changes: 51 additions & 38 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ apply plugin: 'java-library'
apply plugin: 'eclipse'
apply plugin: 'idea'
apply plugin: 'jacoco'
apply plugin: 'maven'
apply plugin: 'maven-publish'
apply plugin: 'signing'

sourceCompatibility = 1.8
Expand All @@ -16,7 +16,7 @@ repositories {
}

maven {
url 'http://repo.md-5.net/content/groups/public/'
url 'https://repo.md-5.net/content/groups/public/'
}
}

Expand All @@ -43,55 +43,68 @@ artifacts {
}

signing {
sign configurations.archives
sign publishing.publications
}

jacocoTestReport {
reports {
xml.enabled true
}
reports {
xml.enabled true
}
}

group = 'com.github.seeseemelk'
version = '0.3.1-SNAPSHOT'

uploadArchives {
repositories {
mavenDeployer {
beforeDeployment {
MavenDeployment deployment -> signing.signPom(deployment)
}
repository(url: 'https://oss.sonatype.org/service/local/staging/deploy/maven2/') {
authentication(userName: findProperty('ossrhUsername'), password: findProperty('ossrhPassword'))
}
snapshotRepository(url: 'https://oss.sonatype.org/content/repositories/snapshots/') {
authentication(userName: findProperty('ossrhUsername'), password: findProperty('ossrhPassword'))
}
pom.project {
name 'MockBukkit-v1.15'
packaging 'jar'
description 'MockBukkit is a mocking framework for bukkit to allow the easy unit testing of Bukkit plugins.'
url 'https://github.com/seeseemelk/MockBukkit'
scm {
connection 'scm:git:git://github.com/seeseemelk/MockBukkit.git'
developerConnection 'scm:git:ssh://github.com:seeseemelk/MockBukkit.git'
url 'https://github.com/seeseemelk/MockBukkit/tree/v1.15-spigot'
}
licenses {
license {
name 'MIT License'
url 'https://github.com/seeseemelk/MockBukkit/blob/v1.15/LICENSE'
configurations {
publishing {
publications {
mockBukkit(MavenPublication) {
from components.java
pom {
name = 'MockBukkit-v1.15'
packaging = 'jar'
description = 'MockBukkit is a mocking framework for bukkit to allow the easy unit testing of Bukkit plugins.'
url = 'https://github.com/seeseemelk/MockBukkit'
scm {
connection = 'scm:git:git://github.com/seeseemelk/MockBukkit.git'
developerConnection = 'scm:git:ssh://github.com:seeseemelk/MockBukkit.git'
url = 'https://github.com/seeseemelk/MockBukkit/tree/v1.15-spigot'
}
}
developers {
developer {
id 'seeseemelk'
name 'Sebastiaan de Schaetzen'
email 'sebastiaan.de.schaetzen@gmail.com'
licenses {
license {
name = 'MIT License'
url = 'https://github.com/seeseemelk/MockBukkit/blob/v1.15/LICENSE'
}
}
developers {
developer {
id = 'seeseemelk'
name = 'Sebastiaan de Schaetzen'
email = 'sebastiaan.de.schaetzen@gmail.com'
}
}
}
}
}

repositories {
maven {
name = 'repository'
url = 'https://oss.sonatype.org/service/local/staging/deploy/maven2/'
credentials {
username = findProperty('ossrhUsername')
password = findProperty('ossrhPassword')
}
}
maven {
name = 'snapshotRepository'
url = 'https://oss.sonatype.org/content/repositories/snapshots/'
credentials {
username = findProperty('ossrhUsername')
password = findProperty('ossrhPassword')
}
}
}
}
}

Expand Down
6 changes: 3 additions & 3 deletions src/main/java/be/seeseemelk/mockbukkit/entity/ZombieMock.java
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import org.bukkit.entity.EntityType;
import org.bukkit.entity.Villager;
import org.bukkit.entity.Zombie;
import org.jetbrains.annotations.Contract;

import java.util.UUID;

Expand Down Expand Up @@ -52,7 +53,7 @@ public boolean isVillager()
/**
* This are unimplemented because they Bukkit specifies they should always fail? (@Contract Tag)
*
* @param villager
* @param villager If the zombie is a village
*/
@Override
public void setVillager(boolean villager)
Expand All @@ -64,12 +65,11 @@ public void setVillager(boolean villager)
/**
* This are unimplemented because they Bukkit specifies they should always fail? (@Contract Tag)
*
* @param profession
* @param profession Villager profession to use
*/
@Override
public void setVillagerProfession(Villager.Profession profession)
{
this.profession = profession;
throw new UnimplementedOperationException();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -126,8 +126,6 @@ public int getSize()
@Override
public ItemStack getItem(int index)
{
if (items[index] == null)
items[index] = new ItemStack(Material.AIR);
return items[index];
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -257,7 +257,7 @@ public Map<String, Object> serialize() {

/**
* Required method for Bukkit deserialization.
* @param args A serialized ItemMetaMock object in a Map<String, Object> format.
* @param args A serialized ItemMetaMock object in a Map&lt;String, Object&gt; format.
* @return A new instance of the ItemMetaMock class.
*/
@SuppressWarnings("unchecked")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -820,7 +820,7 @@ public void testKeepInventoryFalse()

// The Player should have lost their inventory
assertTrue(player.isDead());
assertEquals(Material.AIR, player.getInventory().getItem(0).getType());
assertNull(player.getInventory().getItem(0));
}

@Test
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,14 @@

import java.util.HashMap;
import java.util.ListIterator;
import java.util.Objects;
import java.util.concurrent.atomic.AtomicInteger;

import org.bukkit.Material;
import org.bukkit.event.inventory.InventoryType;
import org.bukkit.inventory.ItemStack;
import org.junit.After;
import org.junit.Assert;
import org.junit.Before;
import org.junit.Test;

Expand Down Expand Up @@ -52,13 +54,12 @@ public void constructor_SetsType()
}

@Test
public void getItem_Default_AllAir()
public void getItem_Default_AllNull()
{
for (int i = 0; i < inventory.getSize(); i++)
{
ItemStack item = inventory.getItem(i);
assertNotNull(item);
assertEquals(Material.AIR, item.getType());
assertNull(item);
}
}

Expand All @@ -75,8 +76,7 @@ public void testClearInventory()
for (int i = 0; i < inventory.getSize(); i++)
{
ItemStack item = inventory.getItem(i);
assertNotNull(item);
assertEquals(Material.AIR, item.getType());
assertNull(item);
}
}

Expand All @@ -87,7 +87,7 @@ public void testClearSlot()
assertEquals(Material.DIAMOND, inventory.getItem(0).getType());

inventory.clear(0);
assertEquals(Material.AIR, inventory.getItem(0).getType());
assertNull(inventory.getItem(0));
}

@Test
Expand All @@ -112,8 +112,7 @@ public void addItem_EmptyInventoryAddsOneStack_OneStackUsed()
ItemStack stored = inventory.getItem(0);
assertEquals(stored.getAmount(), 64);
ItemStack next = inventory.getItem(1);
assertNotNull(next);
assertEquals(Material.AIR, next.getType());
assertNull(next);
}

@Test
Expand Down Expand Up @@ -187,23 +186,20 @@ public void setContents_OneItemAndOneNull_SetAndRestCleared()

ItemStack item = new ItemStack(Material.DIRT, 32);

inventory.setContents(new ItemStack[]
{ item });
inventory.setContents(new ItemStack[] { item });

assertTrue(item.isSimilar(inventory.getItem(0)));
for (int i = 1; i < inventory.getSize(); i++)
{
ItemStack emptyItem = inventory.getItem(i);
assertNotNull(emptyItem);
assertEquals(Material.AIR, emptyItem.getType());
assertNull(emptyItem);
}
}

@Test
public void setContents_ArrayWithNulls_NullsIgnores()
{
inventory.setContents(new ItemStack[]
{ null });
inventory.setContents(new ItemStack[] { null });
}

@Test
Expand All @@ -222,14 +218,14 @@ public void iterator_SeveralItems_IteratorsOverItems()
@Test
public void assertTrueForAll_ChecksIfNullOnEmptyInventory_DoesNotAssert()
{
inventory.assertTrueForAll(itemstack -> itemstack == null);
inventory.assertTrueForAll(Objects::isNull);
}

@Test(expected = AssertionError.class)
public void assertTrueForAll_ChecksIfNullOnNonEmptyInventory_Asserts()
{
inventory.addItem(new ItemStack(Material.DIRT, 1));
inventory.assertTrueForAll(itemstack -> itemstack == null);
inventory.assertTrueForAll(Objects::isNull);
}

@Test
Expand Down

0 comments on commit 2129b74

Please sign in to comment.