auphong2707/dl4se-code-review-dataset huggingface dataset:
Source:
<code>public void containsOnlyViolations(ViolationExpectation... expectedViolations) { isNotNull(); List<ViolationExpectation> actualViolations = new ArrayList<>(); ViolationExpectationPropertiesToTest referencePropertiesToTest; if ( expectedViolations.length == 0 ) { referencePropertiesToTest = ViolationExpectationPropertiesToTest.all(); } else { referencePropertiesToTest = expectedViolations[0].propertiesToTest; for ( ViolationExpectation expectedViolation : expectedViolations ) { if ( !referencePropertiesToTest.equals( expectedViolation.propertiesToTest ) ) { <START> throw new IllegalArgumentException( String.format( "Expected violations are not testing the properties consistently: %1$s - %2$s", <END> expectedViolations[0], expectedViolation ) ); } } } for ( ConstraintViolation<?> violation : actual ) { actualViolations.add( new ViolationExpectation( violation, referencePropertiesToTest ) ); } Assertions.assertThat( actualViolations ).containsExactlyInAnyOrder( expectedViolations ); }</code><technical_language>this mean, "testing consistently"</technical_language>

Target:
public void containsOnlyViolations(ViolationExpectation... expectedViolations) { isNotNull(); List<ViolationExpectation> actualViolations = new ArrayList<>(); ViolationExpectationPropertiesToTest referencePropertiesToTest; if ( expectedViolations.length == 0 ) { referencePropertiesToTest = ViolationExpectationPropertiesToTest.all(); } else { referencePropertiesToTest = expectedViolations[0].propertiesToTest; for ( ViolationExpectation expectedViolation : expectedViolations ) { if ( !referencePropertiesToTest.equals( expectedViolation.propertiesToTest ) ) { throw new IllegalArgumentException( String.format( "Expected violations passed in parameter must test the exact same properties but do not: %1$s != %2$s", expectedViolations[0], expectedViolation ) ); } } } for ( ConstraintViolation<?> violation : actual ) { actualViolations.add( new ViolationExpectation( violation, referencePropertiesToTest ) ); } Assertions.assertThat( actualViolations ).containsExactlyInAnyOrder( expectedViolations ); }
Source:
<code>public byte[] serialize(String topic, StreamlineEvent streamlineEvent) { SchemaMetadata schemaMetadata = Utils.getSchemaKey(topic, false); SchemaVersionInfo schemaVersionInfo; try { <START> schemaMetadata = this.schemaRegistryClient.getSchemaMetadataInfo(schemaMetadata.getName()).getSchemaMetadata(); <END> schemaVersionInfo = this.schemaRegistryClient.getLatestSchemaVersionInfo(schemaMetadata.getName()); } catch (SchemaNotFoundException e) { LOG.error("Exception occured while getting SchemaVersionInfo for " + schemaMetadata, e); throw new RuntimeException(e); } if (streamlineEvent == null || streamlineEvent.isEmpty()) { return null; } else { return avroSnapshotSerializer.serialize(getAvroRecord(streamlineEvent, new Schema.Parser().parse(schemaVersionInfo.getSchemaText())), schemaMetadata); } }</code><technical_language>remove this.schemaRegistryClient schemaRegistryClient</technical_language>

Target:
public byte[] serialize(String topic, StreamlineEvent streamlineEvent) { SchemaMetadata schemaMetadata = Utils.getSchemaKey(topic, false); SchemaVersionInfo schemaVersionInfo; try { schemaMetadata = schemaRegistryClient.getSchemaMetadataInfo(schemaMetadata.getName()).getSchemaMetadata(); schemaVersionInfo = schemaRegistryClient.getLatestSchemaVersionInfo(schemaMetadata.getName()); } catch (SchemaNotFoundException e) { LOG.error("Exception occured while getting SchemaVersionInfo for " + schemaMetadata, e); throw new RuntimeException(e); } if (streamlineEvent == null || streamlineEvent.isEmpty()) { return null; } else { return avroSnapshotSerializer.serialize(getAvroRecord(streamlineEvent, new Schema.Parser().parse(schemaVersionInfo.getSchemaText())), schemaMetadata); } }
Source:
<code>public void variantsShouldBeWrittenIntoMongoDb() throws UnknownHostException { String dbName = "VariantsShouldBeWrittenIntoMongoDb"; Variant variant = Mockito.mock(Variant.class); when(variant.getChromosome()).thenReturn("1").thenReturn("2").thenReturn("3"); when(variant.getStart()).thenReturn(1).thenReturn(2).thenReturn(3); when(variant.getReference()).thenReturn("A").thenReturn("B"); when(variant.getAlternate()).thenReturn("B").thenReturn("C"); <START> objectMap.put("db.name", dbName); <END> MongoOperations mongoOperations = MongoDBHelper.getMongoOperationsFromPipelineOptions(objectMap); DBCollection dbCollection = mongoOperations.getCollection(collectionName); BasicDBObject dbObject = new BasicDBObject(); when(variantToMongoDbObjectConverter.convert(any(Variant.class))).thenReturn(dbObject).thenReturn(dbObject); variantMongoWriter = new VariantMongoWriter(collectionName, mongoOperations, variantToMongoDbObjectConverter); variantMongoWriter.doWrite(Arrays.asList(variant, variant)); assertEquals(2, dbCollection.count()); JobTestUtils.cleanDBs(dbName); }</code><technical_language>This JobParametersNames</technical_language>

