private String getSample(AtlasClient.EntityResult entityResult) { String sample = getSample(entityResult.getCreatedEntities()); if (sample == null) { sample = getSample(entityResult.getUpdateEntities()); } return sample; }
@Test public void testUpdateEntity() throws Exception { final String guid = random(); Response response = mock(Response.class); when(entityResource.updateByUniqueAttribute( anyString(), anyString(), anyString(), any(HttpServletRequest.class))) .thenReturn(response); when(response.getEntity()) .thenReturn( new JSONObject() { { put( ENTITIES, new JSONObject( new AtlasClient.EntityResult(null, Arrays.asList(guid), null) .toString()) .get(ENTITIES)); } }); LocalAtlasClient atlasClient = new LocalAtlasClient(serviceState, entityResource); AtlasClient.EntityResult entityResult = atlasClient.updateEntity(random(), random(), random(), new Referenceable(random())); assertEquals(entityResult.getUpdateEntities(), Arrays.asList(guid)); }