1 17 18 package org.apache.geronimo.transaction.mockjpa; 19 20 import java.util.Map ; 21 22 import javax.persistence.EntityManager; 23 import javax.persistence.FlushModeType; 24 import javax.persistence.LockModeType; 25 import javax.persistence.Query; 26 import javax.persistence.EntityTransaction; 27 28 31 public class MockEntityManager implements EntityManager { 32 33 private final Map properties; 34 private boolean closed = false; 35 private boolean cleared = false; 36 private boolean joined = false; 37 38 public MockEntityManager() { 39 properties = null; 40 } 41 42 public MockEntityManager(Map properties) { 43 this.properties = properties; 44 } 45 46 public void persist(Object object) { 47 } 48 49 public <T> T merge(T t) { 50 return null; 51 } 52 53 public void remove(Object object) { 54 } 55 56 public <T> T find(Class <T> aClass, Object object) { 57 if (aClass == Map .class && "properties".equals(object)) { 58 return (T)properties; 59 } 60 if (aClass == EntityManager.class && "this".equals(object)) { 61 return (T)this; 62 } 63 return null; 64 } 65 66 public <T> T getReference(Class <T> aClass, Object object) { 67 return null; 68 } 69 70 public void flush() { 71 } 72 73 public void setFlushMode(FlushModeType flushModeType) { 74 } 75 76 public FlushModeType getFlushMode() { 77 return null; 78 } 79 80 public void lock(Object object, LockModeType lockModeType) { 81 } 82 83 public void refresh(Object object) { 84 } 85 86 public void clear() { 87 cleared = true; 88 } 89 90 public boolean contains(Object object) { 91 return false; 92 } 93 94 public Query createQuery(String string) { 95 return null; 96 } 97 98 public Query createNamedQuery(String string) { 99 return null; 100 } 101 102 public Query createNativeQuery(String string) { 103 return null; 104 } 105 106 public Query createNativeQuery(String string, Class aClass) { 107 return null; 108 } 109 110 public Query createNativeQuery(String string, String string1) { 111 return null; 112 } 113 114 public void close() { 115 closed = true; 116 } 117 118 public boolean isOpen() { 119 return !closed; 120 } 121 122 public EntityTransaction getTransaction() { 123 return null; 124 } 125 126 public void joinTransaction() { 127 joined = true; 128 } 129 130 public Object getDelegate() { 131 return null; 132 } 133 134 public Map getProperties() { 135 return properties; 136 } 137 138 public boolean isClosed() { 139 return closed; 140 } 141 142 public boolean isCleared() { 143 return cleared; 144 } 145 146 public boolean isJoined() { 147 return joined; 148 } 149 } 150 | Popular Tags |