Target:
public void variantsShouldBeWrittenIntoMongoDb() throws UnknownHostException { String dbName = "VariantsShouldBeWrittenIntoMongoDb"; Variant variant = Mockito.mock(Variant.class); when(variant.getChromosome()).thenReturn("1").thenReturn("2").thenReturn("3"); when(variant.getStart()).thenReturn(1).thenReturn(2).thenReturn(3); when(variant.getReference()).thenReturn("A").thenReturn("B"); when(variant.getAlternate()).thenReturn("B").thenReturn("C"); objectMap.put(JobParametersNames.DB_NAME, dbName); MongoOperations mongoOperations = MongoDBHelper.getMongoOperationsFromPipelineOptions(objectMap); DBCollection dbCollection = mongoOperations.getCollection(collectionName); BasicDBObject dbObject = new BasicDBObject(); when(variantToMongoDbObjectConverter.convert(any(Variant.class))).thenReturn(dbObject).thenReturn(dbObject); variantMongoWriter = new VariantMongoWriter(collectionName, mongoOperations, variantToMongoDbObjectConverter); variantMongoWriter.doWrite(Arrays.asList(variant, variant)); assertEquals(2, dbCollection.count()); JobTestUtils.cleanDBs(dbName); }
Source:
<code>private boolean validateNetworkInterfaces() { Map<String, VmNetworkInterface> interfaceNetworkMap = Entities.interfacesByNetworkName(getVm().getInterfaces()); Set<String> interfaceNetworkNames = interfaceNetworkMap.keySet(); List<Network> clusterNetworks = getNetworkDAO().getAllForCluster(getVm().getvds_group_id()); Set<String> clusterNetworksNames = Entities.objectNames(clusterNetworks); boolean returnValue; <START> returnValue = isVmInterfacesConfigured(interfaceNetworkMap); <END> interfaceNetworkMap.remove(null); return returnValue && isVmInterfacesAttachedToClusterNetworks(clusterNetworksNames, interfaceNetworkNames) && isVmInterfacesAttachedToVmNetworks(clusterNetworks, interfaceNetworkNames); }</code><technical_language>Please move this line of current function rest of processing required in case this validation fails. e.g. if (!isVmInterfacesConfigured(interfaceNetworkMap)){ return false; } rest of validation (no need for returnValue all): Set<String> interfaceNetworkNames = interfaceNetworkMap.keySet(); List<Network> clusterNetworks = getNetworkDAO().getAllForCluster(getVm().getvds_group_id()); ..</technical_language>

Target:
private boolean validateNetworkInterfaces() { Map<String, VmNetworkInterface> interfaceNetworkMap = Entities.interfacesByNetworkName(getVm().getInterfaces()); Set<String> interfaceNetworkNames = interfaceNetworkMap.keySet(); List<Network> clusterNetworks = getNetworkDAO().getAllForCluster(getVm().getvds_group_id()); Set<String> clusterNetworksNames = Entities.objectNames(clusterNetworks); if (!isVmInterfacesConfigured(interfaceNetworkMap)) { return false; } interfaceNetworkMap.remove(null); return isVmInterfacesAttachedToClusterNetworks(clusterNetworksNames, interfaceNetworkNames) && isVmInterfacesAttachedToVmNetworks(clusterNetworks, interfaceNetworkNames); }
Source:
<code>public void patchAddMetadataOnSectionNotExistentTest() throws Exception { context.turnOffAuthorisationSystem(); parentCommunity = CommunityBuilder.createCommunity(context) .withName("Parent Community") .build(); Community child1 = CommunityBuilder.createSubCommunity(context, parentCommunity) .withName("Sub Community") .build(); Collection col1 = CollectionBuilder.createCollection(context, child1) .withName("Collection 1") .build(); WorkspaceItem witem = WorkspaceItemBuilder.createWorkspaceItem(context, col1) .withIssueDate("2019-04-25") .withSubject("ExtraEntry") .build(); configurationService.setProperty("webui.submit.upload.required", false); context.restoreAuthSystemState(); String authToken = getAuthToken(eperson.getEmail(), password); List<Operation> addTitle = new ArrayList<Operation>(); List<Map<String, String>> values = new ArrayList<Map<String, String>>(); Map<String, String> value = new HashMap<String, String>(); value.put("value", "New Title"); values.add(value); addTitle.add(new AddOperation("/sections/not-existing-section/dc.title", values)); String patchBody = getPatchContent(addTitle); <START> getClient(authToken).perform(patch("/api/submission/workspaceitems/" + witem.getID()) <END> .content(patchBody) .contentType(MediaType.APPLICATION_JSON_PATCH_JSON)) .andExpect(status().isUnprocessableEntity()); }</code><technical_language>verify dc.title is created</technical_language>

Target:
public void patchAddMetadataOnSectionNotExistentTest() throws Exception { context.turnOffAuthorisationSystem(); parentCommunity = CommunityBuilder.createCommunity(context) .withName("Parent Community") .build(); Community child1 = CommunityBuilder.createSubCommunity(context, parentCommunity) .withName("Sub Community") .build(); Collection col1 = CollectionBuilder.createCollection(context, child1) .withName("Collection 1") .build(); WorkspaceItem witem = WorkspaceItemBuilder.createWorkspaceItem(context, col1) .withIssueDate("2019-04-25") .withSubject("ExtraEntry") .build(); configurationService.setProperty("webui.submit.upload.required", false); context.restoreAuthSystemState(); String authToken = getAuthToken(eperson.getEmail(), password); List<Operation> addTitle = new ArrayList<Operation>(); List<Map<String, String>> values = new ArrayList<Map<String, String>>(); Map<String, String> value = new HashMap<String, String>(); value.put("value", "New Title"); values.add(value); addTitle.add(new AddOperation("/sections/not-existing-section/dc.title", values)); String patchBody = getPatchContent(addTitle); getClient(authToken).perform(patch("/api/submission/workspaceitems/" + witem.getID()) .content(patchBody) .contentType(MediaType.APPLICATION_JSON_PATCH_JSON)) .andExpect(status().isUnprocessableEntity()); getClient(authToken).perform(get("/api/submission/workspaceitems/" + witem.getID())) .andExpect(status().isOk()) .andExpect(jsonPath("$.sections.traditionalpageone['dc.title']").doesNotExist()); }
Source:
<code>protected Object[] fetchChildren(Object o, IProgressMonitor monitor) throws TeamException { monitor = Policy.monitorFor(monitor); <START> monitor.beginTask(NLS.bind( <END> CVSUIMessages.RemoteFolderElement_fetchingRemoteChildren, new String[] { root.toString() }), 200); try { ICVSRemoteResource[] children = CVSUIPlugin .getPlugin() .getRepositoryManager() .getFoldersForTag(root, tag, Policy.subMonitorFor(monitor, 100)); if (getWorkingSet() != null) children = CVSUIPlugin.getPlugin().getRepositoryManager() .filterResources(getWorkingSet(), children); if (tag.getType() == CVSTag.BRANCH) { return getTopLevelFoldersForChildren(children, Policy.subMonitorFor(monitor, 100)); } else { return children; } } finally { monitor.done(); } }</code><technical_language>a submonitor in case need pass #getTopLevelFoldersForChildren. I avoid if'ing larger amount of code create a submonitor if dealing Branch</technical_language>

