ItemUtils NPE bug fix
Some checks failed
studiorailgun/Renderer/pipeline/head There was a failure building this commit

This commit is contained in:
austin 2024-09-03 23:04:46 -04:00
parent fc3b48deac
commit 0f6e46159f
3 changed files with 24 additions and 0 deletions

View File

@ -678,6 +678,7 @@ Include jenkins dockerfile in repo
Better model for gameobjects Better model for gameobjects
Server synchronization of sprint tree Server synchronization of sprint tree
Fix potential bad path for item state lookup Fix potential bad path for item state lookup
Fix ItemUtils NPE bug + unit test
# TODO # TODO

View File

@ -290,6 +290,9 @@ public class ItemUtils {
* @return true if it is an item, false otherwise * @return true if it is an item, false otherwise
*/ */
public static boolean isItem(Entity e){ public static boolean isItem(Entity e){
if(e == null){
return false;
}
if(!e.containsKey(EntityDataStrings.ENTITY_TYPE)){ if(!e.containsKey(EntityDataStrings.ENTITY_TYPE)){
return false; return false;
} }

View File

@ -0,0 +1,20 @@
package electrosphere.entity.types.item;
import org.junit.jupiter.api.Assertions;
import annotations.FastTest;
import annotations.UnitTest;
/**
* Unit tests for item utils
*/
public class ItemUtilsUnitTests {
@UnitTest
@FastTest
public void isItem_NullEntity_False(){
boolean result = ItemUtils.isItem(null);
Assertions.assertEquals(false, result);
}
}