Target:
protected Object[] fetchChildren(Object o, IProgressMonitor monitor) throws TeamException { if (tag.getType() == CVSTag.BRANCH) { monitor = Policy.monitorFor(monitor); monitor.beginTask(NLS.bind( CVSUIMessages.RemoteFolderElement_fetchingRemoteChildren, new String[] { root.toString() }), 100); try { ICVSRemoteResource[] children = CVSUIPlugin .getPlugin() .getRepositoryManager() .getFoldersForTag(root, tag, Policy.subMonitorFor(monitor, 50)); if (getWorkingSet() != null) children = CVSUIPlugin.getPlugin().getRepositoryManager() .filterResources(getWorkingSet(), children); return getTopLevelFoldersForChildren(children, Policy.subMonitorFor(monitor, 50)); } finally { monitor.done(); } } ICVSRemoteResource[] children = CVSUIPlugin.getPlugin().getRepositoryManager().getFoldersForTag(root, tag, monitor); if (getWorkingSet() != null) children = CVSUIPlugin.getPlugin().getRepositoryManager().filterResources(getWorkingSet(), children); return children; }
Source:
<code>final Integer[] getDateValues(String filePath, Formatter formatter) { <START> Pattern pattern = DEFAULT_PATH_PATTEN; <END> switch (formatter) { case DEFAULT: case LOWER_DEFAULT: break; case HIVE: pattern = HIVE_PATH_PATTERN; break; default: throw new IAE("Format %s not supported", formatter); } Matcher matcher = pattern.matcher(filePath); Integer[] vals = new Integer[7]; if (matcher.matches()) { for (int i = 1; i <= matcher.groupCount(); i++) { vals[i] = (matcher.group(i) != null) ? Integer.parseInt(matcher.group(i)) : null; } } return vals; }</code><technical_language>a typo: PATTEN</technical_language>

Target:
final Integer[] getDateValues(String filePath, Formatter formatter) { Pattern pattern = DEFAULT_PATH_PATTERN; switch (formatter) { case DEFAULT: case LOWER_DEFAULT: break; case HIVE: pattern = HIVE_PATH_PATTERN; break; default: throw new IAE("Format %s not supported", formatter); } Matcher matcher = pattern.matcher(filePath); Integer[] vals = new Integer[7]; if (matcher.matches()) { for (int i = 1; i <= matcher.groupCount(); i++) { vals[i] = (matcher.group(i) != null) ? Integer.parseInt(matcher.group(i)) : null; } } return vals; }
Source:
<code>protected ManagedConnectionFactory createMcf(org.jboss.jca.common.api.metadata.ds.DataSource arg0, String arg1, ClassLoader arg2) throws NotFoundException, DeployException { final LocalManagedConnectionFactory managedConnectionFactory = new LocalManagedConnectionFactory(); managedConnectionFactory.setDriverClass(dataSourceConfig.getDriverClass()); if (dataSourceConfig.getUrlDelimiter() != null) { try { managedConnectionFactory.setURLDelimiter(dataSourceConfig.getUrlDelimiter()); } catch (Exception e) { throw ConnectorLogger.ROOT_LOGGER.failedToGetUrlDelimiter(e); } } if (dataSourceConfig.getDataSourceClass() != null) { managedConnectionFactory.setDataSourceClass(dataSourceConfig.getDataSourceClass()); } if (dataSourceConfig.getConnectionProperties() != null) { managedConnectionFactory.setConnectionProperties(buildConfigPropsString(dataSourceConfig .getConnectionProperties())); } if (dataSourceConfig.getConnectionUrl() != null) { managedConnectionFactory.setConnectionURL(dataSourceConfig.getConnectionUrl()); } else { <START> managedConnectionFactory.setConnectionURL(""); <END> } if (dataSourceConfig.getNewConnectionSql() != null) { managedConnectionFactory.setNewConnectionSQL(dataSourceConfig.getNewConnectionSql()); } if (dataSourceConfig.getUrlSelectorStrategyClassName() != null) { managedConnectionFactory.setUrlSelectorStrategyClassName(dataSourceConfig.getUrlSelectorStrategyClassName()); } setMcfProperties(managedConnectionFactory, dataSourceConfig, dataSourceConfig.getStatement()); return managedConnectionFactory; }</code><technical_language>Hack bypass <LINK_0></technical_language>

Target:
protected ManagedConnectionFactory createMcf(org.jboss.jca.common.api.metadata.ds.DataSource arg0, String arg1, ClassLoader arg2) throws NotFoundException, DeployException { final LocalManagedConnectionFactory managedConnectionFactory = new LocalManagedConnectionFactory(); managedConnectionFactory.setDriverClass(dataSourceConfig.getDriverClass()); if (dataSourceConfig.getUrlDelimiter() != null) { try { managedConnectionFactory.setURLDelimiter(dataSourceConfig.getUrlDelimiter()); } catch (Exception e) { throw ConnectorLogger.ROOT_LOGGER.failedToGetUrlDelimiter(e); } } if (dataSourceConfig.getDataSourceClass() != null) { managedConnectionFactory.setDataSourceClass(dataSourceConfig.getDataSourceClass()); } if (dataSourceConfig.getConnectionProperties() != null) { managedConnectionFactory.setConnectionProperties(buildConfigPropsString(dataSourceConfig .getConnectionProperties())); } if (dataSourceConfig.getConnectionUrl() != null) { managedConnectionFactory.setConnectionURL(dataSourceConfig.getConnectionUrl()); } if (dataSourceConfig.getNewConnectionSql() != null) { managedConnectionFactory.setNewConnectionSQL(dataSourceConfig.getNewConnectionSql()); } if (dataSourceConfig.getUrlSelectorStrategyClassName() != null) { managedConnectionFactory.setUrlSelectorStrategyClassName(dataSourceConfig.getUrlSelectorStrategyClassName()); } setMcfProperties(managedConnectionFactory, dataSourceConfig, dataSourceConfig.getStatement()); return managedConnectionFactory; }
Source:
<code>public void handleEvent(JSONObject event) { String type = event.getString(MESSAGE_TYPE); String cache = event.getString(MESSAGE_CACHE); <START> if (Strings.areEqual(CallContext.getNodeName(), event.getString(NODE_IDENTIFIER))) { <END> return; } if (Strings.areEqual(type, TYPE_CLEAR)) { CacheManager.clearCoherentCacheLocally(cache); } else if (Strings.areEqual(type, TYPE_REMOVE)) { String key = event.getString(MESSAGE_KEY); CacheManager.removeCoherentCacheKeyLocally(cache, key); } else if (Strings.areEqual(type, TYPE_REMOVE_ALL)) { String discriminator = event.getString(MESSAGE_DISCRIMINATOR); String testValue = event.getString(MESSAGE_TEST_VALUE); CacheManager.coherentCacheRemoveAllLocally(cache, discriminator, testValue); } else if (Strings.areEqual(type, TYPE_PUT)) { String node = event.getString(MESSAGE_NODE); if (!Strings.areEqual(node, CallContext.getNodeName())) { String key = event.getString(MESSAGE_KEY); CacheManager.removeCoherentCacheKeyLocally(cache, key); } } }</code><technical_language>suggestion if (Strings.areEqual(CallContext.getNodeName(), event.getString(MESSAGE_NODE))) {</technical_language>

Target:
public void handleEvent(JSONObject event) { String type = event.getString(MESSAGE_TYPE); String cache = event.getString(MESSAGE_CACHE); if (Strings.areEqual(CallContext.getNodeName(), event.getString(MESSAGE_NODE))) { return; } if (Strings.areEqual(type, TYPE_CLEAR)) { CacheManager.clearCoherentCacheLocally(cache); } else if (Strings.areEqual(type, TYPE_REMOVE)) { String key = event.getString(MESSAGE_KEY); CacheManager.removeCoherentCacheKeyLocally(cache, key); } else if (Strings.areEqual(type, TYPE_REMOVE_ALL)) { String discriminator = event.getString(MESSAGE_DISCRIMINATOR); String testValue = event.getString(MESSAGE_TEST_VALUE); CacheManager.coherentCacheRemoveAllLocally(cache, discriminator, testValue); } }
Source:
<code>public void updateHybridRoleName(String roleName, String newRoleName) throws UserStoreException { if (this.isExistingRole(newRoleName)) { throw new UserStoreException("Role name: " + newRoleName + " in the system. Please pick another role name."); } String sqlStmt = HybridJDBCConstants.UPDATE_ROLE_NAME_SQL; if (sqlStmt == null) { throw new UserStoreException("The sql statement for update hybrid role name is null"); } Connection dbConnection = null; try { dbConnection = getDBConnection(); if (sqlStmt.contains(UserCoreConstants.UM_TENANT_COLUMN)) { DatabaseUtil.updateDatabase(dbConnection, sqlStmt, newRoleName, roleName, tenantId); } else { DatabaseUtil.updateDatabase(dbConnection, sqlStmt, newRoleName, roleName); } dbConnection.commit(); this.userRealm.getAuthorizationManager().resetPermissionOnUpdateRole(roleName, newRoleName); } catch (SQLException e) { <START> String errorMessage = "Error occurred while updating role name :"+roleName+"to :"+roleName; <END> throw new UserStoreException(errorMessage, e); } finally { DatabaseUtil.closeAllConnections(dbConnection); } }</code><technical_language>add debug log, correct spacing</technical_language>

Target:
public void updateHybridRoleName(String roleName, String newRoleName) throws UserStoreException { if (this.isExistingRole(newRoleName)) { throw new UserStoreException("Role name: " + newRoleName + " in the system. Please pick another role name."); } String sqlStmt = HybridJDBCConstants.UPDATE_ROLE_NAME_SQL; if (sqlStmt == null) { throw new UserStoreException("The sql statement for update hybrid role name is null"); } Connection dbConnection = null; try { dbConnection = getDBConnection(); if (sqlStmt.contains(UserCoreConstants.UM_TENANT_COLUMN)) { DatabaseUtil.updateDatabase(dbConnection, sqlStmt, newRoleName, roleName, tenantId); } else { DatabaseUtil.updateDatabase(dbConnection, sqlStmt, newRoleName, roleName); } dbConnection.commit(); this.userRealm.getAuthorizationManager().resetPermissionOnUpdateRole(roleName, newRoleName); } catch (SQLException e) { String errorMessage = "Error occurred while updating role name :" + roleName + "to : " + roleName; if (log.isDebugEnabled()) { log.debug(errorMessage, e); } throw new UserStoreException(errorMessage, e); } finally { DatabaseUtil.closeAllConnections(dbConnection); } }
Source:
<code>protected void addVmStatic() { VmStatic vmStatic = getParameters().getVmStaticData(); if (vmStatic.getOrigin() == null) { vmStatic.setOrigin(OriginType.valueOf(Config.<String> GetValue(ConfigValues.OriginType))); } vmStatic.setId(getVmId()); vmStatic.setQuotaId(getQuotaId()); vmStatic.setCreationDate(new Date()); vmStatic.setCreatedByUserId(getUserId()); if (vmStatic.getCustomProperties() != null) { VMCustomProperties properties = VmPropertiesUtils.getInstance().parseProperties(getVdsGroupDAO() .get(getParameters().getVm().getVdsGroupId()) .getcompatibility_version(), vmStatic.getCustomProperties()); String predefinedProperties = properties.getPredefinedProperties(); String userDefinedProperties = properties.getUseDefinedProperties(); vmStatic.setPredefinedProperties(predefinedProperties); vmStatic.setUserDefinedProperties(userDefinedProperties); } vmStatic.setOriginalTemplateGuid(vmStatic.getVmtGuid()); <START> VmTemplate template = getVmTemplateDAO().get(vmStatic.getVmtGuid()); <END> vmStatic.setOriginalTemplateName(template.getName()); getVmStaticDao().save(vmStatic); getCompensationContext().snapshotNewEntity(vmStatic); }</code><technical_language>save a DAO fetch if vmt id equals empty guid.</technical_language>

Target:
protected void addVmStatic() { VmStatic vmStatic = getParameters().getVmStaticData(); if (vmStatic.getOrigin() == null) { vmStatic.setOrigin(OriginType.valueOf(Config.<String> GetValue(ConfigValues.OriginType))); } vmStatic.setId(getVmId()); vmStatic.setQuotaId(getQuotaId()); vmStatic.setCreationDate(new Date()); vmStatic.setCreatedByUserId(getUserId()); if (vmStatic.getCustomProperties() != null) { VMCustomProperties properties = VmPropertiesUtils.getInstance().parseProperties(getVdsGroupDAO() .get(getParameters().getVm().getVdsGroupId()) .getcompatibility_version(), vmStatic.getCustomProperties()); String predefinedProperties = properties.getPredefinedProperties(); String userDefinedProperties = properties.getUseDefinedProperties(); vmStatic.setPredefinedProperties(predefinedProperties); vmStatic.setUserDefinedProperties(userDefinedProperties); } vmStatic.setOriginalTemplateGuid(vmStatic.getVmtGuid()); if (VmTemplateHandler.BlankVmTemplateId.equals(vmStatic.getVmtGuid())) { vmStatic.setOriginalTemplateName(VmTemplateHandler.BlankVmTemplateName); } else { VmTemplate template = getVmTemplateDAO().get(vmStatic.getVmtGuid()); vmStatic.setOriginalTemplateName(template.getName()); } getVmStaticDao().save(vmStatic); getCompensationContext().snapshotNewEntity(vmStatic); }
Source:
<code>public static String sendHttpGet(final String url) throws Exception { HttpUriRequest request = RequestBuilder.get(url).setHeader(HttpHeaders.CONTENT_TYPE, APPLICATION_JSON) <START> .build(); <END> return httpClient.execute(request, getStringResponseHandler()); }</code><technical_language>put .build() in previous line</technical_language>

Target:
public static String sendHttpGet(final String url) throws Exception { HttpUriRequest request = RequestBuilder.get(url).setHeader(HttpHeaders.CONTENT_TYPE, APPLICATION_JSON).build(); return HTTP_CLIENT.execute(request, getStringResponseHandler()); }
Source:
<code>public static void append(File file, Object text, String charset, boolean writeBom) throws IOException { Writer writer = null; try { boolean shouldWriteBom = writeBom && !file.exists(); FileOutputStream out = new FileOutputStream(file, true); <START> if (shouldWriteBom) { <END> IOGroovyMethods.writeUTF16BomIfRequired(charset, out); } writer = new OutputStreamWriter(out, charset); InvokerHelper.write(writer, text); writer.flush(); Writer temp = writer; writer = null; temp.close(); } finally { closeWithWarning(writer); } }</code><technical_language>!file.exists() check</technical_language>

Target:
public static void append(File file, Object text, String charset, boolean writeBom) throws IOException { Writer writer = null; try { boolean shouldWriteBom = writeBom && !file.exists(); FileOutputStream out = new FileOutputStream(file, true); if (shouldWriteBom) { IOGroovyMethods.writeUTF16BomIfRequired(out, charset); } writer = new OutputStreamWriter(out, charset); InvokerHelper.write(writer, text); writer.flush(); Writer temp = writer; writer = null; temp.close(); } finally { closeWithWarning(writer); } }
Source:
<code>public void setPropertyFileLocation(String propertyFileLocation) { if (propertyFileLocation != null && !propertyFileLocation.isEmpty() && !propertyFileLocation.equals(this.propertyFileLocation)) { Properties p = new Properties(); try { p.load(getClass().getResourceAsStream(propertyFileLocation)); } catch (FileNotFoundException e) { LOGGER.debug("File not found when attempting to load user properties file.", e); } catch (IOException e) { LOGGER.debug("Exception when trying to load the user properties file.", e); <START> } <END> propBackingEngine = new PropertiesBackingEngine(p); List<UserPrincipal> userList = propBackingEngine.listUsers(); userMapping = new HashMap(); for (UserPrincipal eachUser : userList) { List<RolePrincipal> userRoles = propBackingEngine.listRoles(eachUser); List<String> roleList = new ArrayList(); for (RolePrincipal userRole : userRoles) { roleList.add(userRole.getName()); } userMapping.put(eachUser.getName(), StringUtils.join(roleList, ",")); } } this.propertyFileLocation = propertyFileLocation; }</code><technical_language>I PropertiesLoader.loadProperties(propertyFileLocation) get Properties object instead of manually this try/catch block. inherit built-in cross-OS compatibility handling for relative absolute paths</technical_language>

Target:
public void setPropertyFileLocation(String propertyFileLocation) { if (propertyFileLocation != null && !propertyFileLocation.isEmpty() && !propertyFileLocation.equals(this.propertyFileLocation.toString())) { setPropertyFileLocation(Paths.get(propertyFileLocation)); } }
Source:
<code>protected boolean set(EntityLivingBase container, Float value) { <START> container.fallDistance = value; <END> return true; }</code><technical_language>here. needs some validation</technical_language>

Target:
protected boolean set(EntityLivingBase container, Float value) { container.fallDistance = Preconditions.checkNotNull(value); return true; }
Source:
<code>public V apply(Map.Entry<Key, Value> keyValueEntry) { EventFields eventFields = new EventFields(); eventFields.read(kryo, new Input(keyValueEntry.getValue().get()), EventFields.class); V entry = buildTupleCollectionFromKey(keyValueEntry.getKey()); for (Map.Entry<String, EventFields.FieldValue> fieldValue : eventFields.entries()) { String[] aliasVal = splitPreserveAllTokens(new String(fieldValue.getValue().getValue()), ONE_BYTE); Object javaVal = typeRegistry.decode(aliasVal[0], aliasVal[1]); String vis = fieldValue.getValue().getVisibility().getExpression().length > 0 ? new String(fieldValue.getValue().getVisibility().getExpression()) : ""; try { Map<String,Object> meta = metadataSerDe.deserialize(fieldValue.getValue().getMetadata()); <START> if(meta != null) { <END> Map<String,Object> metadata = new HashMap<String,Object>(); metadata.putAll(meta); setVisibility(metadata, vis); Tuple tuple = new Tuple(fieldValue.getKey(), javaVal, metadata); entry.put(tuple); } else { Map<String,Object> metadata = new HashMap<String,Object>(); setVisibility(metadata, vis); Tuple tuple = new Tuple(fieldValue.getKey(), javaVal, metadata); entry.put(tuple); } } catch(Exception e) { log.error("There was an error deserializing the metadata for a tuple", e); } } return entry; }</code><technical_language>Instead of duplicating of logic, simply if else logic for creating metadata object a rest of logic in this if statement is same. For example Map<String,Object> metadata = (meta == null : new HashMap<String, Object>() ? new HashMap<String, Object>(meta)); setVisibility(metadata, vis); Tuple tuple = new Tuple(fieldValue.getKey(), javaVal, metadata); entry.put(tuple);</technical_language>

Target:
public V apply(Map.Entry<Key, Value> keyValueEntry) { EventFields eventFields = new EventFields(); eventFields.read(kryo, new Input(keyValueEntry.getValue().get()), EventFields.class); V entry = buildTupleCollectionFromKey(keyValueEntry.getKey()); for (Map.Entry<String, EventFields.FieldValue> fieldValue : eventFields.entries()) { String[] aliasVal = splitPreserveAllTokens(new String(fieldValue.getValue().getValue()), ONE_BYTE); Object javaVal = typeRegistry.decode(aliasVal[0], aliasVal[1]); String vis = fieldValue.getValue().getVisibility().getExpression().length > 0 ? new String(fieldValue.getValue().getVisibility().getExpression()) : ""; try { Map<String,Object> meta = metadataSerDe.deserialize(fieldValue.getValue().getMetadata()); Map<String,Object> metadata = (meta == null ? new HashMap<String,Object>() : new HashMap<String,Object>(meta)); setVisibility(metadata, vis); Tuple tuple = new Tuple(fieldValue.getKey(), javaVal, metadata); entry.put(tuple); } catch(Exception e) { log.error("There was an error deserializing the metadata for a tuple", e); } } return entry; }
Source:
<code>public void startAndShutdownWithDefaults() throws Exception { System.setProperty(NinjaProperties.NINJA_EXTERNAL_CONF, "conf/minimal.conf"); NinjaJetty nj = new NinjaJetty(); nj.setPort(randomPort); try { <START> Assert.assertEquals(new Integer(randomPort), nj.port); <END> Assert.assertNull(nj.host); Assert.assertNull(nj.ninjaContextPath); Assert.assertEquals(NinjaMode.prod, nj.ninjaMode); nj.start(); Assert.assertNotNull("http://localhost:" + randomPort, nj.ninjaProperties.get(NinjaConstant.serverName)); Assert.assertNotNull(nj.context); Assert.assertNotNull(nj.ninjaServletListener); Assert.assertTrue(nj.context.isAvailable()); Assert.assertTrue(nj.context.isStarted()); Assert.assertTrue(nj.server.isStarted()); nj.shutdown(); Assert.assertTrue(nj.context.isStopped()); Assert.assertTrue(nj.server.isStopped()); } finally { nj.shutdown(); } }</code><technical_language>statically import Assert? test more concise..</technical_language>

Target:
public void startAndShutdownWithDefaults() throws Exception { System.setProperty(NinjaProperties.NINJA_EXTERNAL_CONF, "conf/minimal.conf"); NinjaJetty nj = new NinjaJetty(); nj.setPort(randomPort); try { assertEquals(new Integer(randomPort), nj.port); assertNull(nj.host); assertNull(nj.ninjaContextPath); assertEquals(NinjaMode.prod, nj.ninjaMode); nj.start(); assertNotNull("http://localhost:" + randomPort, nj.ninjaProperties.get(NinjaConstant.serverName)); assertNotNull(nj.context); assertNotNull(nj.ninjaServletListener); assertTrue(nj.context.isAvailable()); assertTrue(nj.context.isStarted()); assertTrue(nj.server.isStarted()); nj.shutdown(); assertTrue(nj.context.isStopped()); assertTrue(nj.server.isStopped()); } finally { nj.shutdown(); } }
Source:
<code>public List<Condition> searchConditionByName(String name) throws NotImplementedException { <START> return null; <END> }</code><technical_language>I throwing NotImplementedException instead of returning null</technical_language>

Target:
public List<Condition> searchConditionByName(String name) { throw new NotImplementedException(); }
Source:
<code>public ConfigurableApplicationContext run(String[] parentArgs) { ConfigurableApplicationContext parentContext = this.parentContext != null ? this.parentContext : AggregateApplication.createParentContext(parentArgs); SharedChannelRegistry sharedChannelRegistry = parentContext .getBean(SharedChannelRegistry.class); List<AppConfigurer<?>> apps = new ArrayList<AppConfigurer<?>>(); if (this.sourceConfigurer != null) { apps.add(sourceConfigurer); } if (!processorConfigurers.isEmpty()) { for (ProcessorConfigurer processorConfigurer : processorConfigurers) { apps.add(processorConfigurer); } } if (this.sinkConfigurer != null) { apps.add(sinkConfigurer); } List<Class<?>> appsToEmbed = new ArrayList<>(); String namespace = null; for (int i = 0; i < apps.size(); i++) { AppConfigurer<?> appConfigurer = apps.get(i); appsToEmbed.add(appConfigurer.getApp()); if (namespace == null) { <START> namespace = appConfigurer.namespace; <END> } } AggregateApplication.prepareSharedChannelRegistry(sharedChannelRegistry, appsToEmbed.toArray(new Class<?>[0]), namespace); for (int i = apps.size() - 1; i >= 0; i--) { AppConfigurer<?> appConfigurer = apps.get(i); appConfigurer.namespace(AggregateApplication .getNamespace(namespace, appConfigurer.getApp().getName(), i)); appConfigurer.embed(); } return parentContext; }</code><technical_language>goal of namespace is disambiguate channels name, belong applications (e.g. output channels belong successive Processors), registered in SharedChannelRegistry. namespaces for embedded app</technical_language>

Target:
public ConfigurableApplicationContext run(String[] parentArgs) { ConfigurableApplicationContext parentContext = this.parentContext != null ? this.parentContext : AggregateApplication.createParentContext(parentArgs); SharedChannelRegistry sharedChannelRegistry = parentContext .getBean(SharedChannelRegistry.class); List<AppConfigurer<?>> apps = new ArrayList<AppConfigurer<?>>(); if (this.sourceConfigurer != null) { apps.add(sourceConfigurer); } if (!processorConfigurers.isEmpty()) { for (ProcessorConfigurer processorConfigurer : processorConfigurers) { apps.add(processorConfigurer); } } if (this.sinkConfigurer != null) { apps.add(sinkConfigurer); } LinkedHashMap<Class<?>, String> appsToEmbed = new LinkedHashMap<>(); for (int i = 0; i < apps.size(); i++) { AppConfigurer<?> appConfigurer = apps.get(i); Class<?> appToEmbed = appConfigurer.getApp(); appsToEmbed.put(appToEmbed, appConfigurer.namespace); } AggregateApplication.prepareSharedChannelRegistry(sharedChannelRegistry, appsToEmbed); for (int i = apps.size() - 1; i >= 0; i--) { AppConfigurer<?> appConfigurer = apps.get(i); appConfigurer.namespace(AggregateApplication .getNamespace(appConfigurer.namespace, appConfigurer.getApp().getName(), i)); appConfigurer.embed(); } return parentContext; }
Source:
<code>public void save() { <START> clusters.stream().forEach(ICluster::save); <END> Preferences accountRoot = getAccountsPreferences(); ISecurePreferences accountSecureRoot = getSecureAccountsPreferences(); removed.stream().forEach(id -> { try { accountRoot.node(id).removeNode(); accountSecureRoot.node(id).removeNode(); } catch (BackingStoreException e) { OpenShiftIOCoreActivator.logError(e.getLocalizedMessage(), e); } }); removed.clear(); }</code><technical_language>call forEach once, stream()</technical_language>

Target:
public void save() { clusters.forEach(ICluster::save); Preferences accountRoot = getAccountsPreferences(); ISecurePreferences accountSecureRoot = getSecureAccountsPreferences(); removed.forEach(id -> { removeAccount(id ,accountRoot, accountSecureRoot); }); removed.clear(); }
Source:
<code>public void onMediaUploadCancelClicked(String mediaId, boolean delete) { if (!TextUtils.isEmpty(mediaId)) { int localMediaId = Integer.valueOf(mediaId); EventBus.getDefault().post(new PostEvents.PostMediaCanceled(localMediaId)); } else { <START> EventBus.getDefault().post(new PostEvents.PostMediaCanceled(true)); <END> } }</code><technical_language>Gotcha. toast message a nice addition though, user</technical_language>

Target:
public void onMediaUploadCancelClicked(String mediaId, boolean delete) { if (!TextUtils.isEmpty(mediaId)) { int localMediaId = Integer.valueOf(mediaId); EventBus.getDefault().post(new PostEvents.PostMediaCanceled(localMediaId)); } else { ToastUtils.showToast(this, getString(R.string.error_all_media_upload_canceled)); EventBus.getDefault().post(new PostEvents.PostMediaCanceled(true)); } }
Source:
<code>private Revision getRevision(RevCommit commit, String sFilePath) throws GitAPIException, IOException { List<String> commitParentsList = getCommitParents(commit); List<Branch> commitBranchesList = getCommitBranches(commit, ListMode.ALL); List<DiffCommitFile> diffCommitFilesList = getCommitDiffFiles(commit,sFilePath); <START> GitUser oAuthor = getCommitAuthor(commit); <END> GitUser oCommitter = getCommitCommitter(commit); Revision revision = createDto(Revision.class).withId(commit.getId() .getName()) .withMessage(commit.getFullMessage()) .withCommitTime((long) commit.getCommitTime() * 1000) .withCommitter(oCommitter) .withAuthor(oAuthor) .withBranches(commitBranchesList) .withCommitParent(commitParentsList) .withDiffCommitFile(diffCommitFilesList); return revision; }</code><technical_language>explain is o prefix in variable name</technical_language>

Target:
private Revision getRevision(RevCommit commit, String sFilePath) throws GitAPIException, IOException { List<String> commitParentsList = Stream.of(commit.getParents()) .map(RevCommit::getName) .collect(Collectors.toList()); List<Branch> commitBranchesList = getCommitBranches(commit, ListMode.ALL); List<DiffCommitFile> diffCommitFilesList = getCommitDiffFiles(commit,sFilePath); GitUser author = getCommitAuthor(commit); GitUser committer = getCommitCommitter(commit); Revision revision = createDto(Revision.class).withId(commit.getId() .getName()) .withMessage(commit.getFullMessage()) .withCommitTime((long) commit.getCommitTime() * 1000) .withCommitter(committer) .withAuthor(author) .withBranches(commitBranchesList) .withCommitParent(commitParentsList) .withDiffCommitFile(diffCommitFilesList); return revision; }
Source:
<code>public void hasNoActiveMemberships_shouldReturnFalseIfOneExists() throws Exception{ SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); Date endDateLater = dateFormat.parse("2100-02-01 00:00:00"); Cohort cohort = new Cohort(3); CohortMembership temp = new CohortMembership(7); temp.setVoided(false); temp.setEndDate(endDateLater); cohort.addMembership(temp); <START> <END> assertFalse(cohort.hasNoActiveMemberships()); }</code><technical_language>this test pass year 2100</technical_language>

Target:
public void hasNoActiveMemberships_shouldReturnFalseIfOneExists() throws Exception{ Calendar calendar = Calendar.getInstance(); calendar.add(Calendar.DAY_OF_YEAR, 1); Date endDateLater = calendar.getTime(); Cohort cohort = new Cohort(3); CohortMembership temp = new CohortMembership(7); temp.setVoided(false); temp.setEndDate(endDateLater); cohort.addMembership(temp); assertFalse(cohort.hasNoActiveMemberships()); }
Source:
<code>public boolean sendSerialData(XBee64BitAddress address, byte[] data) throws InterfaceNotOpenException, InvalidOperatingModeException, TimeoutException, IOException { if (!connectionInterface.isOpen()) throw new InterfaceNotOpenException(); XBeePacket xbeePacket; XBeePacket receivedPacket; if (address == null || data == null) throw new NullPointerException("Address and data cannot be null"); <START> logger.info("Sending data to >> {}.", address, HexUtils.byteArrayToHexString(data)); <END> switch (getXBeeProtocol()) { case RAW_802_15_4: xbeePacket = new TX64Packet(getNextFrameID(), address, XBeeTransmitOptions.NONE, data); receivedPacket = sendXBeePacket(xbeePacket); if (receivedPacket == null) return true; if (receivedPacket instanceof TXStatusPacket) { switch (((TXStatusPacket)receivedPacket).getTransmitStatus()) { case SUCCESS: return true; default: return false; } } else return false; default: xbeePacket = new TransmitPacket(getNextFrameID(), address, XBee16BitAddress.UNKNOWN_ADDRESS, 0, XBeeTransmitOptions.NONE, data); receivedPacket = sendXBeePacket(xbeePacket); if (receivedPacket == null) return true; if (receivedPacket instanceof TransmitStatusPacket) { switch (((TransmitStatusPacket)receivedPacket).getTransmitStatus()) { case SUCCESS: return true; default: return false; } } else return false; } }</code><technical_language>Change 'Sending serial data [...]'</technical_language>

Target:
public boolean sendSerialData(XBee64BitAddress address, byte[] data) throws InterfaceNotOpenException, InvalidOperatingModeException, TimeoutException, IOException { if (!connectionInterface.isOpen()) throw new InterfaceNotOpenException(); if (address == null) throw new NullPointerException("Address cannot be null"); if (data == null) throw new NullPointerException("Data cannot be null"); XBeePacket xbeePacket; XBeePacket receivedPacket; logger.info(toString() + "Sending serial data to >> {}.", address, HexUtils.byteArrayToHexString(data)); switch (getXBeeProtocol()) { case RAW_802_15_4: xbeePacket = new TX64Packet(getNextFrameID(), address, XBeeTransmitOptions.NONE, data); receivedPacket = sendXBeePacket(xbeePacket); if (receivedPacket == null) return true; if (receivedPacket instanceof TXStatusPacket) { switch (((TXStatusPacket)receivedPacket).getTransmitStatus()) { case SUCCESS: return true; default: return false; } } else return false; default: xbeePacket = new TransmitPacket(getNextFrameID(), address, XBee16BitAddress.UNKNOWN_ADDRESS, 0, XBeeTransmitOptions.NONE, data); receivedPacket = sendXBeePacket(xbeePacket); if (receivedPacket == null) return true; if (receivedPacket instanceof TransmitStatusPacket) { switch (((TransmitStatusPacket)receivedPacket).getTransmitStatus()) { case SUCCESS: return true; default: return false; } } else return false; } }
Source:
<code>public void removeContrib(EventDispatcherDescriptor contrib) { Iterator<EventDispatcherDescriptor> it = contribs.iterator(); while (it.hasNext()) { EventDispatcherDescriptor desc = it.next(); if (desc.getName().equals(contrib.getName())) { it.remove(); break; } <START> } <END> }</code><technical_language>List.removeIf instead of this code</technical_language>

Target:
public void removeContrib(EventDispatcherDescriptor contrib) { contribs.removeIf(descriptor -> descriptor.getName().equals(contrib.getName())); }
Source:
<code>public void testChangeMessageOfLastCommit(GitConnectionFactory connectionFactory) throws GitException, IOException { GitConnection connection = connectToGitRepositoryWithContent(connectionFactory, repository); int commitsBefore = connection.log(newDto(LogRequest.class)).getCommits().size(); CommitRequest commitRequest = newDto(CommitRequest.class).withMessage("Changed message").withAmend(true); connection.commit(commitRequest); int commitsAfter = connection.log(newDto(LogRequest.class)).getCommits().size(); <START> assertEquals(commitsBefore, commitsAfter); <END> assertEquals(connection.log(newDto(LogRequest.class)).getCommits().get(commitsAfter - 1).getMessage(), commitRequest.getMessage()); }</code><technical_language>check equals of commits commit. in fact compare commits number. for rename this variable this aspect clear</technical_language>

Target:
public void testChangeMessageOfLastCommit(GitConnectionFactory connectionFactory) throws GitException, IOException { GitConnection connection = connectToGitRepositoryWithContent(connectionFactory, repository); addFile(connection, "NewFile.txt", CONTENT); connection.add(newDto(AddRequest.class).withFilepattern(ImmutableList.of("NewFile.txt"))); connection.commit(newDto(CommitRequest.class).withMessage("First commit")); int beforeCommitsCount = connection.log(newDto(LogRequest.class)).getCommits().size(); CommitRequest commitRequest = newDto(CommitRequest.class).withMessage("Changed message").withAmend(true); connection.commit(commitRequest); int afterCommitsCount = connection.log(newDto(LogRequest.class)).getCommits().size(); assertEquals(beforeCommitsCount, afterCommitsCount); assertEquals(connection.log(newDto(LogRequest.class)).getCommits().get(0).getMessage(), commitRequest.getMessage()); }
Source:
<code>public void reinstatePatchForbiddenTest() throws Exception { context.turnOffAuthorisationSystem(); parentCommunity = CommunityBuilder.createCommunity(context) .withName("Parent Community") .build(); Community child1 = CommunityBuilder.createSubCommunity(context, parentCommunity) .withName("Sub Community") .build(); Collection col1 = CollectionBuilder.createCollection(context, child1) .withName("Collection 1").build(); context.setCurrentUser(admin); Item item = ItemBuilder.createItem(context, col1) .withTitle("Public item 1") .withIssueDate("2017-10-17") .withAuthor("Smith, Donald").withAuthor("Doe, John") .withSubject("ExtraEntry") .withdrawn() .build(); String token = getAuthToken(eperson.getEmail(), password); String tokenAdmin = getAuthToken(admin.getEmail(), password); List<Operation> ops = new ArrayList<Operation>(); <START> ReplaceOperation replaceOperation = new ReplaceOperation("/withdrawn", "false"); <END> ops.add(replaceOperation); String patchBody = getPatchContent(ops); getClient(token).perform(patch("/api/core/items/" + item.getID()) .content(patchBody) .contentType(MediaType.APPLICATION_JSON_PATCH_JSON)) .andExpect(status().isForbidden()); getClient(tokenAdmin).perform(get("/api/core/items/" + item.getID())) .andExpect(status().isOk()) .andExpect(jsonPath("$.uuid", Matchers.is(item.getID().toString()))) .andExpect(jsonPath("$.withdrawn", Matchers.is(true))) .andExpect(jsonPath("$.inArchive", Matchers.is(false))); }</code><technical_language>official true instead "true"</technical_language>

Target:
public void reinstatePatchForbiddenTest() throws Exception { context.turnOffAuthorisationSystem(); parentCommunity = CommunityBuilder.createCommunity(context) .withName("Parent Community") .build(); Community child1 = CommunityBuilder.createSubCommunity(context, parentCommunity) .withName("Sub Community") .build(); Collection col1 = CollectionBuilder.createCollection(context, child1) .withName("Collection 1").build(); context.setCurrentUser(admin); Item item = ItemBuilder.createItem(context, col1) .withTitle("Public item 1") .withIssueDate("2017-10-17") .withAuthor("Smith, Donald").withAuthor("Doe, John") .withSubject("ExtraEntry") .withdrawn() .build(); String token = getAuthToken(eperson.getEmail(), password); String tokenAdmin = getAuthToken(admin.getEmail(), password); List<Operation> ops = new ArrayList<Operation>(); ReplaceOperation replaceOperation = new ReplaceOperation("/withdrawn", false); ops.add(replaceOperation); String patchBody = getPatchContent(ops); getClient(token).perform(patch("/api/core/items/" + item.getID()) .content(patchBody) .contentType(MediaType.APPLICATION_JSON_PATCH_JSON)) .andExpect(status().isForbidden()); getClient(tokenAdmin).perform(get("/api/core/items/" + item.getID())) .andExpect(status().isOk()) .andExpect(jsonPath("$.uuid", Matchers.is(item.getID().toString()))) .andExpect(jsonPath("$.withdrawn", Matchers.is(true))) .andExpect(jsonPath("$.inArchive", Matchers.is(false))); }